Repository navigation
Description
Description
An ordinary view can bypass a base-table row rewrite rule. With the required rewrite setting enabled, the affected user sees only authorized rows when querying the base table directly, but sees an unauthorized row when querying a normal view that expands the same table.
Environment
- MatrixOne:
main@480b91764a94cf9ab49d3f2b43a60cb63ce677c6 - Deployment: macOS arm64, single-node local isolated MatrixOne service
- Required session setting:
enable_remap_hint = 1
Steps to reproduce
CREATE DATABASE rcac_view;
CREATE TABLE rcac_view.sales(id INT PRIMARY KEY, tenant INT, amount INT);
INSERT INTO rcac_view.sales VALUES (1,1,10), (2,1,20), (3,2,30);
CREATE VIEW rcac_view.v_sales AS
SELECT id, tenant, amount FROM rcac_view.sales;
CREATE ROLE rcac_view_r;
ALTER ROLE rcac_view_r ADD RULE
"select * from rcac_view.sales where tenant = 1"
ON TABLE rcac_view.sales;
CREATE USER rcac_view_u IDENTIFIED BY '<test-password>' DEFAULT ROLE rcac_view_r;
GRANT CONNECT ON ACCOUNT * TO rcac_view_r;
GRANT SELECT ON TABLE rcac_view.sales TO rcac_view_r;
GRANT SELECT ON VIEW rcac_view.v_sales TO rcac_view_r;Log in as rcac_view_u and execute:
SET enable_remap_hint = 1;
SELECT id FROM rcac_view.sales ORDER BY id;
SELECT id FROM rcac_view.v_sales ORDER BY id;Actual behavior
direct base-table query: 1, 2
ordinary-view query: 1, 2, 3
The direct query proves the row rule is active for this session. The view query exposes row id=3, whose tenant=2 does not satisfy the rule.
Expected behavior
Both queries must return only 1, 2. The view execution path must preserve the base-table row rule (or reject access when its security model requires that); it must never expose rows hidden by the rule.
Stability / impact
- Reproduced directly on current
mainin an isolated service. - A user with ordinary view access can read rows hidden by the base table's row access-control rule.
- This is a data-access-control bypass, not an EXPLAIN-only observability issue.
Evidence and initial scope
- The direct base-table control and view query ran in the same authenticated session with the same active default role and
enable_remap_hint = 1setting. - Evidence scopes the fault to the view expansion/execution path not applying the base-table rewrite rule; root cause is not yet confirmed.
- This issue is independent of [Bug]: secondary role rewrite rules collapse duplicate projected values from distinct visible rows #29081, which concerns secondary-role rewrite-rule combination.
Regression coverage
After remediation, add an end-to-end regression that creates a controlled base table and ordinary view, then verifies that direct and view queries produce the same authorized row set. Cover nested views and supported definer/invoker semantics separately if applicable.
Activity
fix(plan): preserve row rewrite rules through views (#29695)
slyunnn commentedon Oct 10, 2026
Regression and extended verification for #29093 (2026-10-10)
Verification Environment
0ccc989731f9c2b40d31554a44ca505c656c0e62—feat(sql): add durable cluster-scoped UUID_SHORT() (#29805)— with Go1.27.1on Linux/ARM64. The newly started runtime reports this commit.f2134a94b5a79c6a71def4475dfc913cb3300904d13bcf0fecf56b0d3c270c23.2 CN / 1 TN / 1 Log service / Proxy, local-disk storage.127.0.0.1:6661→ container6009, CN1127.0.0.1:16661→16001, CN2127.0.0.1:16662→16002. Alternate host ports avoid existing services; the pre-existing6001/16001/16002deployment was not tested.COM_QUERY. Access-control assertions ran as a dedicated restricted user, not as the setup administrator.What Was Covered
enable_remap_hint=1, both the direct table and ordinary View return only IDs1,2; unauthorized ID3is absent, on all endpoints.1with sum30; View/table join returns count2and sum30.3or tenant2return count0.enable_remap_hint=0, direct, ordinary and nested View queries still enforce mandatory role rules on this main revision.SQL SECURITY DEFINERandSQL SECURITY INVOKERView declaration forms both preserve the restricted row set in this fixture. This does not assert full MySQL definer/invoker context equivalence.SELECTgrant is rejected with error20101; the same connection remains usable afterward.6replays,45statements per replay, no failures or skips.issue_25186_insert_select_remap_hintcase passed:2/2cases,66/66statements,-j 2.Findings
The reported ordinary-View row-rule bypass is no longer reproducible on the tested main.
Related merged fix: #29695 — fix(plan): preserve row rewrite rules through views, commit
a23874569c5669febbe641f8b1c230afad3426e0, contained in the tested main. It propagates the outer row-rewrite option into the independent View binding context and preserves the qualifier required by stored View projections.MOTR / BVT Coverage
zz_accesscontrol/role_rule.sqlcontains ordinary-View coverage. Added MOTR coverage for nested/star/aggregate Views, forbidden-row predicates, joins, accepted security declaration forms, permission rejection and connection health.suites/14_issue_regression/t/issue_29093_view_row_rule.testand the matching.resultfile. The recorded baseline was reviewed against explicit authorized-row expectations before replay.test/issue-29093-view-row-rule.3f75461cc9ee2f42ceab569b39f8cf66dd40a2f0,test: add MOTR regression for #29093.-j 2run were parallel. This is not a claim of engine-parallel execution coverage.Final Conclusion
Fixed for the reported bypass and the tested View expansions on
0ccc989731f9c2b40d31554a44ca505c656c0e62, verified through Proxy and both CNs.Large-data regression is not needed: the defect is policy propagation during View binding. Three controlled rows distinguish authorized from unauthorized visibility; additional volume would not exercise a different boundary for this defect.