Skip to content

[Bug]: controlled user can disable enable_remap_hint and bypass row rule #29142

Closed

Description

@slyunnn

[Bug]: Controlled user can disable enable_remap_hint and bypass row rule

Environment

  • MatrixOne main: 56f7d1eae392b5f3de33e1ea43c916956c50b833
  • macOS arm64, single-node isolated local service

Impact

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

CREATE DATABASE rcac_switch;
CREATE TABLE rcac_switch.sales (id INT PRIMARY KEY, tenant INT, amount INT);
INSERT INTO rcac_switch.sales VALUES (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;
CREATE USER rcac_switch_u IDENTIFIED BY '...' DEFAULT ROLE rcac_switch_r;
GRANT CONNECT ON ACCOUNT * TO rcac_switch_r;
GRANT SELECT ON TABLE rcac_switch.sales TO rcac_switch_r;

As rcac_switch_u (the default value is enable_remap_hint=off):

SET enable_remap_hint = 1;
SELECT id, amount FROM rcac_switch.sales ORDER BY id;
-- 1 | 100

SET enable_remap_hint = 0;
SELECT id, amount FROM rcac_switch.sales ORDER BY id;
-- 1 | 100
-- 2 | 200   -- unauthorized tenant=2 row

Expected behavior

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.

Activity

  1. added
    kind/bug
    on Sep 20, 2026
  2. added theissue type on Sep 20, 2026
  3. added this to the MO-202609 milestone on Sep 20, 2026
  4. added
    ai-easy
    on Sep 24, 2026
  5. slyunnn commented on Sep 24, 2026

    @slyunnn
    Author

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

ai-easykind/bug

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions