Bug #121890 Mixed global REVOKE bypasses partial privilege restriction
Description:
With partial_revokes enabled, a definer has global SELECT and INSERT with GRANT OPTION but is restricted from SELECT on db1.*. A SQL SECURITY DEFINER procedure should therefore be unable to revoke SELECT globally.
However, combining the unauthorized SELECT privilege with the authorized INSERT privilege in one REVOKE succeeds. Both privileges are removed from the target account:
Grants for target@%
GRANT USAGE ON *.* TO `target`@`%`
The compound privilege request must fail when any requested privilege is unauthorized.
How to repeat:
Run as root:
SET GLOBAL partial_revokes = ON;
CREATE DATABASE db1;
CREATE USER 'grantor'@'%';
CREATE USER 'target'@'%';
GRANT SELECT, INSERT ON *.* TO 'target'@'%';
DELIMITER //
CREATE DEFINER='grantor'@'%' PROCEDURE db1.revoke_privs()
SQL SECURITY DEFINER
BEGIN
REVOKE SELECT, INSERT ON *.* FROM 'target'@'%';
SHOW GRANTS FOR 'target'@'%';
END//
DELIMITER ;
GRANT SELECT, INSERT ON *.* TO 'grantor'@'%' WITH GRANT OPTION;
REVOKE SELECT ON db1.* FROM 'grantor'@'%';
GRANT EXECUTE ON PROCEDURE db1.revoke_privs TO 'grantor'@'%';
CALL db1.revoke_privs();
Observed: the CALL succeeds and reports:
Grants for target@%
GRANT USAGE ON *.* TO `target`@`%`
Expected: the CALL fails because the definer's SELECT privilege is restricted on db1.*.
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.049 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.