首批通过分布式安全可靠测评,为关键业务系统打造
MySQL 模式下授予用户 all privileges 权限仍提示无权限查看表
更新时间:2023-12-07 03:16
问题现象
业务租户的用户进行了授权 all privileges,但是授权后,业务用户无法执行查询表的语句,仍然报错权限不足,后面针对单表进行授权后,可以执行查询。
复现步骤如下:
使用 root 用户登录数据库的 sys 租户。
执行如下语句创建名为
tkipts的库,在库中创建表mtest并插入一条数据。obclient> create database tkipts; Query OK, 1 row affected (0.07 sec) obclient> use tkipts Database changed obclient> create table mtest(id int); Query OK, 0 rows affected (0.10 sec) obclient> insert into mtest values(1); Query OK, 1 row affected (0.04 sec)创建
admin_test用户。obclient> create user admin_test identified by '123456'; Query OK, 0 rows affected (0.07 sec)授予
admin_test用户相应的权限。obclient> GRANT ALTER, CREATE, CREATE VIEW, DELETE, DROP, GRANT OPTION, INDEX, INSERT, SELECT, SHOW VIEW, UPDATE ON tkipts.* TO admin_test; Query OK, 0 rows affected (0.06 sec) obclient> GRANT SHOW DATABASES, PROCESS ON *.* TO admin_test; Query OK, 0 rows affected (0.06 sec)查看
admin_test拥有的权限,发现授权成功。obclient> show grants for admin_test; +----------------------------------------------------------------------+ | Grants for admin_test@% | +----------------------------------------------------------------------+ | GRANT SHOW DB, PROCESS ON *.* TO 'admin_test' | | GRANT ALL PRIVILEGES ON `tkipts`.* TO 'admin_test' WITH GRANT OPTION | +----------------------------------------------------------------------+使用
admin_test用户登录数据库。obclient -h11.xxx -P2881 -uadmin_test@sys -Dtkipts -A -pxxx Welcome to the OceanBase. Commands end with ; or \g. Your OceanBase connection id is 3221508215 Server version: OceanBase 3.2.3.3 (r108000062023041511-33aee97541a93ccde986373e55fd0ba188615f29) (Built Apr 15 2023 11:55:17) Copyright (c) 2000, 2018, OceanBase and/or its affiliates. All rights reserved. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. obclient [(none)]>执行查询语句发现如下报错。
obclient> show tables; Empty set (0.04 sec) obclient> select * from mtest; ERROR 1142 (42000): SELECT command denied to user 'admin_test'@'%' for table 'mtest' obclient>
问题原因
同时授予用户 show databases 权限和库级别权限会导致出现该问题。
影响版本
OceanBase 数据库 V3.x 版本。
解决方法及规避方式
- 规避方法:不同时授予
show databases权限和库级别权限。 - 应急方法:revoke show databases 权限。