Repository navigation
Description
Description
After an administrator revokes the currently active role from a user, the existing user session continues to use that role for subsequent statements. Clearing the session privilege cache does not remove the revoked active role. Both fresh text SQL and an existing binary prepared statement remain authorized.
Environment
- Branch:
main - Commit:
a53f5a3b757c5b21a36e539e4471533fe1d091a8 - Deployment: local
mo-service, 1 Log / 1 TN / 1 CN - Client: MySQL Connector/J 8.4.0, server-side prepared statements enabled
enable_privilege_cache:on; the user session explicitly runsSET SESSION clear_privilege_cache=ONafter revoke- Test date: 2026-08-26 (Asia/Shanghai)
Steps to reproduce
- Create role
reader, useruwith default rolereader, and a table containing one row. - Grant table
SELECTtoreader, then grantreadertou. - Connect as
uwithreaderactive and prepare a parameterizedSELECT. - Confirm both text SQL and the prepared statement can read the row.
- From an administrator session, run
REVOKE reader FROM u. - In the existing user session, run
SET SESSION clear_privilege_cache=ON. - Execute the equivalent fresh text query and the existing binary prepared statement.
- Run
SET ROLE public, then trySET ROLE readeragain as a control.
Actual behavior
- The fresh text query still succeeds after role revoke and cache clear.
- The existing binary prepared statement also still succeeds.
- After switching to
public,SET ROLE readeris rejected because the role is no longer granted. This confirms the catalog revoke succeeded while the already active session retained stale authorization.
Observed in 3/3 fresh rounds:
round=1 text=allowed prepared=allowed switch-back=denied
round=2 text=allowed prepared=allowed switch-back=denied
round=3 text=allowed prepared=allowed switch-back=denied
Expected behavior
Revoking an active role should adjust the privileges of current sessions for the next statement. Fresh text and prepared execution should both be rejected after the revoke.
Controls
- Direct
REVOKE SELECT ... FROM readerplus session privilege-cache clear correctly denies both text/prepared access on this commit, confirming the [Bug]: prepared statements bypass revoked table SELECT privilege after cache clear #26891 fix remains effective. - A fresh connection explicitly requesting the revoked role is rejected in 3/3 rounds.
- MySQL 8.0.46 control: the existing session loses the role privilege on the first statement after revoke.
- No data mutation is involved. Cleanup succeeded after every round.
Code analysis
doRevokeRole removes the mo_user_grant row, but the existing session keeps its role ID/name in TenantInfo. Privilege cache invalidation only clears cached privilege results; it does not revalidate whether the active role is still granted to the user.
Regression recommendation
Add a multi-session access-control regression covering text SQL and binary prepared execution after role membership revoke, cache clear, switch-away/switch-back, and re-grant recovery.
Activity
fix(frontend): invalidate revoked active roles in existing sessions (#…
Ariznawlll commentedon Sep 5, 2026
测试版本
mainfa829e5c505520e4bd429d283c78157781b4de72原问题验证
3 轮隔离租户复测:已建立连接的用户在角色被撤销后,文本 PREPARE/EXECUTE 不能继续读取原授权对象。
Happy Path 覆盖
Unhappy Path 覆盖
SET ROLE reader和显式 reader 登录均被拒绝。白盒验证
不适用:以 MySQL 协议黑盒验证权限缓存失效。
回归测试
已加入 MOTR:
suites/14_issue_regression/t/issue_27650_27651_revoked_roles.test与 binary 协议补充issue_27650_binary_role_revoke.test。PR:https://github.com/matrixorigin/motr/pull/145 。该仓库当前没有可触发的 PR 回归 workflow,状态检查为空。测试证据
隔离账号在每轮均删除;文本与 binary prepared 变体各 3/3 通过。
测试结论
测试通过。
fix(frontend): invalidate revoked active roles in existing sessions (m…
fix(frontend): invalidate revoked active roles in existing sessions (m…
fix(frontend): invalidate revoked active roles in existing sessions (m…