ACL cache collision lets a role inherit privileges from a same-named socket user
MariaDB's privilege cache key does not distinguish a role lookup from a UNIX-socket user with the same name. A socket connection can warm the cache with the user account's database privileges, and a different account that activates the same-named role then receives those cached user privileges even though they were never granted to the role.
- Disclosed after 44 days
Summary
MariaDB's database privilege cache key does not distinguish a role lookup from a UNIX-socket user with the same name. A socket connection can warm the cache with the user account's database privileges. A different account that activates the same-named role then receives the cached user privileges even though those privileges were never granted to the role
Preconditions
- A role and a UNIX-socket-accessible user have the same name.
- The user has database privileges that the role does not.
- Another account has permission to activate the role.
- The socket user warms the relevant database privilege-cache entry first.
Reproduction
As an administrator:
CREATE DATABASE vhrole;
CREATE TABLE vhrole.secret(marker VARCHAR(40));
INSERT INTO vhrole.secret VALUES ('role-cache-collision-row');
CREATE ROLE vhcollision;
CREATE USER 'vhcollision'@'localhost'
IDENTIFIED BY 'collision-user-only';
CREATE USER 'vhholder'@'127.0.0.1'
IDENTIFIED BY 'holder-test-only';
GRANT SELECT ON vhrole.* TO 'vhcollision'@'localhost';
GRANT vhcollision TO 'vhholder'@'127.0.0.1';
FLUSH PRIVILEGES;
Warm the cache using the same-named user over the UNIX socket:
SELECT marker FROM vhrole.secret;
Connect as [email protected]:
SET ROLE vhcollision;
SELECT CURRENT_ROLE;
SELECT marker FROM vhrole.secret;
Observed result
vhcollision
role-cache-collision-row
The role holder read the row even though SELECT was granted only to
'vhcollision'@'localhost', not to role vhcollision.
Expected result
The final SELECT should return an access-denied error because the active role has no
privilege on vhrole.
Root cause
acl_get() constructs a cache key from (ip, user, db) but caches a result derived
from (host, ip, user, db). A UNIX-socket user has an empty IP, while role lookups use
synthetic empty host and IP values. Same-named principals therefore generate the same
key despite requiring different ACL resolution.
Impact
A low-privilege role holder can inherit database-level privileges assigned to a different principal. Depending on the colliding account's grants, this can disclose or modify data outside the role holder's authorization.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the privilege cache key is built from (ip, user, db) but the cached result depends on (host, ip, user, db), so a UNIX-socket user with an empty IP and a role lookup with synthetic empty host and IP collide.
Impact
A low-privilege role holder can inherit database-level privileges assigned to a different principal, which could disclose or modify data outside the role holder's authorization.
What the attacker needed
Role and socket user share a name; socket user has extra database privileges; another account can activate the role; socket user warms the cache first
How it was found
- As administrator, create a database, a role, a socket user with the same name as the role, and another user who can activate the role.
- Grant SELECT on the database to the socket user and grant the role to the other user.
- Connect as the socket user over the UNIX socket and run a SELECT to warm the privilege cache.
- Connect as the other user and activate the role.
- Run the same SELECT and observe that it succeeds even though the role has no privilege.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
In MariaDB, roles and users are different things, but they can share a name. The database keeps a cache of who is allowed to do what, and the cache key for a role and for a socket user with the same name is identical. So if the user first loads their permissions into the cache, someone else who activates the role gets those permissions by mistake.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.