Details

    • 10.1.14

    Description

      A user is granted one role only and no other privileges.
      SET ROLE NONE makes mysqld crash

      mysql> SET ROLE NONE;
      ERROR 2013 (HY000): Lost connection to MySQL server during query
      

      Attachments

        Activity

          elenst Elena Stepanova added a comment - - edited

          Could you please attach your error log and cnf file(s)?

          It does not crash for me:

          MariaDB [test]> create user foo@localhost;
          Query OK, 0 rows affected (0.66 sec)
           
          MariaDB [test]> create role r;
          Query OK, 0 rows affected (0.00 sec)
           
          MariaDB [test]> grant r to foo@localhost;
          Query OK, 0 rows affected (0.00 sec)
           
          MariaDB [test]> exit
          Bye
          

          $ client/mysql -ufoo test
          Welcome to the MariaDB monitor.  Commands end with ; or \g.
          Your MariaDB connection id is 4
          Server version: 10.1.13-MariaDB-debug Source distribution
           
          Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
           
          Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
           
          MariaDB [test]> SET ROLE NONE;
          Query OK, 0 rows affected (0.00 sec)
          

          elenst Elena Stepanova added a comment - - edited Could you please attach your error log and cnf file(s)? It does not crash for me: MariaDB [test]> create user foo@localhost; Query OK, 0 rows affected (0.66 sec)   MariaDB [test]> create role r; Query OK, 0 rows affected (0.00 sec)   MariaDB [test]> grant r to foo@localhost; Query OK, 0 rows affected (0.00 sec)   MariaDB [test]> exit Bye $ client/mysql -ufoo test Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 4 Server version: 10.1.13-MariaDB-debug Source distribution   Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.   Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.   MariaDB [test]> SET ROLE NONE; Query OK, 0 rows affected (0.00 sec)
          ip1981 Igor Pashev added a comment - Attached my.cnf backtrace.txt
          ip1981 Igor Pashev added a comment -

          Right, it works for user@localhost.

          This is what I see for user@'%' when connecting locally (unix-socket I guess) (only this record exists in mysql.user)

          # mysql -u abcdefg
          Welcome to the MariaDB monitor.  Commands end with ; or \g.
          Your MariaDB connection id is 47
          Server version: 10.1.13-MariaDB MariaDB Server
           
          Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
           
          Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
           
          MariaDB [(none)]> show grants;
          +-------------------------------------------------+
          | Grants for abcdefg@%                            |
          +-------------------------------------------------+
          | GRANT all_all TO 'abcdefg'@'%'                  |
          | GRANT USAGE ON *.* TO 'abcdefg'@'%'             |
          | GRANT SELECT ON `mysql`.`user` TO 'abcdefg'@'%' |
          +-------------------------------------------------+
          3 rows in set (0.00 sec)
           
          MariaDB [(none)]> SET ROLE NONE;
          ERROR 1960 (0L000): The current user is invalid.
          MariaDB [(none)]> SET ROLE all_all;
          Query OK, 0 rows affected (0.00 sec)
           
          MariaDB [(none)]> SET ROLE NONE;
          ERROR 1960 (0L000): The current user is invalid.
          MariaDB [(none)]> Bye
          

          And when I connect by TCP from outside:

          # mysql -h  192.168.56.101 -u abcdefg
          Welcome to the MariaDB monitor.  Commands end with ; or \g.
          Your MariaDB connection id is 50
          Server version: 10.1.13-MariaDB MariaDB Server
           
          Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
           
          Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
           
          MariaDB [(none)]> set role none;
          ERROR 2013 (HY000): Lost connection to MySQL server during query
          MariaDB [(none)]> 
          

          ip1981 Igor Pashev added a comment - Right, it works for user@localhost . This is what I see for user@'%' when connecting locally (unix-socket I guess) (only this record exists in mysql.user ) # mysql -u abcdefg Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 47 Server version: 10.1.13-MariaDB MariaDB Server   Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.   Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.   MariaDB [(none)]> show grants; +-------------------------------------------------+ | Grants for abcdefg@% | +-------------------------------------------------+ | GRANT all_all TO 'abcdefg'@'%' | | GRANT USAGE ON *.* TO 'abcdefg'@'%' | | GRANT SELECT ON `mysql`.`user` TO 'abcdefg'@'%' | +-------------------------------------------------+ 3 rows in set (0.00 sec)   MariaDB [(none)]> SET ROLE NONE; ERROR 1960 (0L000): The current user is invalid. MariaDB [(none)]> SET ROLE all_all; Query OK, 0 rows affected (0.00 sec)   MariaDB [(none)]> SET ROLE NONE; ERROR 1960 (0L000): The current user is invalid. MariaDB [(none)]> Bye And when I connect by TCP from outside: # mysql -h 192.168.56.101 -u abcdefg Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 50 Server version: 10.1.13-MariaDB MariaDB Server   Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.   Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.   MariaDB [(none)]> set role none; ERROR 2013 (HY000): Lost connection to MySQL server during query MariaDB [(none)]>
          elenst Elena Stepanova added a comment - - edited

          Thank you.

          I'm not getting the buffer overflow, but I guess it's just the matter of environment, binaries, maybe luck. Anyway, something is already wrong when we start getting ERROR 1960 The current user is invalid (which I'm getting too on a user with an unspecified host).

          elenst Elena Stepanova added a comment - - edited Thank you. I'm not getting the buffer overflow, but I guess it's just the matter of environment, binaries, maybe luck. Anyway, something is already wrong when we start getting ERROR 1960 The current user is invalid (which I'm getting too on a user with an unspecified host).
          ip1981 Igor Pashev added a comment -

          I think check_user_can_set_role should find something for the user, but with find_user_exact it does not.

          diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
          index d34f04c..e39992d 100644
          --- a/sql/sql_acl.cc
          +++ b/sql/sql_acl.cc
          @@ -2035,7 +2035,7 @@ static int check_user_can_set_role(const char *user, const char *host,
             {
               /* have to clear the privileges */
               /* get the current user */
          -    acl_user= find_user_exact(host, user);
          +    acl_user= find_user_wild(host, user, ip);
               if (acl_user == NULL)
               {
                 my_error(ER_INVALID_CURRENT_USER, MYF(0), rolename);
          

          ip1981 Igor Pashev added a comment - I think check_user_can_set_role should find something for the user, but with find_user_exact it does not. diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index d34f04c..e39992d 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -2035,7 +2035,7 @@ static int check_user_can_set_role(const char *user, const char *host, { /* have to clear the privileges */ /* get the current user */ - acl_user= find_user_exact(host, user); + acl_user= find_user_wild(host, user, ip); if (acl_user == NULL) { my_error(ER_INVALID_CURRENT_USER, MYF(0), rolename);
          holyfoot Alexey Botchkov added a comment - Proposed fix: http://lists.askmonty.org/pipermail/commits/2016-April/009327.html
          holyfoot Alexey Botchkov added a comment - http://lists.askmonty.org/pipermail/commits/2016-April/009327.html

          People

            holyfoot Alexey Botchkov
            ip1981 Igor Pashev
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.