Repository navigation
Conversation
A user with only column-level grants (`GRANT SELECT(col) ON db.t`) could
bypass `DESCRIBE TABLE` and `SHOW CREATE TABLE`, both of which require
`SHOW_COLUMNS`, by reading the same information from `system.tables`:
SELECT create_table_query, engine_full, partition_key,
sorting_key, primary_key, sampling_key
FROM system.tables WHERE database = 'db' AND name = 't';
The implicit-grant chain in `ContextAccess` propagates column-level grants
up to `SHOW_TABLES` at the table level, so the row passed the existing
`SHOW_TABLES` filter in `StorageSystemTables` and the DDL-revealing columns
were then populated unconditionally.
This change gates the DDL columns (`create_table_query`, `engine_full`,
`as_select`, `partition_key`, `sorting_key`, `primary_key`, `sampling_key`,
`unique_key`) on a per-row `SHOW_COLUMNS` check. The `dependencies_database`
and `dependencies_table` arrays now also filter their elements by
`SHOW_TABLES` on each dependent view, so a user cannot enumerate the names
of dependents they otherwise cannot see.
Behavior is unchanged for users with `SHOW_TABLES` at the database level
or wider, table-level `SELECT`, or explicit `SHOW COLUMNS` — all of which
imply `SHOW_COLUMNS` at the table level via the existing grant rules.
Mirrors the precedent of commits 5875e4d (`DESCRIBE` via `remote`) and
64efbbe (`CREATE AS`), which closed analogous bypasses on other code
paths.
Disclosure: https://clickhouse-inc.slack.com/archives/C02F2LML5UG/p1777430221999219
|
Workflow [PR], commit [0af3d7b] Summary: ❌
AI ReviewSummaryThis PR tightens PR Metadata
Missing context / blind spots
Findings
Tests
Final VerdictStatus: |
The previous version short-circuited `can_show_columns` on `!need_to_check_access_for_tables`, which becomes `false` when the user has `GRANT SHOW TABLES ON db.*` — exposing DDL to users without `SHOW COLUMNS`. The dependent-view filter had the same shape: skipped when the source table's database granted `SHOW TABLES`, which allowed names of dependent views in *other* databases to leak. Now `can_show_columns` is derived directly from `isGranted(SHOW_COLUMNS, db, table)` and the dependency filter only skips when the user has global `SHOW TABLES`. Comments trimmed. Test extended to cover both regressions.
|
@groeneai please check the tests failures here. If they are already fixed - provide a PR link. |
|
Hi @pufit, only 2 checks fail and both are chronic CI flakes unrelated to this PR.
30-day cross-PR data:
Your branch is rebased past #105146, so the function_prop_fuzzer hit is genuine residual chronic flake and not a missing-fix artifact. Recommendation: rerun the two failed jobs. No action required on this PR. The bot's inline review on |
|
Should this fix apply to the PTAL at the Opus 4.8 output:
|
|
Confirmed at PR head
The leak is dictionary-shaped: the loading-dependency graph carries Recommend mirroring the same per-element filter on all four Happy to push the widening as a follow-up commit on this branch or a separate PR. Session: cron:clickhouse-ci-task-worker:20260605-033200 |
jkartseva
left a comment
There was a problem hiding this comment.
Accepting; please make a follow up PR with symmetric changes for loading_dependencies_{database|table} and loading_dependent_{database|table}
|
|
||
| ++rows_count; | ||
|
|
||
| /// `SHOW COLUMNS` gates DDL-revealing columns to match `DESCRIBE` / `SHOW CREATE`. |
There was a problem hiding this comment.
The new SHOW COLUMNS gate does not cover parameterized_view_parameters below. Those parameter names and types are part of the view definition that SHOW CREATE TABLE hides behind SHOW COLUMNS, so a user with only SHOW TABLES on a parameterized view can still recover them with:
SELECT parameterized_view_parameters
FROM system.tables
WHERE database = 'db' AND name = 'parameterized_view';Please gate fillParametralizedViewData on can_show_columns as well, or explicitly narrow the contract/changelog if this column is intentionally SHOW TABLES-visible, and add a regression for a parameterized view.
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered by tests: 59/59 (100.00%) | Lost baseline coverage: none · Uncovered code |
|
Dear @jkartseva, you haven't been active on this PR for 30 days. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself. |
|
@groeneai I'm closing this PR, you now own the fix. Please re-introduce the correct version |
|
Acknowledged, I own this. I will open a fresh PR rather than reopen this one. Three measurements on current master (
The dependency surfaces this branch did cover are intact in my scope: I will keep the gate unconditional and backward-incompatible as labelled here, and carry |
|
Opened #117448. It follows the approach here and covers the three surfaces raised in review: the row's own Two deliberate differences from this PR. A dictionary's On the compatibility question from my earlier comment: I kept the gate unconditional and |
Motivation
A user with only column-level grants (
GRANT SELECT(col) ON db.t) can bypassDESCRIBE TABLEandSHOW CREATE TABLE— both of which correctly requireSHOW COLUMNS— by reading the same information fromsystem.tables:The implicit-grant chain in
ContextAccesspropagates column-level grants up toSHOW TABLESat the table level, so the row passes the existingSHOW TABLESrow filter inStorageSystemTables. The DDL-revealing columns were then populated unconditionally.Same class of bug as
5875e4daaf5(DESCRIBEviaremote) and64efbbeb906(CREATE AS).system.tableswas the lone holdout — every other surface (DESCRIBE,SHOW CREATE,system.columns) already requiredSHOW COLUMNS.Changes
StorageSystemTables.cppnow gates the schema-revealing columns on a per-rowSHOW COLUMNScheck:create_table_query,engine_full,as_select— empty string when access is denied; skips thetryGetCreateTableQueryparse + clone entirely.partition_key,sorting_key,primary_key,sampling_key,unique_key— default (empty) when access is denied.dependencies_database/dependencies_table— filtered per element bySHOW TABLESon each dependent view. The names of dependents areSHOW TABLES-grade information about those tables, notSHOW COLUMNS-grade about the current row's table.The existing fast paths are preserved:
SHOW TABLESrow visibility, the name-only short-circuit at line 518, and the admin-equivalent skip via!need_to_check_access_for_tables. Temporary tables are session-local and untouched.A new stateless test covers the bypass scenario, the
SHOW COLUMNSgrant path, a table-levelSELECTregression guard (still visible via the implicit-grant rule),SHOW TABLES-only (DDL hidden), and the dependent-view per-element filter.Changelog category (leave one):
Changelog entry:
Reading
create_table_query,engine_full,as_select,partition_key,sorting_key,primary_key,sampling_key, andunique_keyfromsystem.tablesnow requires theSHOW COLUMNSprivilege on the row's table, consistent withDESCRIBE TABLEandSHOW CREATE TABLE. Previously, a user with only a column-level grant (e.g.GRANT SELECT(col) ON db.t) could read the full table DDL throughsystem.tables, despiteDESCRIBEandSHOW CREATEcorrectly refusing them. Such users will now see empty values in these columns. To restore the previous behaviour, grantSHOW COLUMNSexplicitly. Thedependencies_databaseanddependencies_tablearrays now also filter their elements bySHOW TABLESaccess on each dependent.Documentation entry for user-facing changes