Bug #85562 | dropping a role does not remove privileges from active users | ||
---|---|---|---|
Submitted: | 21 Mar 2017 9:48 | Modified: | 22 Dec 2017 8:42 |
Reporter: | Giuseppe Maxia (OCA) | Email Updates: | |
Status: | Can't repeat | Impact on me: | |
Category: | MySQL Server: Security: Roles | Severity: | S2 (Serious) |
Version: | 8.0 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[21 Mar 2017 9:48]
Giuseppe Maxia
[21 Mar 2017 10:12]
MySQL Verification Team
Hello Giuseppe, Thank you for the report and feedback! Verified as described. Thanks, Umesh
[2 Jun 2017 6:11]
Giuseppe Maxia
Changed category to "Roles"
[5 Dec 2017 12:29]
Kristofer Pettersson
Posted by developer: A session checks out a a privilege map which contain all current privileges. This happens naturally before query execution. If the underlying roles are dropped in another session the session will update its privileges on the next available moment but not sooner. This means that when testing the first statement will succeed because it's executing under privileges already granted. The reason privileges aren't updated at once is because we prioritize performance over absolute consistency here. The following test case pass as expected: CREATE DATABASE db1; USE db1; CREATE ROLE r_ro; CREATE ROLE r_rw; GRANT SELECT ON db1.* TO r_ro; GRANT INSERT, UPDATE, DELETE ON db1.* TO r_rw; CREATE USER u_ro IDENTIFIED BY 'optimism' DEFAULT ROLE r_ro; CREATE USER u_rw IDENTIFIED BY 'positive_thinking' DEFAULT ROLE r_ro,r_rw; GRANT r_ro TO u_ro; GRANT r_ro, r_rw TO u_rw; CREATE TABLE t1(id int); connect(con1, localhost, u_rw, positive_thinking, db1); SHOW GRANTS; --echo # u_rw has INSERT grants. The following statement will succeed: INSERT INTO db1.t1 VALUES (1); connection default; --echo # Root now drops the role which grants INSERT statements. DROP ROLE r_rw; connection con1; --echo # The existing connection for u_rw should have updated. USE db1; --echo # SHOW GRANTS will fail with an error because the active roles --echo # are now invalid --error ER_ROLE_NOT_GRANTED SHOW GRANTS; --echo # Ignoring active roles will not fail: SHOW GRANTS FOR u_rw USING r_ro; --echo # The session checked out a new authorization map and --echo # inserts are not possible despite previous active roles. --error ER_TABLEACCESS_DENIED_ERROR INSERT INTO db1.t1 VALUES (1); connect(con2, localhost, u_rw, positive_thinking, db1); --echo # A new connection is established for user 'u_rw' and it should --echo # not demonstrate any INSERT grants nor any grants for r_rw. SHOW GRANTS; SHOW GRANTS FOR u_rw; --echo # Any INSERT statement should fail too: --error ER_TABLEACCESS_DENIED_ERROR INSERT INTO t1 VALUES (2); --echo # SELECT will still work: SELECT * FROM t1; connection default; disconnect con1; disconnect con2; DROP ROLE r_ro; DROP USER u_rw,u_ro;