search

Home  >  Q&A  >  body text

Is it possible to grant metadata permissions exclusively in MySQL?

TLDR;

Target:

Is it possible to grant an "audit" user access to only the MySQL metadata (at least the schema, tables, columns) and not the exact data in the table?

Version

MySQL 8

try:

Before this question,

I have tried or know:

background:

My company orders devops to collect MySQL metadata for auditing or security monitoring or other issues (I don't know the details of the whole story). My leadership anticipates that unnecessary data breaches will not occur. BTW, I don't know the specific method by which they (maybe the audit department) will collect the metadata. All I have to do is create an authorized user for them.

P粉715274052P粉715274052242 days ago399

reply all(1)I'll reply

  • P粉739706089

    P粉7397060892024-03-22 18:38:15

    I think I found a solution to this problem, but it's just a hack and not a real solution.

    https://dev.mysql.com/doc /refman/8.0/en/show-tables.html said:

    That is, you cannot use SHOW TABLES, nor view the table in a query against INFORMATION_SCHEMA (because SHOW TABLES is really only a query against these system views).

    But the language of “no privilege” got me thinking. Are there permissions that a user can have but are not allowed to read or write data?

    https://dev.mysql.com/doc/refman /8.0/en/grant.html said:

    SHOW VIEW How about it? This only allows viewing metadata, not querying tables or views.

    So I tried it:

    mysql> create user 'auditor'@'%';
    mysql> grant show view on test.* to 'auditor'@'%';

    Then I logged in as that user and tried:

    mysql> show grants;
    +----------------------------------------------+
    | Grants for auditor@%                         |
    +----------------------------------------------+
    | GRANT USAGE ON *.* TO `auditor`@`%`          |
    | GRANT SHOW VIEW ON `test`.* TO `auditor`@`%` |
    +----------------------------------------------+
    
    mysql> use test
    
    mysql> show tables;
    +----------------+
    | Tables_in_test |
    +----------------+
    | Accounts       |
    | Bugs           |
    | BugsProducts   |
    | BugStatus      |
    ...

    I can also view columns etc.

    To be clear, these are specific tables, not views. But since my auditor user doesn't have any permissions on the table (not even irrelevant permissions), it serves the purpose of letting them see metadata about the table.

    In MySQL 8.0.20, they added the SHOW ROUTINES permission. Prior to this, you required SELECT permission to view the body of a stored procedure or function. But you didn't mention the auditor viewing routine in your question.

    reply
    0
  • Cancelreply