Repository navigation
fix(frontend): authorize table metadata SHOW with object privileges - #30304
mergify[bot] merged 5 commits into
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
Apply metadata visibility only to queries requiring frontend authorization. Trusted internal discovery runs before privilege catalogs exist. Cover missing-catalog bootstrap and ordinary-user fail-closed planning. Validated planner package, vet/lint, fresh-service Connector/J 8.0.15, 8.3, 8.4 and 9.7, and two rounds of both existing privilege BVTs. Related to matrixorigin#30279
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 458f178d68e3b3768e6b35c8b88127c065b2417f
Assessment: request_changes
Reviewed the complete 13-file delta and affected callers. Reusing the canonical visibility policy is sound, but the subscription fallback introduces a confirmed view-definition authorization bypass.
Model: gpt-6-astra / xhigh
Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1
- P2
pkg/frontend/show_metadata_privilege.go:74: Publish a database containing a view, then grant a subscriber role SELECT on table subscribed.* without database-level metadata privileges. Execute SHOW CREATE TABLE subscribed.private_view.
Impact: The statement returns the publisher's full view definition despite the existing view-definition privilege gate. Preserve the base-table-only restriction for subscription objects and add a subscribed-view regression test.
Evidence: baseTableOnly restricts only the local query; the subscription query ignores it. buildShowCreateTable subsequently delegates resolved views to buildShowCreateView without another authorization check. The public SQL probe returned CREATE VIEW text while SHOW CREATE VIEW on the same subscribed view and SHOW CREATE TABLE on a local view were denied. Restoring all changed production files to merge-base semantics made the same denial oracle pass.
Validation:
-
Isolation preflight and repository-owned native build passed. Independently verified 192 native inputs and 52 artifact hashes; the frozen source remains unchanged.
-
Seven focused frontend, planner and sysview tests passed with -count=1 and the supplied test-exec. The public SQL probe failed specifically because the unauthorized view-definition request succeeded. Log: focused-and-wire-tests-recovered.log; receipt: checks/1792076017309127098-3.json.
-
The merge-base production overlay control passed; both probe runs completed service shutdown and resource release. Log: baseline-wire-test.log; receipt: checks/1792076165187937278-3.json.
-
Command, source, exit, log and overlay reconciliation passed. Evidence directory: /home/xupeng/.local/state/mo-bot/jobs/39d0f394c551eb0a86f0442f/attempt-1. See validation-audit.json and behavioral-evidence.txt; final audit receipt: checks/1792076288817077887-4.json.
Limitations:
-
Full package suites and distributed BVT were not repeated locally. Supplied exact-head CI successes and author reports were considered; local_validation contained no retained author artifacts.
-
No comparative performance measurement was performed. Added catalog work is confined to metadata SHOW paths; ordinary SELECT/DML/DDL gain no visibility queries.
-
The linked issue body was absent from the frozen evidence. Initial dependency-download failures were recovered and were not treated as product-test results.
After subscriber-local broad visibility succeeds, verify the SHOW CREATE TABLE target through the existing internal SHOW FULL TABLES planner. Keep view definitions behind the database metadata gate while preserving base tables, publication allowlists, and subscriber-local role checks. Cover published and local views, denied PREPARE, and same-session EXECUTE after metadata-grant revocation. Validate frontend tests, vet/lint, and two normal BVT rounds of 184/184 checks with verified teardown. Related to matrixorigin#30279
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 591f4621431242ea1da79b53f7a900383e1bce6e
Assessment: approve
Reviewed the complete 14-file delta and affected callers. Reusing the canonical visibility policy restores object-level metadata access without adding authorization state. Database binding, subscription boundaries, error handling and protocol compatibility are coherent. Both prior findings are resolved; no actionable defects remain.
Model: gpt-6-astra / xhigh
Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1
Validation:
-
Ten focused tests passed across frontend, planner, sysview and SQL integration, including inherited privileges, revoked roles, bootstrap discovery, protocols 40/41 and prepared execution across 40→41→40. Receipt: checks/1792098203219660496-3.json; log: focused-validation.log.
-
An independent public SQL probe passed for subscribed-view denial, allowed table definitions and view columns, publication allowlists, hidden siblings, cached revocation and prepared statements. Receipt: checks/1792098237151922937-3.json; log: public-boundary.log. Fixture shutdown and resource release completed.
-
Isolation preflight passed. Verified 192 native inputs and 62 artifact hashes against this revision and invoked the repository build owner. Tests used Go 1.27.1 on Linux/amd64 with the supplied test executor; source remained unchanged.
-
Commands, source fingerprints, exits, logs and overlay hashes were reconciled in /home/xupeng/.local/state/mo-bot/jobs/9a74ac19f12ecf47fcd59ba0/attempt-1/validation-audit.json. Final audit receipt: checks/1792098311493804308-4.json.
-
The supplied current-head CI snapshot reports successful required CI, unit tests, static analysis, coverage and BVT.
Limitations:
-
Full package suites and distributed BVT were not repeated locally; raw CI logs and the linked issue body were not supplied.
-
Compatibility validation used an embedded CN with controlled protocol versions, not a mixed-binary rolling-upgrade cluster.
-
No comparative performance benchmark was run. Added catalog and role traversal work is confined to metadata SHOW paths; ordinary SELECT/DML/DDL gain no visibility queries. Large-schema and role-graph latency remains unmeasured.
Merge Queue Status
This pull request spent 2 hours 29 minutes 58 seconds in the queue, including 53 minutes 40 seconds running CI. Required conditions to merge
|
Backport the SHOW metadata behavior from matrixorigin#30304 onto the release branch. Bind the selected database, evaluate current object grants at execution time, and preserve publication allowlists and view definition privileges. Use release protocol 12 for object-only SHOW TABLES admission and row filtering. Protocol 11 retains its database-level admission and listing. Propagate the active role identity and transaction context and bound role closure loads per physical execution, including retry and cancellation. Refs matrixorigin#32855.
## 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 #32855. Backports #30304 to `4.2-dev`. The original report is #30279. ## What this PR does / why we need it: A user with SELECT on a table can query its rows, yet the database-level SHOW privilege check rejects inspection of its columns and CREATE TABLE definition. This backport binds each SHOW statement to its actual target database and consults object privileges after an ordinary database-level denial. SHOW TABLES uses the same visibility rules so a grant on one table exposes only the permitted names. Subscription publication allowlists and view-definition restrictions still apply. The release branch needs the execution-time role lookup and identity propagation that main already had when #30304 landed. The new code resolves active and inherited roles against the executing transaction, bounds role traversal, and reuses the result within one physical execution. Prepared SHOW statements refresh the relevant metadata and authorization when executed, including after a revoke or a publication change. **Protocol compatibility.** Release protocol 12 corresponds to main's protocol 41 for object-only SHOW TABLES admission and filtering. Release protocol 11 keeps the database-level gate and its existing listing behavior. The mapping is specific to this capability. **Historical SQL validation (original backport head `dd7b10f9c4360e486a4008b8fdbc27178718a219`).** Three SQL regression suites ran on macOS arm64. The privilege suite passed 1,746 checks with 2 ignored, publication/subscription passed 1,693, and dml/show passed 613 with 23 ignored. The issue-specific subsets passed 25/25 and 22/22. Coverage includes exact visible names, table metadata access, revoke/regrant, prepared execution, and publication changes. Four additional plain SHOW TABLES executions through an isolated two-CN proxy returned exactly the 64 expected names after worker labels changed. Statement history recorded success but did not retain physical placement. **Validation limits.** Arbitrary in-flight protocol downgrade was not tested. Timing samples did not establish a reliable latency comparison. A separate stress query adding a large generated series encountered a remote execution failure under forced placement. Its behavior on the unmodified release base has not been established. **CI repair validation (08b9738).** Completed the Apache 2.0 headers in two added test files identified by [SCA run 44226249385, job 134540120015, attempt 1](https://github.com/matrixorigin/matrixone/actions/runs/44226249385/job/134540120015). Newly ran `license-eye -c .licenserc.yml header check` using CI-pinned v0.4.0: 4,888 valid, zero invalid; the focused two-file check, `git diff --check`, and formatting checks also passed. Package declarations, imports, and test code are byte-for-byte unchanged from `dd7b10f9c4360e486a4008b8fdbc27178718a219`; the SQL validation above is reused. No runtime tests were rerun for this comment-only repair; the remaining SCA analyzers will run in the new CI. **SCA error-path repair (8e010d7).** [Run 44229764080, attempt 1](https://github.com/matrixorigin/matrixone/actions/runs/44229764080/job/134552286070) passed license checks and reported SA5001 in the new role-root query helper; CI Required propagated that failure. The helper now checks the SQL error before deferring cleanup and explicitly closes partial results on failure. Added error cases for account, primary-role grant, and all-role grant queries assert original-error propagation and released result memory. Newly passed on macOS arm64 with CI Go 1.26.4: owning-package build/vet; `mo-cgo-test` identity matrix, full package normal/race, and identity `-race -count=100`; compiler tests `TestCurrentRolesExecutionCacheScopeAndGeneration` and `TestShowRolesCompiledCacheGeneration`; CI-pinned golangci-lint 2.6.2 with `.golangci.yml` on `./pkg/sql/colexec/table_function` (0 issues); focused license and formatting checks. Native dependencies were built from this release tree. Original SQL evidence is reused; full Linux CI awaits the new push. **Review repair validation (bbd3093).** Object-only SHOW fallback now accepts an explicit set of row-local predicate operators; subqueries, function calls and unknown forms are rejected before execution. SHOW TABLES carries its database/object admission into planning: database admission avoids role traversal, object admission cannot select an unfiltered legacy plan, and prepared rebuilds refresh admission against the prepared database. Newly passed with Go 1.26.4/native CGO on macOS arm64: frontend/planner/AST build, vet and owning-package tests; each of four predicate/admission/prepared/rollback tests with `-race -count=100`; and the authenticated SQL regression `TestShowMetadataAdmissionIsolation` with `-short -tags matrixone_test -race`. That regression proves exact visible names, rejected unauthorized predicate reads, database SHOW grants, and prepared execution after revoke. An original-head production-source overlay fails the same regression precisely because the malicious SHOW returns no error. Final protocol-transition edits are covered by the deterministic in-planning downgrade test; unchanged-input public SQL evidence is reused. CI-pinned golangci-lint 2.6.2 reports 0 issues, headers and artifact checks pass. Full BVT and a 4,097-role SQL fixture were not rerun; the typed planner test verifies that database admission installs no role-closure CTE. **SCA test-probe repair (771106f).** [Run 44266293888, attempt 1](https://github.com/matrixorigin/matrixone/actions/runs/44266293888/job/134671649659) reported rowserrcheck/sqlclosecheck in the new SQL regression. Expected-error SHOW probes now use `ExecContext`, retaining the exact rejection assertion and the successful-listing Rows checks. Newly passed with Go 1.26.4/native CGO: owning `pkg/tests/issues/isolated` vet and all configured golangci-lint 2.6.2 checks (0 issues); `TestShowMetadataAdmissionIsolation` with `-short -tags matrixone_test -race -count=1` (20.058s); header and diff checks. The package is test-only, and the regression command compiled its test binary. Production code and earlier review validation are reused unchanged. **Review repair validation (1487d93).** SHOW COLUMNS uses the same target database for authorization and planning, and prepared SHOW metadata keeps the database selected at PREPARE. Object-authorized SHOW TABLES reads visibility at the statement authorization snapshot while the user's SI data snapshot stays intact. Newly passed on macOS arm64 with Go 1.26.4 and native CGO: frontend/planner/AST build, vet and package tests, focused frontend/planner race tests, and the public SQL regression `TestShowMetadataAdmissionIsolation` with `-short -tags matrixone_test -race -count=1` (33.756s). The regression covers RC and SI, database precedence, text and binary PREPARE across USE, and revocation during an open transaction. The tagged test vet, golangci-lint 2.6.2 for the changed diff, and the PR artifact check also passed. Earlier CI evidence applies to `771106ffdbafdab15b88b09dddc0bfab69236771`. Linux and multi-CN verification for the repair will run on the new commit. **Object identity regression validation (`23dbcfa799d651e289361b20620a92ff4790588f`).** Object-authorized SHOW COLUMNS and SHOW CREATE TABLE now resolve and read the target in the statement authorization snapshot. Text and binary EXECUTE refresh admission before planning, and the user transaction keeps its data snapshot. Newly passed on macOS arm64 with Go 1.26.4 and native CGO: frontend, planner and AST build/vet and package tests, tagged vet for the isolated SQL test package, frontend package race, 100 focused race rounds of `TestRebuildPreparedShowRefreshesAdmission`, and changed-line golangci-lint 2.6.2 (0 issues). `TestShowMetadataAdmissionIsolation` passed with `-short -tags matrixone_test -race -count=1` in RC and SI, including direct and prepared metadata for the replacement object and an independent SI data read. The same final test fails on an overlay of the reviewed production files because it observes the old object. Linux CI will run on this commit. **Pipeline cancellation validation (`8e9a5a47468411168bbe496ffb7015764ffb24c1`).** The execution owner classifies cancellation before cleanup. Merge and vector aggregation preserve the terminal result and release blocked siblings and shared role loaders with the originating failure. A graceful local stop still leaves the shared execution cache usable. Newly passed on macOS arm64 with Go 1.26.4 and native CGO. The `mo-cgo-test` normal suites passed for compile, table functions and pipeline, and full race suites passed for compile and table functions. Five focused race tests each passed 100 rounds, covering independent child cancellation, graceful stop, vector branch lifecycle, retry generations and shared cache retirement. The original head reproduces the missing parent cancellation with the same race regression. Build, vet, changed-line golangci-lint 2.6.2 and the artifact check passed. The test runner used the OS temporary directory because the local file service filters the hidden ancestor in the default Loom temp path. Linux CI will run on this commit. **Conflict resolution and validation (`250e9da34224f8e76dd1cae4777d80cfe5c16e98`).** Rebased onto official `4.2-dev` at `f4dc8554a3bd4f92d1e009cb2dcb2bd227036861`. The scope uses the release branch's pre-cleanup cancellation classification and diagnostics. Merge and vector aggregation retain the terminal error and release blocked role loaders. MORPC 11 remains the immediate predecessor of this PR's protocol 12. Newly passed on Darwin/arm64 with Go 1.26.4 and native CGo. Build, vet, and normal and race suites passed for compile, table functions, and pipeline. Nine focused compiler tests each passed 100 race repetitions, covering independent child errors, local stop, serial and parallel reader failures, and retry and registration boundaries. The authenticated `TestShowMetadataAdmissionIsolation` passed in RC and SI under race. The PR artifact check passed. The prior head's Linux run completed successfully on attempt 2. Linux verification of this rebase will run on the new head. [Prior Linux CI](https://github.com/matrixorigin/matrixone/actions/runs/44383815319/attempts/2) --------- Co-authored-by: XuPeng-SH <[email protected]>
What type of PR is this?
Which issue(s) this PR fixes:
What this PR does / why we need it:
A table SELECT grant already exposes that table through information_schema, but SHOW COLUMNS and SHOW CREATE TABLE reject it at the database privilege gate. Bind the statement's actual database and allow current-object metadata inspection through the shared metadata visibility policy after an ordinary database-level denial. Apply the same policy to SHOW TABLES so unauthorized sibling tables remain hidden. Object-only SHOW TABLES admission and per-table filtering require protocol 41 or later, where the complete inherited-role closure is available. Below protocol 41, preserve the existing database-level authorization and unfiltered listing; table-only grants do not enable this new fallback.
Reuse the existing role closure, privilege scopes, ownership, and subscriber-local visibility rules. Preserve publication table allowlists, shared system/cluster tables, and the existing view-definition and historical-query authorization boundaries. No catalog format or cache state changes. Database-gate denials perform at most two visibility queries. A successful subscription SHOW CREATE TABLE fallback adds one exact-object SHOW FULL TABLES probe, preserving the view-definition gate without evaluating subscriber roles in the publisher account or requiring a newer metadata protocol.
Validation on macOS arm64 / Go 1.27.1:
All required CI checks passed on the preceding head 0c1a089. CI validation for this compatibility repair will run after push. The issue remains available for reporter verification after merge.