Bug #91981 | Inconsistent user@host definitions for definer/grantor/grantee columns | ||
---|---|---|---|
Submitted: | 11 Aug 2018 13:02 | Modified: | 22 Aug 2018 11:02 |
Reporter: | Paul Campbell | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: Security: Privileges | Severity: | S3 (Non-critical) |
Version: | 5.6, 5.7, 8.0 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[11 Aug 2018 13:02]
Paul Campbell
[13 Aug 2018 12:14]
MySQL Verification Team
Hi, I do not see what is the version and release that you are using. Please try 8.0.12 and let us know whether it is any different. Also, our documentation clearly states what are the sizes of the columns and also states that special characters should not be used.
[13 Aug 2018 12:14]
MySQL Verification Team
Hi, I do not see what is the version and release that you are using. Please try 8.0.12 and let us know whether it is any different. Also, our documentation clearly states what are the sizes of the columns and also states that special characters should not be used.
[13 Aug 2018 19:12]
Paul Campbell
Hope the following helps to explain the issue. The inconsistency described, i.e. different column sizes for the user@host across different tables and inconsistent application of quoting exists in all of the following versions to which I have access. Sorry, don't have 8.0.12 8.0.11 MySQL Community Server - GPL 5.7.23-0ubuntu0.18.04.1-log (Ubuntu) 5.6.38 MySQL Community Server (GPL) 5.5.58 MySQL Community Server (GPL) Column sizes are documented for the mysql schema, I don't know the documentation on columns sizes for privilege tables in information_schema is, nonetheless one derives from the other yet you make different provision for user and host (in mysql.tables_priv), and user@host (in information_schema.table_privileges) mysql> describe mysql.tables_priv; +-------------+-----------------------------------------------------------------------------------------------------------------------------------+------+-----+-------------------+-----------------------------+ | Field | Type | Null | Key | Default | Extra | +-------------+-----------------------------------------------------------------------------------------------------------------------------------+------+-----+-------------------+-----------------------------+ | Host | char(60) | NO | PRI | | | | Db | char(64) | NO | PRI | | | | User | char(32) | NO | PRI | | | | Table_name | char(64) | NO | PRI | | | | Grantor | char(93) | NO | MUL | | | | Timestamp | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP | | Table_priv | set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger') | NO | | | | | Column_priv | set('Select','Insert','Update','References') | NO | | | | +-------------+-----------------------------------------------------------------------------------------------------------------------------------+------+-----+-------------------+-----------------------------+ 8 rows in set (0.29 sec) mysql> describe information_schema.table_privileges; +----------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------------+--------------+------+-----+---------+-------+ | GRANTEE | varchar(81) | NO | | | | | TABLE_CATALOG | varchar(512) | NO | | | | | TABLE_SCHEMA | varchar(64) | NO | | | | | TABLE_NAME | varchar(64) | NO | | | | | PRIVILEGE_TYPE | varchar(64) | NO | | | | | IS_GRANTABLE | varchar(3) | NO | | | | +----------------+--------------+------+-----+---------+-------+ 6 rows in set (0.04 sec) So, mysql.tables_priv allows host (60) and user (32), when these columns are concatenated as grantee in information_schema.table_privileges only 81 characters total is shown and 5 of these are used for quotes and @. You can only display 76 of the 92 possible characters for the user and host combination. As regards quoting, the documentation says the following ... https://dev.mysql.com/doc/refman/8.0/en/account-names.html <snip> The user name and host name need not be quoted if they are legal as unquoted identifiers. Quotes are necessary to specify a user_name string containing special characters (such as space or -), or a host_name string containing special characters or wildcard characters (such as . or %); for example, 'test-user'@'%.com'. Quote user names and host names as identifiers or as strings, using either backticks (`), single quotation marks ('), or double quotation marks ("). For string-quoting and identifier-quoting guidelines, see Section 9.1.1, “String Literals”, and Section 9.2, “Schema Object Names”. The user name and host name parts, if quoted, must be quoted separately. That is, write 'me'@'localhost', not 'me@localhost'; the latter is actually equivalent to 'me@localhost'@'%'. </snip> So, use of 'special' characters is specifically mentioned, particularly in the context of wildcard host names where, rather than discouraged, they are essential. You quote table_privileges.grantee in information_schema but don't quote tables_priv.grantor in mysql, I think you should use quotes consistently for user@host style columns.
[13 Aug 2018 19:13]
Paul Campbell
Hope the following helps to explain the issue. The inconsistency described, i.e. different column sizes for the user@host across different tables and inconsistent application of quoting exists in all of the following versions to which I have access. Sorry, don't have 8.0.12 8.0.11 MySQL Community Server - GPL 5.7.23-0ubuntu0.18.04.1-log (Ubuntu) 5.6.38 MySQL Community Server (GPL) 5.5.58 MySQL Community Server (GPL) Column sizes are documented for the mysql schema, I don't know the documentation on columns sizes for privilege tables in information_schema is, nonetheless one derives from the other yet you make different provision for user and host (in mysql.tables_priv), and user@host (in information_schema.table_privileges) mysql> describe mysql.tables_priv; +-------------+-----------------------------------------------------------------------------------------------------------------------------------+------+-----+-------------------+-----------------------------+ | Field | Type | Null | Key | Default | Extra | +-------------+-----------------------------------------------------------------------------------------------------------------------------------+------+-----+-------------------+-----------------------------+ | Host | char(60) | NO | PRI | | | | Db | char(64) | NO | PRI | | | | User | char(32) | NO | PRI | | | | Table_name | char(64) | NO | PRI | | | | Grantor | char(93) | NO | MUL | | | | Timestamp | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP | | Table_priv | set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger') | NO | | | | | Column_priv | set('Select','Insert','Update','References') | NO | | | | +-------------+-----------------------------------------------------------------------------------------------------------------------------------+------+-----+-------------------+-----------------------------+ 8 rows in set (0.29 sec) mysql> describe information_schema.table_privileges; +----------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------------+--------------+------+-----+---------+-------+ | GRANTEE | varchar(81) | NO | | | | | TABLE_CATALOG | varchar(512) | NO | | | | | TABLE_SCHEMA | varchar(64) | NO | | | | | TABLE_NAME | varchar(64) | NO | | | | | PRIVILEGE_TYPE | varchar(64) | NO | | | | | IS_GRANTABLE | varchar(3) | NO | | | | +----------------+--------------+------+-----+---------+-------+ 6 rows in set (0.04 sec) So, mysql.tables_priv allows host (60) and user (32), when these columns are concatenated as grantee in information_schema.table_privileges only 81 characters total is shown and 5 of these are used for quotes and @. You can only display 76 of the 92 possible characters for the user and host combination. As regards quoting, the documentation says the following ... https://dev.mysql.com/doc/refman/8.0/en/account-names.html <snip> The user name and host name need not be quoted if they are legal as unquoted identifiers. Quotes are necessary to specify a user_name string containing special characters (such as space or -), or a host_name string containing special characters or wildcard characters (such as . or %); for example, 'test-user'@'%.com'. Quote user names and host names as identifiers or as strings, using either backticks (`), single quotation marks ('), or double quotation marks ("). For string-quoting and identifier-quoting guidelines, see Section 9.1.1, “String Literals”, and Section 9.2, “Schema Object Names”. The user name and host name parts, if quoted, must be quoted separately. That is, write 'me'@'localhost', not 'me@localhost'; the latter is actually equivalent to 'me@localhost'@'%'. </snip> So, use of 'special' characters is specifically mentioned, particularly in the context of wildcard host names where, rather than discouraged, they are essential. You quote table_privileges.grantee in information_schema but don't quote tables_priv.grantor in mysql, I think you should use quotes consistently for user@host style columns.
[14 Aug 2018 12:14]
MySQL Verification Team
Hi, This seems to be a bug. However, this is not a bug of high priority. Not only that, but I doubt that any GA version will get the changes necessary, as the amount of changes is more suitable for some newer version. Verified as reported.
[14 Aug 2018 12:15]
MySQL Verification Team
Added missing versions.
[22 Aug 2018 11:02]
Paul Campbell
A little more info on this Querying the information_schema privilege tables where a user record exists with `grantee` exceeding the allowed 81 characters results in this error ERROR 1406 (22001): Data too long for column 'GRANTEE' at row 1
[9 May 2023 18:59]
Pratiksha Ratnaparkhi
Hi, If I want to show PRIVILEGE_TYPE just for a particular GRANTEE then I am not able to select it in WHERE clause. like ex., select * from information_schema.user_privileges where 'GRANTEE'='azureuser'; select * from information_schema.user_privileges where 'GRANTEE'='azureuser@%'; both didn't work. Can you please point me towards the solution?
[10 May 2023 11:56]
MySQL Verification Team
Hi, This is not a forum for free support, but only a forum for bug reports with repeatable test cases. A small hint though. The name of the account to which the privilege is granted, in 'user_name'@'host_name' format.