You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: controlled user can disable enable_remap_hint and bypass row rule #29142
A user protected by a role row/column rule can execute SET enable_remap_hint = 0. The role rule then is not applied and the user receives rows previously filtered by the rule. This allows the protected user to bypass the feature without changing role membership or object privileges.
Reproduction
CREATEDATABASErcac_switch;
CREATETABLErcac_switch.sales (id INTPRIMARY KEY, tenant INT, amount INT);
INSERT INTOrcac_switch.salesVALUES (1,1,100),(2,2,200);
CREATE ROLE rcac_switch_r;
ALTER ROLE rcac_switch_r
ADD RULE 'select id, amount from rcac_switch.sales where tenant = 1'ON TABLE rcac_switch.sales;
CREATEUSERrcac_switch_u IDENTIFIED BY '...' DEFAULT ROLE rcac_switch_r;
GRANT CONNECT ON ACCOUNT * TO rcac_switch_r;
GRANTSELECTON TABLE rcac_switch.sales TO rcac_switch_r;
As rcac_switch_u (the default value is enable_remap_hint=off):
Once a role rule applies to a user/table, an ordinary user must not be able to disable the role-rule rewrite path or broaden visible rows with a session setting. The setting should be privileged, ignored for mandatory role rules, or the query should fail closed.
Stability and cleanup
Reproduced once in a clean isolated service. Temporary user, role, database, table, and rule will be removed after evidence capture.
Regression and extended verification for #29142 (2026-09-24)
Verification Environment
Validated source: GitHub origin/main head 95b1d2bfd9d756d08320569858080cb16f230fff — fix(external): keep parquet scalar siblings vectorized (#29285). The local Git remote ref was stale, so the runtime was built from GitHub's exact source archive for that commit.
Runtime image: locally built matrixorigin/matrixone:issue-29161-main (sha256:e2c4991f7620728f4526d9417833dbf0cfcd9f4e0c67da602aff51fb21f3a5b2).
Topology: 1 Log service / 1 TN / 2 CN / Proxy; all services were running.
Endpoint checks: Proxy 6001, CN1 16001, and CN2 16002 each accepted real SQL connections. The protocol regression executed through all three endpoints.
Client protocol: Go database/sql with go-sql-driver/mysql and interpolateParams=false. PrepareContext exercised real COM_STMT_PREPARE / COM_STMT_EXECUTE handles; the text-query path was also exercised.
Related fix: PR #29236, merged as 2ad62b2b71ba1155bfdc6f26b94686f0820af59f; product commits include fb914315555dab3d9dc4fce4bab25beefe5af0da — fix(frontend): prevent role rule bypass via remap hint and 178173c743c673cdf29c6e1e2a3cd8d18e4dd3f6 — fix(frontend): preserve role rules in native prepare.
What Was Covered
OK Original text-query scenario: with enable_remap_hint = 1, the controlled user received only the permitted tenant = 1 row.
OK Unhappy-path bypass attempt: after SET enable_remap_hint = 0, the same controlled user still received only the permitted row; the tenant = 2 row was not exposed.
OK Session-transition boundary: 1 → 0 → 1 → 0 in the same controlled-user session preserved the role-rule result at every step.
OK Native prepared protocol: with interpolateParams=false, prepared SELECT statements under both enable_remap_hint = 0 and 1 returned only the permitted row across two executions of each prepared handle.
OK Endpoint coverage: the original scenario and prepared-statement extension passed serially through Proxy 6001, CN1 16001, and CN2 16002.
OK Existing BVT: test/distributed/cases/zz_accesscontrol/role_rule.sql passed twice through Proxy 6001, each run completing 200/200 statements successfully.
OK BVT compatibility coverage includes role-rule management, multi-role behavior, inherited roles, projections, error paths, and the enabled-to-disabled switch transition.
Not covered The PR's nested PREPARE ... FROM and schema-change/rebuild integration variants were not independently replayed in this multi-CN environment.
Findings
No role-rule bypass was observed. enable_remap_hint now gates optional session and inline remap layers only; it no longer disables mandatory role-rule rewriting.
The endpoint cases ran serially because they create account-level users, roles, and databases and temporarily change @@global.enable_privilege_cache on one shared cluster. Each endpoint used isolated names, all temporary objects were removed, and the global setting was restored to 1 after BVT replay.
Large-data regression is not required: this is a session-policy and authorization-rewrite invariant, not a row-count, block/batch, memory, spill, concurrency, data-skew, network-transfer, or resource-scale issue.
MOTR / BVT Coverage
No new MOTR case was added. The associated product fix already added the focused transition to test/distributed/cases/zz_accesscontrol/role_rule.sql and native prepared coverage in pkg/tests/sqlintegration/role_rule_prepared_test.go. The BVT was replayed twice successfully.
Final Conclusion
Fixed. An ordinary controlled user cannot disable enable_remap_hint to broaden rows protected by a role rule; the behavior is verified through Proxy, CN1, CN2, text SQL, and native prepared-statement protocol execution.
Activity
fix(frontend): prevent role rule bypass when remap hint is disabled (#…
slyunnn commentedon Sep 24, 2026
Regression and extended verification for #29142 (2026-09-24)
Verification Environment
origin/mainhead95b1d2bfd9d756d08320569858080cb16f230fff—fix(external): keep parquet scalar siblings vectorized (#29285). The local Git remote ref was stale, so the runtime was built from GitHub's exact source archive for that commit.matrixorigin/matrixone:issue-29161-main(sha256:e2c4991f7620728f4526d9417833dbf0cfcd9f4e0c67da602aff51fb21f3a5b2).1 Log service / 1 TN / 2 CN / Proxy; all services were running.6001, CN116001, and CN216002each accepted real SQL connections. The protocol regression executed through all three endpoints.database/sqlwithgo-sql-driver/mysqlandinterpolateParams=false.PrepareContextexercised realCOM_STMT_PREPARE/COM_STMT_EXECUTEhandles; the text-query path was also exercised.2ad62b2b71ba1155bfdc6f26b94686f0820af59f; product commits includefb914315555dab3d9dc4fce4bab25beefe5af0da—fix(frontend): prevent role rule bypass via remap hintand178173c743c673cdf29c6e1e2a3cd8d18e4dd3f6—fix(frontend): preserve role rules in native prepare.What Was Covered
enable_remap_hint = 1, the controlled user received only the permittedtenant = 1row.SET enable_remap_hint = 0, the same controlled user still received only the permitted row; thetenant = 2row was not exposed.1 → 0 → 1 → 0in the same controlled-user session preserved the role-rule result at every step.interpolateParams=false, preparedSELECTstatements under bothenable_remap_hint = 0and1returned only the permitted row across two executions of each prepared handle.6001, CN116001, and CN216002.test/distributed/cases/zz_accesscontrol/role_rule.sqlpassed twice through Proxy6001, each run completing200/200statements successfully.PREPARE ... FROMand schema-change/rebuild integration variants were not independently replayed in this multi-CN environment.Findings
No role-rule bypass was observed.
enable_remap_hintnow gates optional session and inline remap layers only; it no longer disables mandatory role-rule rewriting.The endpoint cases ran serially because they create account-level users, roles, and databases and temporarily change
@@global.enable_privilege_cacheon one shared cluster. Each endpoint used isolated names, all temporary objects were removed, and the global setting was restored to1after BVT replay.Large-data regression is not required: this is a session-policy and authorization-rewrite invariant, not a row-count, block/batch, memory, spill, concurrency, data-skew, network-transfer, or resource-scale issue.
MOTR / BVT Coverage
No new MOTR case was added. The associated product fix already added the focused transition to
test/distributed/cases/zz_accesscontrol/role_rule.sqland native prepared coverage inpkg/tests/sqlintegration/role_rule_prepared_test.go. The BVT was replayed twice successfully.Final Conclusion
Fixed. An ordinary controlled user cannot disableenable_remap_hintto broaden rows protected by a role rule; the behavior is verified through Proxy, CN1, CN2, text SQL, and native prepared-statement protocol execution.