Skip to content

fix(frontend): prevent role rule bypass when remap hint is disabled - #29236

Merged
XuPeng-SH merged 4 commits into
matrixorigin:mainfrom
iamlinjunhong:fix/29142-disable-remap-hint-bypass
Sep 23, 2026
Merged

XuPeng-SH merged 4 commits into
matrixorigin:mainfrom
iamlinjunhong:fix/29142-disable-remap-hint-bypass

Conversation

@iamlinjunhong

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #29142

What this PR does / why we need it:

SET enable_remap_hint = 0 could skip role rewrite rules and expose rows outside a user's mandatory row rule. This change always captures and applies role rules, while keeping session and inline remap hints controlled by the switch. Native prepared statements use the same policy, including nested PREPARE ... FROM paths.

Regression coverage includes the role-rule BVT transition from the switch enabled to disabled, policy unit tests, and test fixtures for the now mandatory role-cache lookup.

Validation:

  • ./.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=900s ./pkg/frontend
  • Role-rule BVT: test/distributed/cases/zz_accesscontrol/role_rule.sql passed twice on the same rebuilt service instance (200/200 each run)

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@mergify mergify Bot added the kind/bug Something isn't working label Sep 22, 2026
@matrix-meow matrix-meow added the size/M Denotes a PR that changes [100,499] lines label Sep 22, 2026
@iamlinjunhong
iamlinjunhong force-pushed the fix/29142-disable-remap-hint-bypass branch from ae41d45 to 9ddfcc5 Compare September 22, 2026 11:55

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

REQUEST_CHANGES(GPT-6 high review)

发现 1 个 P1 安全问题:native prepared statement 仍可绕过 mandatory role rule。

在 pkg/frontend/mysql_cmd_executor.go 的 COM_STMT_PREPARE 路径中,新增的无条件 rewriteSQL 虽然生成了角色规则 hint,但后续调用 doComQuery 没有传递对应的 rewrite policy。随后 GetComputationWrapper 会重新读取已关闭的 ses.rewriteEnabled,跳过 AddRewriteHints;普通 MySQL parser 也不会把该注释自动转换为 RewriteOption。因此保存的 prepared AST/plan 可能不带 mandatory role rule,之后 COM_STMT_EXECUTE 可返回被禁止的行。

请补充并修复:

  1. 将同一个 policy snapshot 传入 native prepare 的后续解析/物化流程,并确保 mandatory rule 只附加一次;
  2. 增加真实 COM_STMT_PREPARE/COM_STMT_EXECUTE 协议回归:enable_remap_hint=0 时断言禁止行不会返回;
  3. 覆盖 prepared 重建/开关切换后的路径。

当前 CI 和普通查询回归通过,但没有覆盖上述 native prepared 绕过。

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GPT-6 High deep re-review of exact head 178173c743c673cdf29c6e1e2a3cd8d18e4dd3f6: APPROVE. The prior native COM_STMT_PREPARE/EXECUTE mandatory-role-rule bypass is closed. The captured policy is passed through native prepare, materialization is guarded against duplicate attachment, and the integration regression exercises server-side prepared execution with enable_remap_hint off/on/off, reuse, and schema rebuild. Exact-head UT/SCA/BVT/coverage passed; role_rule.sql passed 200/200 in Compose BVT. No concrete P1/P2 blockers found.

@mergify mergify Bot added the queued label Sep 23, 2026
@mergify

mergify Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-09-23 09:03 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-09-23 09:30 UTC · at e540f82e4cc66095ab6ad7556b9c8ab4f5b6d3ce

This pull request spent 27 minutes 27 seconds in the queue, with no time running CI.

Waiting for any of
  • check-neutral = CI Required
  • check-skipped = CI Required
  • check-success = CI Required
All conditions

Reason

Pull request #29236 has been dequeued

Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.

> The author needs to enable ["Allow edits from maintainers"](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork) on this pull request.

Hint

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

@XuPeng-SH
XuPeng-SH merged commit 2ad62b2 into matrixorigin:main Sep 23, 2026
26 of 27 checks passed
@mergify mergify Bot added dequeued and removed queued labels Sep 23, 2026
XuPeng-SH added a commit that referenced this pull request Nov 27, 2026
Backport the policy boundary from #29236 for #33377 and retain 4.2 prepared authorization and SQL mode behavior.
XuPeng-SH added a commit that referenced this pull request Nov 28, 2026
## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Fixes #33377. Backport of #29236.

## What this PR does / why we need it:

Apply the active role’s row and column rules to client queries and both
MySQL prepare paths. Keep session and inline rewrites optional. Preserve
mandatory rules while binding optional rewrite layers, and reject
statement forms that cannot apply them. Keep the existing
object-privilege checks.

Refresh mandatory policy after a role change within a request. Check the
retained policy before reusing a prepared plan and require a new prepare
when the active policy differs. Preserve 4.2’s SQL-mode staging, SQL
source classification, and prepared-statement invalidation behavior.

Built the service on Linux/amd64 with Go 1.26.4. On a loopback-only
synthetic database, 29 MySQL-protocol assertions passed for row
filtering, column projection, object-privilege denial, relational and
full-text reads, vector search, new connections, prepared execution, and
role and session state changes. Focused frontend, parser, and planner
tests also passed.

Physical IVFFlat verification on
`e2dfe3392fed4583914c7dd26cf6e7bd6993afbe` used a loopback-only
synthetic database. All six restricted cases (`pre`, `post`, and
`include` with optional rewriting enabled and disabled) showed
`ivf_search` in `EXPLAIN`. The `pre` and `post` plans retained the role
predicate on the base-table scan. The `include` plan pushed the
predicate into the index reader. All six executions returned the same
two authorized rows in rank order (synthetic IDs 12 and 14), matching
the exact-scan control. Wildcard projection returned only the
role-projected columns. Both execution and `EXPLAIN` rejected queries
when object privileges were missing or the rule omitted the embedding
column.

Distributed BVT was outside the local verification.

### Review follow-up

Mandatory role rules now reach INSERT assignment and source binding
contexts. Rule caches validate the policy and role-grant catalogs
against the authorized read snapshot. A committed rule change refreshes
the remaining statements in the same request. Connections with prepared
statements stay on the source CN, and the destination rejects unverified
prepared state. A policy catalog read failure permits normal handling of
a standalone transaction end while data statements fail closed.

On `a1b738479207667cb99ca76c8a2df08dd48b319d`, the maintained two-CN
MySQL regression passed first-rule publication, policy tightening on an
existing connection, stale native and text prepared-plan denial, and
role changes. It also checked relational and full-text results, the
physical IVFFlat plan, column projection, and the role predicate in a
conflict-assignment subquery. Focused frontend, parser, and planner
tests passed, including injected catalog failure with transaction
rollback and migration refusal at both ends.

The four frontend cases reported by the old x86 coverage job and both
`combined` rounds of `TestRewritePolicySavedResult` passed locally. The
frontend mocks now supply the expected role-catalog rows. The
saved-result checks assert authorization for both live and persisted
rows. The embedded test used a local TCP-only listener setting. [Old x86
coverage
job](https://github.com/matrixorigin/matrixone/actions/runs/45964609254/job/140394575275)

Distributed BVT and end-to-end proxy migration were outside this local
follow-up.

### Statement authorization review follow-up

The active role policy and object authorization now share one view for
each client statement, including statements in a batch and nested
expressions. Views inherit the caller’s mandatory rules. Unsupported
data reads and protected-target `INSERT RETURNING` fail closed.
Restricted users can replay saved rows only when the saved policy and
principal match, and existing object authorization still applies. Policy
catalog errors follow the transaction rollback setting. The test for an
invalid policy under the current SQL mode also verifies that authorized
table cleanup remains available.

Local validation of `bb66239ab6e76129ac406395874ce66f8ac7679f` passed
with Go 1.26.4 on Linux/amd64.

- The two-CN MySQL fixture verified row and column results through
relational, full-text and nested-view reads, confirmed `ivf_search` in
the physical IVFFlat plan, and verified object-denial controls, policy
changes, prepared-plan invalidation, and the expected counts in INSERT
conflict assignments and SET expressions.
- Frontend tests verified a controlled policy and object-authorization
snapshot interleaving, transaction rollback for both settings on text
query and native prepare errors, and migration refusal for unverified
plans. `Test_mce`, `TestKill`, `TestMysqlResultSet` and
`TestSession_Migrate/ok` passed.
- Both `combined` rounds of `TestRewritePolicySavedResult` passed using
the local TCP-only test configuration. The test accepted authorized
saved rows and rejected a result after its policy changed. Focused
parser, view, INSERT and RETURNING tests also passed.

Hosted distributed BVT and end-to-end proxy migration remain separate
from these local results. The previous head’s Proxy BVT reported two
cleanup failures in the role-rule fixture. The new head's hosted result
will establish the distributed outcome. [Previous Proxy
BVT](https://github.com/matrixorigin/matrixone/actions/runs/45975525564/job/140431175982)

### Prepared migration and cancellation follow-up

The source and destination both verify prepared replay. The supported
path rebuilds ordinary prepared SQL when the authenticated principal,
preparation settings and client-visible metadata agree and neither CN
has an active role rule. Other prepared state stays on the source. The
proxy checks the source before dialing and defers session-level transfer
refusals until client activity. A standalone KILL reaches the usual
authorization and cancellation handler during a role-catalog read
failure. Data requests continue to fail closed.

The old x86 Coverage timeout occurred because the authorization reader
moved its first cancellation check behind a mutex held by the waiting
test. The current head restores the baseline check before the wait and
retains the check after acquisition. The fixture now reports a bounded
failure if it cannot observe that order. [Old x86 Coverage
log](https://github.com/matrixorigin/matrixone/actions/runs/45986073683/job/140462472199)

Go 1.26.4 on Linux/amd64 validated
`3f32c488748aee4d91e17fa19014decc348e4a26`, tree
`ff72501b166f4b90c588439687dd5e88851e61fb`, from 11:59:08 to 11:59:51
UTC on 2026-11-27. The focused runner exited 0 across frontend, proxy,
isolated integration, embed, parser and planner. The retained validation
record contains the command, tested tree, exit status and Go test
events.

- `TestMandatoryRoleRulesAcrossConnections` passed in 14.06 s. Two real
CNs exported and replayed text- and native-prepared handles through the
query-service RPCs. The destination executed both retained handles and
returned the expected synthetic row. Source export and destination
replay refused the same prepared state after the mandatory policy was
published. The existing restricted-user fixture also verified views,
full text, physical IVFFlat, projection and object-privilege denial.
- `TestAuthorizationWaitHonorsCancellation/authorization`,
`TestRoleRuleAndObjectPrivilegesShareStatementSnapshot` and `TestKill`
passed. The SQL protocol fixture cancelled queries and connections
during the injected catalog fault and rejected queries that could access
data.
- `TestMigrateConnSourceRefusalStopsBeforeRouting`,
`TestTransferSync_SkipCachePopOnMigration` and the tunnel delivery
regression passed. Both `TestRewritePolicySavedResult` combined rounds
passed with the local TCP-only embed listener setting.

The local run covered two-CN RPC replay and proxy retry tests. A live
proxy handoff and hosted distributed BVT remain pending. [New head
CI](https://github.com/matrixorigin/matrixone/actions/runs/45995181524)

### Saved-result replay, historical reads and proxy drain

`2f553ddd3b0981fdb738f68e111559c400bea4d9` keeps the released
saved-result metadata format and expiry. A saved payload and a rule-text
fingerprint cannot establish whether the effective policy still
authorizes the materialized rows and columns. Both `result_scan` and
`meta_scan` refuse replay while a role rule is active. With an empty
effective role policy, reads retain the existing object-privilege checks
for old, new and restored results. Live queries continue to apply the
current filters and projection. No metadata migration or rewrite is
needed.

The binder rejects MO snapshot and Iceberg history qualifiers when a
role-rule rewrite would replace the qualified table reference. A two-CN
SQL fixture verified the no-rule historical rows against a different set
of current rows and verified refusal for the restricted reader. The
Iceberg qualifier is covered at the planner boundary.

The destination compares the authenticated account, user, primary role
and secondary-role mode before replaying client settings. The proxy
records activity after sending a command. A native statement close has
no acknowledgement, so in-flight or unreplayable prepared state uses the
existing 10-second migration cooldown. The source copies prepared
metadata only outside an active command.

- The real TCP proxy with two CNs preserved the connection ID and
session variable on an ordinary handoff, and refused both primary-role
and secondary-role-mode mismatches. After a native `COM_STMT_CLOSE`, the
previously refused idle session reached the target within 15.249 seconds
with the same connection ID and returned the authorized row. A separate
prepared session recovered after a rule change with only PING traffic in
15.243 seconds. Proxy runner and service shutdown both exited 0.
- Six focused Go packages passed on Linux/amd64 with Go 1.26.4. Both
saved-result rounds verified an unchanged rule whose dependency change
moved the live authorized result from row 1 to row 2, and verified that
both replay entry points refused the old result. The run also covered
native snapshots, the earlier x86 Coverage fixture, statement
authorization and cancellation, two-CN prepared replay, physical
IVFFlat, full text, projection and object privileges. A local listener
overlay substituted TCP in two existing fixtures.
- The synchronized CLOSE-forwarding test passed 100 repetitions under
`-race`. A whole-package proxy `-race` run stopped when local socket
policy blocked six Unix-listener fixtures. Hosted x86 Coverage and
distributed BVT remain separate. [GitHub
checks](https://github.com/matrixorigin/matrixone/pull/33389/checks)

### v4.2.9 shutdown-upgrade receipt (2f553dd)

Official Linux x86_64 asset for tag `v4.2.9`, source commit
`6c05e42f9f660a207077b050b8ec285ccf3f8103`. The downloaded archive
SHA-256 matched the digest in the GitHub release metadata. The candidate
was built and tested from local commit
`8b55c3fc049b1e30c39fb052ed703fc7aedbb17b`, with identical tree
`db6b13f46daa6ebdb346ebf90a8d8e91cd8c20d2` to the then-current PR head
`2f553ddd3b0981fdb738f68e111559c400bea4d9`. Both binaries used the same
isolated data directory in sequence. Separate backup and restore and the
later v4.2.8 hotfix binaries were outside this run. [Official
archive](https://github.com/matrixorigin/matrixone/releases/download/v4.2.9/mo-v4.2.9-linux-x86_64.zip)
· [Release
metadata](https://api.github.com/repos/matrixorigin/matrixone/releases/assets/782007199)

```text
SHA256 archive    7d567c88cdcc1ea610e122df67340941865a8116ea876f17eb775855dd072737  sha256sum -c: OK
SHA256 v4.2.9 bin d76fcc947ee73bc8a6ada94c437910c40a12d52af1a67d55ad0d2708f51d79e4
SHA256 candidate  b3fc56c11d3094f1ef5e82c4421ccedfa16ea5eb28d0c60e8c8373939f5b73a2

2026-11-27T14:15:31Z v4.2.9   mo-service -launch etc/launch/launch.toml
2026-11-27T14:15:44Z seed     two authorized saved fixtures, columns=[id], rows=[[1]]
2026-11-27T14:15:45Z v4.2.9   SIGTERM; all services stopped, exit=0; seed_exit=0
2026-11-27T14:19:27Z build    GOFLAGS=-buildvcs=false make ARCHSIMD=0 build-with-prebuilt-native
2026-11-27T14:19:56Z build    exit=0
2026-11-27T14:19:57Z candidate mo-service -launch etc/launch/launch.toml (same stopped data directory)
2026-11-27T14:20:01Z legacy   active-rule read refused; no-rule read columns=[id], rows=[[1]]
2026-11-27T14:20:01Z new      active-rule result_scan and meta_scan both refused (20301)
2026-11-27T14:20:01Z new      no-rule write/read columns=[id], rows=[[1]]
2026-11-27T14:20:02Z candidate SIGTERM; all services stopped, exit=0; upgrade_exit=0
```

### Table and role identity (d3931b6)

The role catalog and planner now share physical relation identity in all
three table-name modes. The derived binding exposes the same column
qualifier as an ordinary scan. An ambiguous historical folded key
prevents the affected read and leaves authorized rule DDL available.
Before replaying session state, migration compares the SQL-visible
primary role name and table-name mode in addition to the existing role
and principal IDs.

Rebased to `4.2-dev` at `78fe31d619`. Local incremental SCA passed. Race
validation covered frontend, proxy, parser and planner, the two-CN
role-policy fixture, and saved-result replay. The proxy cancellation
case passed 30 race repetitions with cancellation triggered after
request receipt. Shutdown upgrade verification from the published v4.2.9
build covered retained lower-case role data on the same store.

For the final build, a paired local benchmark of warmed SQL reads
against the rebased pre-fix build measured median block latency of
181.88 vs 188.77 µs with an active rule and 195.84 vs 199.50 µs for the
no-rule control. The active-rule median decreased in the reverse-order
pair.

### Directory proof and bounded role retry (a71450c)

Case-preserving sessions accept a folded legacy policy key only when the
statement authorization snapshot proves a unique exact lowercase
database and relation and the planner resolves the same physical
relation. Both ambiguous spellings are denied. Changes to the directory
invalidate the proof, and prepared statements whose proof has changed
require a fresh prepare. The persisted rule format is unchanged.

The destination requires role equivalence before replay. A recoverable
primary-role name or ID mismatch uses the existing 10-second per-tunnel
cooldown and drain scheduler. The destination still rejects migration
while roles are unequal.

At `a71450cc69a2dfbbd77be2136ff27868883d823d`, the tested local commit
`459b45db8d1b6913add6fa7d4d0c56c09accf6b9` has identical tree
`63e15f8eda5d02bc0678caad5a67454ab03945dc`. Six focused Linux/amd64 Go
1.26.4 package suites passed (`frontend`, `proxy`, `sql/parsers`,
`sql/plan`, `tests/issues/isolated`, `embed`), including case-sensitive
binding, a new case sibling invalidating a prepared plan, saved results,
and proxy retry classification. A test-only overlay substituted TCP
listeners for two local fixtures. `git diff --check` passed.

### Current v4.2.9 shutdown-upgrade receipt

This receipt covers the exact tree of the earlier head
`a71450cc69a2dfbbd77be2136ff27868883d823d`.

The released Linux x86_64 binary (source commit
`6c05e42f9f660a207077b050b8ec285ccf3f8103`) and the candidate ran
sequentially against the same stopped synthetic data directory.
[Official
archive](https://github.com/matrixorigin/matrixone/releases/download/v4.2.9/mo-v4.2.9-linux-x86_64.zip)
· [Published asset
digest](https://api.github.com/repos/matrixorigin/matrixone/releases/assets/782007199)

```text
2026-11-27 UTC | Linux/amd64, synthetic fixtures
SHA256 archive   7d567c88cdcc1ea610e122df67340941865a8116ea876f17eb775855dd072737  (sha256sum -c: OK)
SHA256 v4.2.9    d76fcc947ee73bc8a6ada94c437910c40a12d52af1a67d55ad0d2708f51d79e4
SHA256 candidate 3d3b69e7964ca8dd5d9810a73ecdde400b18748ddc75115f8b3a640af67952f3
20:42:19Z  GOFLAGS=-buildvcs=false make ARCHSIMD=0 build-with-prebuilt-native
20:43:07Z  build exit=0
20:43:08Z  v4.2.9: mo-service -launch etc/launch/launch.toml
20:43:22Z  fixture setup exit=0, v4.2.9 SIGTERM exit=0
20:43:22Z  candidate: mo-service -launch etc/launch/launch.toml
20:43:27Z  unique legacy key: columns=[id] rows=[[1]]
           ambiguous group: both spellings denied
           unruled saved results: legacy and new rows=[[1]]
           active policy: result_scan and meta_scan denied
           candidate SIGTERM exit=0, upgrade runner exit=0
20:43:28Z  candidate: mo-service -launch etc/launch-with-proxy/launch.toml -with-proxy
20:43:54Z  ordinary two-CN handoff passed, renamed-role connection stayed on source
20:44:09Z  original role restored, PING-only client migrated in 15.044s
           connection ID preserved, authorized rows=[[1]]
20:44:11Z  candidate SIGTERM exit=0, proxy runner exit=0
```

Backup/restore and upgrades from other releases were outside this run.
Distributed BVT is tracked in [hosted
CI](https://github.com/matrixorigin/matrixone/pull/33389/checks).

### Physical exports, ordinary writes and table-name mode retry

With active role rules, physical table export and SQL backup are refused
before their handlers can emit data. Row-local UPDATE and DELETE still
use ordinary object authorization when the planner resolves one
unprotected base table. Protected or uncertain targets, foreign-key
access to other tables, and unsupported expressions or multi-source
forms are refused.

A recoverable mismatch in the destination's table-name mode uses the
existing 10-second per-tunnel retry cooldown. Migration still requires
equivalent session identity and table-name mode before replay.

Validation for `fc2af632a8b4afd2dc10c0b574319b7eacea1f9f` used local
commit `5bcfae1bfb53b493ea4874dd4e820f60ef62ad35` with identical tree
`43305cde43e60b90b1301fa0b8ed409446d94a59`.

- Six focused Linux/amd64 Go 1.26.4 package suites passed across
`frontend`, `proxy`, `sql/parsers`, `sql/plan`, `tests/issues/isolated`
and `embed`. The saved-result test used a local TCP-only listener
overlay because Unix sockets were unavailable. Existing table-export
privilege and handler controls also passed.
- The two-CN MySQL regression verified committed ordinary writes on an
unprotected table, denial without mutations on a protected table,
refusal of a subquery write, and denial of an administrator's physical
dump before manifest creation.
- The exact candidate built via `make ARCHSIMD=0
build-with-prebuilt-native` (exit 0, binary SHA-256
`aed0027d37eedde368fa0843ef70cead1d0547444b8032af303ac1d10af2fdc6`). A
synthetic two-CN cluster with a real TCP proxy ran `mo-service -launch
etc/launch-with-proxy/launch.toml -with-proxy`. On 2026-11-27 at
21:43:52 UTC a mode mismatch retained the source connection. At 21:44:07
UTC the same client migrated after mode restoration with PING as its
only client traffic while waiting (15.054 s, same connection ID and
authorized `id` projection with row `[1]`). Service and runner exited 0.

This revision did not rerun the release-to-release shutdown-upgrade or
backup/restore exercises. Distributed BVT is tracked in [hosted
CI](https://github.com/matrixorigin/matrixone/pull/33389/checks).

### CDC admission and row-local write functions

When mandatory role rules apply, CREATE CDC is refused before task
creation. The background reader cannot maintain the creating statement's
authorization policy. Without mandatory role rules, the existing CDC
authorization and configuration checks apply.

The ordinary UPDATE and DELETE path accepts a small set of registered
data-only scalar built-ins with recursively row-local arguments. The
planner still proves the unprotected single-table target and applies
existing object permissions. A missing built-in overload cannot fall
back to a UDF on this path. Unknown forms remain fail-closed.

Validation for `b93a41bac6907e414c919f01690a9b6e1a1c043a` used local
commit `cfc77844d0d476350d4e16a75e474778d2b17948` with identical tree
`0f11e188fd8b9ebceba72c5392921cbb6e60226f`. Five focused Linux/amd64 Go
1.26.4 packages passed at 22:19 UTC on 2026-11-27 (`frontend`, `proxy`,
`sql/plan`, `sql/plan/function` and `tests/issues/isolated`), including
the existing CDC create handler and policy regressions. `git diff
--check` passed.

The synthetic two-CN MySQL regression verified that the unruled
administrator reached the normal CDC configuration validator, the same
request under an active rule was refused, and no task was recorded. No
CDC sink was configured. On the unprotected table, the restricted
client's row-local built-in UPDATE committed the expected value and its
DELETE removed only the expected row. Unknown and subquery expressions
were refused. Distributed BVT is tracked in [hosted
CI](https://github.com/matrixorigin/matrixone/pull/33389/checks).

### CDC lifecycle admission

The existing statement role-policy gate refuses CREATE CDC, resume and
restart before dispatch to the CDC task service when mandatory role
rules apply. All three can activate background reads that lack the
caller's continuous authorization policy. SHOW, PAUSE and DROP retain
their existing administrator checks and behavior.

Validation for `8477faa346c8b93876959977bbe3a3cdfe68f541` used local
commit `add15063dbd3d0b95e8af165ecec907fa464ede9` with identical tree
`e8117c4e5e57529db50fcc4b8d0032f15694ff49`. Focused Linux/amd64 Go
1.26.4 suites for `frontend`, `taskservice` and `tests/issues/isolated`
passed on 2026-11-27 at 22:58 UTC. The frontend protocol test refused
resume and restart before any task-service call and left the synthetic
paused task unchanged. Existing task-service tests verified lifecycle
transitions on test doubles.

In the two-CN MySQL fixture, the unruled administrator reached the
normal task lookup for resume and restart. With an active rule, both
were refused at authorization, as was create. PAUSE and idempotent DROP
were accepted and no fixture task was created. The tests used no real
CDC sink. `git diff --check` passed. Distributed BVT is tracked in
[hosted
CI](https://github.com/matrixorigin/matrixone/pull/33389/checks).

### Prepared policy principal

SQL and binary prepared execution now compare the authorization
principal from the rule lookup along with the effective rules, directory
proof and SQL mode. The snapshot retains its principal even when the
catalog is unable to provide reusable version evidence. A change of
principal under an active policy requires a fresh prepare. Statements in
sessions without rules and equivalent policies for the same principal
retain normal reuse. Proxy migration keeps its existing identity and
replay checks.

Validation for `78da203ee89eebf367720c39fc7cb5cca7b54633` used local
commit `5b043676105cabc48dd8fd988e66eb072ce8c257` with identical tree
`3a8edd52d392adb21191a8490acde74f5bf9b951`. The synthetic two-CN MySQL
test used matching static policies and verified that SQL and binary
prepared execution both requested a fresh prepare after a role change.
Fresh handles returned the expected authorized rows. The same fixture
verified reuse between unruled roles and after restoring the original
principal, and exercised two-CN prepared migration. Focused `frontend`,
`proxy`, `tests/issues/isolated` and `embed` tests passed on Linux/amd64
Go 1.26.4 on 2026-11-28 at 03:00 UTC, including secondary-role rule
discovery and saved results. The saved-result fixture used a TCP-only
listener overlay.

Git's three-way merge check against `4.2-dev` at
`57cd85573cd1d4e1297642010f06094cbfb92320` was clean. Runtime tests used
the published candidate tree. The prior IVF Coverage attribution is
unchanged and this round contains no IVF changes. [Earlier Coverage
run](https://github.com/matrixorigin/matrixone/actions/runs/46079827898/job/140776717160)
· [Current hosted
checks](https://github.com/matrixorigin/matrixone/pull/33389/checks)

---------

Signed-off-by: XuPeng-SH <[email protected]>

This branch was previously deployed

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

Labels

kind/bug Something isn't working size/L Denotes a PR that changes [500,999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants