Bug #30079 A check for "hidden" I_S tables is flawed

Submitted: 26 Jul 2007 16:26 Modified: 1 Nov 2007 2:59
Reporter: Sergei Golubchik Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Information schema Severity:S3 (Non-critical)
Version: OS:Any
Assigned to: Sergei Glukhov CPU Architecture:Any

[26 Jul 2007 16:26] Sergei Golubchik
Description:
Certain I_S tables are "hidden" - they cannot be selected from, and only accessible as some SHOW command.

The check is implemented as

    if (!schema_table ||
        (schema_table->hidden && 
         (sql_command_flags[lex->sql_command] & CF_STATUS_COMMAND) == 0))
    {
      my_error(ER_UNKNOWN_TABLE, MYF(0),
               ptr->table_name, INFORMATION_SCHEMA_NAME.str);
      DBUG_RETURN(0);
    }

in st_select_lex::add_table_to_list(). That is, if the table is "hidden" and the sql command is not a SHOW command - MySQL pretends the table doesn't exist.

This can be easily circumvented.

How to repeat:
mysql> select * from information_schema.TABLE_NAMES;
ERROR 1109 (42S02): Unknown table 'TABLE_NAMES' in information_schema

mysql> show fields from information_schema.TABLE_NAMES;
+---------------+--------------+------+-----+---------+-------+
| Field         | Type         | Null | Key | Default | Extra |
+---------------+--------------+------+-----+---------+-------+
| TABLE_CATALOG | varchar(512) | YES  |     | NULL    |       | 
| TABLE_SCHEMA  | varchar(64)  | NO   |     | NULL    |       | 
| TABLE_NAME    | varchar(64)  | NO   |     | NULL    |       | 
| TABLE_TYPE    | varchar(64)  | NO   |     | NULL    |       | 
+---------------+--------------+------+-----+---------+-------+
4 rows in set (0.01 sec)
[14 Aug 2007 10:01] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/32499

ChangeSet@1.2513, 2007-08-14 14:58:25+05:00, gluh@mysql.com +3 -0
  Bug#30079 A check for "hidden" I_S tables is flawed
  added check for hidden I_S tables for 'show columns|keys' commands
[4 Oct 2007 11:25] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/34892

ChangeSet@1.2551, 2007-10-04 16:20:56+05:00, gluh@mysql.com +3 -0
  Bug#30079 A check for "hidden" I_S tables is flawed
  added check for hidden I_S tables for 'show columns|keys' commands
[29 Oct 2007 8:42] Bugs System
Pushed into 5.0.52
[29 Oct 2007 8:45] Bugs System
Pushed into 5.1.23-beta
[29 Oct 2007 8:49] Bugs System
Pushed into 6.0.4-alpha
[1 Nov 2007 2:59] Paul DuBois
Noted in 5.0.52, 5.1.23, 6.0.4 changelogs.

Some INFORMATION_SCHEMA tables are intended for internal use, but
could be accessed by using SHOW statements.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.058 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.