Skip to content

Require SHOW COLUMNS to read DDL columns in system.tables - #117448

Merged
alexey-milovidov merged 16 commits into
ClickHouse:masterfrom
groeneai:groeneai/system-tables-show-columns-gate
Oct 16, 2026
Merged

alexey-milovidov merged 16 commits into
ClickHouse:masterfrom
groeneai:groeneai/system-tables-show-columns-gate

Conversation

@groeneai

@groeneai groeneai commented Sep 1, 2026 •

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • Backward Incompatible Change

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Reading the columns of system.tables that describe a table's schema requires the SHOW COLUMNS privilege on that table, the same privilege DESCRIBE and SHOW CREATE TABLE require: create_table_query, engine_full, as_select, partition_key, sorting_key, primary_key, sampling_key, unique_key, skipping_indices_types and parameterized_view_parameters. Previously any column-level grant, such as GRANT SELECT(col) ON db.t, sufficed to read the full DDL of db.t. For a table created by CREATE DICTIONARY the CREATE query follows SHOW CREATE DICTIONARY and stays readable with SHOW DICTIONARIES; the row itself is still listed only with SHOW TABLES. The columns naming other tables (dependencies_*, loading_dependencies_*, loading_dependent_*, target_database, target_table) now list only tables the user may see with SHOW TABLES. INFORMATION_SCHEMA.VIEWS.view_definition follows the same rule. To restore the previous behaviour, grant SHOW COLUMNS ON db.t, the same on an Alias target, and SHOW TABLES on the tables the dependency columns name.

Description

Root cause: a column-level grant is promoted to table-level SHOW_TABLES, so the row passes the row filter; table-level SHOW_COLUMNS means "on every column" and stays false, but TablesBlockSource::generate never consulted it.

Two invariants, so two mechanisms. can_show_columns gates the columns describing the row's own schema, requiring table-level SHOW_COLUMNS as InterpreterShowCreateQuery does, including its SHOW DICTIONARIES branch, and, for a StorageAlias row, the same on its target; it composes with the existing can_expose_metadata. is_dependency_visible filters per element the columns naming other tables, dropping both halves of each pair together so they stay index-aligned. Denial renders the column default, not an error.

Out of scope, no column-level information: comment, definer, metadata_path, storage_policy.

03636_storage_alias_metadata_access_rights pinned this leak: a user granted only SELECT(value) on an Alias target saw the whole DDL. Those assertions now read 0. Since #115141 SHOW CREATE TABLE strips an Alias's inlined columns, but create_table_query returns the stored definition as is, so the target check stays.

Disclosed, not fixed: system.data_skipping_indices, system.projections and system.constraints are SHOW_TABLES-gated and each exposes a definition naming columns.

Related: #105367

Re-introduces @ pufit's PR, following its approach, widened to the surfaces raised in review.

Measured effect on consumers that read the gated columns

Each measured on this branch against an unpatched build of the same base, as a user holding only SHOW TABLES.

Consumer Before After
INFORMATION_SCHEMA.VIEWS.view_definition (reads as_select, SQL SECURITY INVOKER) full SELECT text empty
SHOW INDEX / SHOW KEYS (rewritten onto primary_key) names the primary-key columns one PRIMARY row with an empty column_name
ArrowFlight CommandGetPrimaryKeys (reads primary_key) names the columns no primary-key rows
/schema UI, play.html table properties DDL panes and graph edges populated blank panes, no cross-database edges

The SHOW INDEX result is not a new output shape: an engine without a primary key, such as Memory, already yields exactly that row today for any user, which is why InterpreterShowIndexesQuery is left alone here rather than given its own check.

INFORMATION_SCHEMA.TABLES is unaffected: its primary_key reference is primary_key_size from system.parts, and every column it takes from system.tables is ungated.


Workflow [PR]
Sync PR [sync-upstream/pr/117448]

Version info

  • Merged into: 26.11.1.112-master (included in 26.11 and later)

groeneai and others added 6 commits August 31, 2026 16:50
A user holding only a column-scoped grant, such as GRANT SELECT(public_col) ON
db.t, could read the full DDL of db.t out of system.tables, although DESCRIBE
and SHOW CREATE TABLE correctly refuse them the same information.

A column-level grant is promoted to table-level SHOW_TABLES (ContextAccess.cpp,
the leaf_or_wildcard clause), so the row passes the row filter. Table-level
SHOW_COLUMNS is "on every column" (AccessRights.cpp min_flags_with_children) and
stays false, but TablesBlockSource::generate never consulted it, so every
schema-revealing column was filled unconditionally. The interpreters do gate:
InterpreterShowCreateQuery and InterpreterDescribeQuery both checkAccess on
SHOW_COLUMNS. system.tables was the only holdout.

Two invariants, so two mechanisms:

- can_show_columns gates the columns that describe the table's own schema:
  create_table_query, engine_full, as_select, the five key expressions,
  skipping_indices_types and parameterized_view_parameters, in both the main
  loop and the temporary/external-table path. It requires table-level
  SHOW_COLUMNS on the row's table and, for a StorageAlias row, on its target,
  mirroring InterpreterShowCreateQuery exactly. It composes with the existing
  can_expose_metadata rather than replacing it. Denial renders the column's
  default instead of throwing, matching can_expose_metadata and the system.*
  convention that these tables hide information rather than fail the query.
  The global short-circuit follows StorageSystemColumns.cpp verbatim, so a user
  with instance-wide SHOW COLUMNS pays no per-row check.

- is_dependency_visible filters, per element, the columns that name *other*
  tables: dependencies_*, the four loading_* arrays and target_*. Both halves of
  every pair are skipped together, because programs/server/schema.html zips them
  by index and a one-sided filter would pair the wrong database with the wrong
  table.

Deliberately out of scope, since they carry no column-level information:
comment, definer, metadata_path and storage_policy. The fast path
fillTableNamesOnly emits only database and name, so it is unaffected.

03636_storage_alias_metadata_access_rights pinned the leak: a user granted only
SELECT(value) on an Alias target was asserted to see the whole DDL through
system.tables while SHOW CREATE TABLE on the same object threw ACCESS_DENIED.
Those two assertions now read 0, the paired ACCESS_DENIED assertion is added so
the reference proves the two surfaces agree, and the block titles are corrected
to say "column-scoped target permission" to match the grant they exercise.

INFORMATION_SCHEMA.VIEWS.view_definition reads as_select with SQL SECURITY
INVOKER, so the gate propagates there; that is intended, since SHOW CREATE TABLE
on the same view already refuses the same user.
… the Alias target

Review round 1 on the SHOW COLUMNS gate for the DDL columns of system.tables.

InterpreterShowCreateQuery authorizes a CREATE query with two different
privileges, not one: SHOW DICTIONARIES when the statement is SHOW CREATE
DICTIONARY, SHOW COLUMNS otherwise. The gate implemented only the second, so a
user holding row visibility plus SHOW DICTIONARIES read empty DDL columns out of
system.tables while SHOW CREATE DICTIONARY handed them the full text for the
same object. That is a loss of information the user is authorized to have, and
it made the changelog's parity claim inaccurate for dictionary rows.

can_show_create_query adds the dictionary disjunct at exactly one site, the
rendered-CREATE trio. The other gated columns stay on can_show_columns because
DESCRIBE of a dictionary still requires SHOW COLUMNS; for a dictionary row they
are empty anyway, so this keeps the change interpreter-shaped and minimal.

The object-kind test is a non-null configuration, verified in-tree as equivalent
to Location::SameDatabaseAndNameAsDictionary by the chassert in
StorageDictionary::renameInMemory. IStorage::isDictionary() and
DatabaseCatalog::isDictionaryExist() are deliberately not used: both are also
true for CREATE TABLE ... ENGINE = Dictionary (Location::Custom), whose CREATE
query carries a plain table's column list, so either would open a new leak
rather than close one. Substituting isDictionary() in a throwaway build makes
the new negative control in 05055 hand a SHOW DICTIONARIES holder the full
column list of a table that SHOW CREATE TABLE refuses them, which is why the
control is in the test rather than the reasoning being in a comment.

Two guards named in the changelog had no test that would notice their removal:

  - The Alias target conjunct of can_show_columns was only ever observed in its
    denied state. Every Alias assertion on a gated column expected a blank, and
    the one test asserting a non-empty create_table_query for an Alias row runs
    as the default user, where the global short-circuit fires first. Forcing the
    conjunct to false left the whole suite green. 03636 now also probes the row
    in the granted state, inside the block that grants SHOW COLUMNS on the
    target, and all seven flags come back set.

  - unique_key had a guard and a changelog mention but no oracle. Covered by a
    new test rather than by extending 05055: every UNIQUE KEY test needs several
    environment exclusion tags, and importing those onto 05055 would delete the
    rest of that file from those CI lanes, i.e. weaken the tests that pin this
    fix. The new test omits no-fasttest because it never inserts, matching
    04657, which creates a UNIQUE KEY table without inserting and runs there.

Each of the three new oracles was proved live by reverting its guard in a
separate build and confirming the corresponding test fails.
…h emits it

Review round 2 on the `SHOW COLUMNS` gate for the DDL columns of `system.tables`.

Round 1 made the authorization of the rendered-CREATE trio depend on the kind of
the object: a non-null `StorageDictionary` configuration plus `SHOW DICTIONARIES`
authorizes the `CREATE` query the way `SHOW CREATE DICTIONARY` does. That kind is
read off the storage object the tables iterator captured, while the value emitted
is resolved again by name, because `IDatabase::getRenderedCreateTableQuery` goes
through `getRenderedCreateTableQueryImpl`, which renders whatever
`tryGetCreateTableQuery` returns for that name.

So the privilege was checked against one object and the text was fetched for
whatever holds the name at the moment the row renders. The window is not a single
instruction: the tables iterator is a snapshot of the database's table map, taken
once per database per `generate` call, and rows are then rendered one at a time
with metadata I/O in between, so a late row can render long after its snapshot
was taken. A name dropped as a `CREATE DICTIONARY` object and recreated as a
regular table inside that window rendered the new table's full DDL to a holder of
`SHOW DICTIONARIES`, which is exactly what `SHOW CREATE TABLE` refuses them.

`RenderedCreateQuery` now carries `is_dictionary`, set in `renderCreateQuery`
where the `ASTCreateQuery` is already in hand, and a rendering that only the
dictionary disjunct authorized is discarded unless it is itself a
`CREATE DICTIONARY`. That validates the artifact actually emitted, which is what
`InterpreterShowCreateQuery` gets for free by fetching and validating in one
lookup.

Two alternatives rejected. Calling `tryGetCreateTableQuery` a second time to
inspect the kind is another lookup by name, so it is a fresh instance of the same
problem rather than a fix, and it doubles the cost of the most expensive column in
`system.tables`. Holding a lock across the authorize-and-render pair, or changing
the iterator's snapshot semantics, widens synchronization on a hot path to settle
a question the rendered value already answers.

The race direction has no deterministic oracle without a new failpoint inside
`TablesBlockSource::generate`, and a failpoint in that path is a worse trade than
the guard. The non-race direction is covered: forcing `is_dictionary` false in a
throwaway build turns the granted dictionary arm of
`05055_system_tables_show_columns_leak` from `1 0 0` to `0 0 0` on exactly one
line, and leaves the other two tests green. So the guard sits on the executed
path and it does not blank the dictionary rows round 1 restored.

`docs/reference/system-tables/tables.mdx` said the schema columns require
`SHOW COLUMNS` and that without it they read as empty, which round 1 made false
for dictionary rows and left the diff contradicting its own changelog entry. The
page now states the carve-out, and names `CREATE DICTIONARY` rather than "a
dictionary" so that a table declared `CREATE TABLE ... ENGINE = Dictionary` is
not described as if it were covered. It also mentions the `Alias` target
conjunct, which it never did.

The comment above `dictionary_probe` in `05055` attributed the empty
`partition_key` and `skipping_indices_types` to the gate. They are empty because
`StorageDictionary` sets only columns, comment and virtuals, so it has no key
expressions and no secondary indices: those two flags are a non-regression check
in both arms, and the width of the `SHOW DICTIONARIES` disjunct is established by
the `create_table_query` transition and the `ENGINE = Dictionary` control.

Co-Authored-By: Claude Opus 5 <[email protected]>
…endency loop

Two test-only gaps, both of which let a guard be hard-coded with the whole
suite still green.

The temporary and external table branch of StorageSystemTables carries its own
copy of the schema gate, applied to create_table_query,
parameterized_view_parameters and skipping_indices_types. No test reached it:
the persisted tests build no temporary Alias, and the temporary MergeTree test
runs as an unrestricted user, where the global short-circuit fires before any
conjunct is evaluated. The conjunct is not cosmetic. StorageAlias forwards
getInMemoryMetadataPtr to the target, so the index types and view parameters on
such a row belong to the target and are exactly the information this gate
withholds elsewhere.

The new test drives it over one HTTP session. A same-connection test cannot
reach the interesting state at all: creating an Alias requires table-level
SHOW COLUMNS on the target, so the withheld state exists only after that
privilege is revoked, and the revoke has to come from an administrator on
another connection while the temporary table stays alive. An HTTP session gives
that deterministically and with no timing window: grant, create, read, revoke
elsewhere, read again. A second user cannot substitute for it, because the
create-time check would refuse the alias to a user who lacks the grant.

The probe also selects an ungated column and asserts it in both arms. A
temporary row inserts a default database, so without that a row which had
simply disappeared would read as a row whose columns were withheld.

For the dependency arrays, the per-element filter runs in two separate loops,
over getLoadingDependencies and over getLoadingDependents. Three of the four
name families asserted both a hidden and a visible element, but
loading_dependencies_* asserted only the hidden one, and the alignment block
compares lengths only. Dropping every loading dependency for any restricted
user therefore kept the suite green. One query closes it, on a dependency the
existing administrator assertion already proves exists, so no fixture changed.

Each guard was checked by mutation, against the final text of the tests rather
than an earlier draft. Hard-coding the temporary conjunct true moves the
withheld arm and nothing else; hard-coding it false moves the granted arm and
nothing else; skipping the first dependency loop for restricted users moves the
new visible-dependency line and leaves the administrator line alone. The same
dependency mutation leaves the suite green when the new assertion is removed,
which is the reason for adding it.

One alternative was refuted rather than chosen. Asserting withholding by
granting only column-scoped access to the target is not constructible: the
create-time check demands the table-level privilege, so the alias cannot be
created in that state in the first place.

Co-Authored-By: Claude Opus 5 <[email protected]>
can_show_columns_temp gates three columns on a temporary or external table
row, and 05057 reached only two of them: create_table_query and
skipping_indices_types. Deleting the conjunct from the
parameterized_view_parameters site alone left the whole suite green.

StorageAlias forwards getInMemoryMetadataPtr to its target and the column is
built from the target's inner SELECT, so a temporary Alias over a
parameterized view reports the target view's parameter names and types. That
is the information this gate withholds elsewhere, and DESCRIBE already
refuses the same object for the same user.

The test now creates a second temporary alias over a parameterized view in
the same session and probes its parameter list next to the ungated engine
column, so a withheld column stays distinguishable from a row that vanished.
The parameter is deliberately not named after a column of the base table.

No source change. Removing the conjunct from that one site reddens the
withheld arm and nothing else; forcing the whole gate closed reddens the
granted arm, now including the new flag.
Two test-only fixes. No source change.

05057 created two temporary Alias tables as a restricted user without granting
TABLE ENGINE on Alias. InterpreterCreateQuery::getRequiredAccess has no early
return for temporary tables: after the isTemporary branch appends CREATE
ARBITRARY TEMPORARY TABLE, control falls through to the TABLE ENGINE entry, and
getTablePropertiesAndNormalizeCreateQuery re-checks the same privilege after
setEngine. It is enforced when table_engines_require_grant is set, which
tests/config/config.d/enable_access_control_improvements.xml does and
tests/config/install.sh links into every functional-test server. Both CREATE
TEMPORARY TABLE statements were therefore a certain ACCESS_DENIED under CI while
passing against a plain server. 03636 already grants the same privilege for the
same engine and user shape, and 02561 shows it applies to the temporary path.

05055 asserted only target_database on the materialized-view target pair.
StorageSystemTables fills target_database and target_table from two separate
inserts, so filtering one and not the other leaves the reference green, and the
unfiltered one would be the table name. The probe now asserts both halves, in
the admin arm as well, so the fixture is shown to populate them before the
restricted arm reads them.

Both are validated against a server carrying the stateless-test config overlay
instead of a plain one, which is what let the missing grant through earlier.
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-request PR origin: a maintainer pinged or directed groeneai labels Sep 1, 2026
@groeneai

groeneai commented Sep 1, 2026 •

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 18 findings over 5 rounds,
$124 of gate spend), plus my own cold review of the resulting code before each of those
rounds ran. Five fix rounds followed; nothing below is outstanding.

# Sev Finding Verdict Evidence / action
1 ❌ A legacy Alias-to-Alias chain bypasses the final target's SHOW COLUMNS check, so system.tables shows that target's key expressions (StorageSystemTables.cpp can_show_columns) DISAGREE The chain and the single-hop check are both real, but DESCRIBE behaves identically: InterpreterDescribeQuery.cpp:251,255-258 runs the same checkAccess(SHOW_COLUMNS, table) plus immediate-target pair and then lists the columns of the same recursively resolved snapshot (StorageAlias.h:125-132). The gate's own probe measured DESCRIBE on the chain succeeding for that user while DESCRIBE on the final target was refused. The depth limit is in StorageAlias::isTargetTableGranted and is shared by DESCRIBE, SHOW CREATE TABLE and the creation-time check at StorageAlias.cpp:551; closing it here alone would make system.tables stricter than DESCRIBE, which is the asymmetry this PR exists to remove. Disclosed, not changed.
2 ⚠️ The temporary-table path leaves engine_full nonempty after the target's SHOW COLUMNS is removed DISAGREE True and irrelevant: that branch inserts table.second->getName(), the byte-identical expression the ungated engine column already emitted for the same row, and StorageAlias::getName returns the constant Alias rather than the target's engine. It publishes nothing the row does not publish one column earlier. The main loop's engine_full, which does carry engine arguments, is gated.
3 ⚠️ The gate hides a dictionary's DDL from a holder of SHOW DICTIONARIES, who is still authorized to read it through SHOW CREATE DICTIONARY AGREE, fixed in this PR Correct, and it made the parity claim inaccurate for dictionary rows. InterpreterShowCreateQuery.cpp:89-92 authorizes the CREATE text with SHOW DICTIONARIES for a dictionary and SHOW COLUMNS otherwise; only the second branch was mirrored. The rendered CREATE query of a CREATE DICTIONARY object now also opens under SHOW DICTIONARIES, discriminated by StorageDictionary::getConfiguration, so CREATE TABLE ... ENGINE = Dictionary stays closed. The schema-detail columns keep requiring SHOW COLUMNS, matching DESCRIBE.
4 ⚠️ The Alias test proves denial only: it would pass if Alias schema were always suppressed AGREE, fixed in this PR Confirmed. Every Alias assertion on a gated column expected a denied state, and the one test in the suite asserting a nonempty create_table_query for an Alias row runs as a user with instance-wide grants, so the global short-circuit fires before the alias-target conjunct is evaluated. A positive system.tables assertion is added after the existing target SHOW COLUMNS grant, and it was checked to fail when that conjunct is forced false.
5 ⚠️ unique_key is named as gated but never given a nonempty value, so its guard has no oracle AGREE, fixed in this PR Confirmed, and I had raised the same gap independently. Covered in its own test file rather than in the main one: every UNIQUE KEY test needs several environment exclusion tags, and importing them would have removed the rest of the new test from those CI lanes.
6 ❌ The dictionary branch authorizes on the object the tables iterator captured, while the CREATE query is resolved again by name, so a name dropped as a dictionary and recreated as a regular table renders that table's DDL to a SHOW DICTIONARIES holder AGREE, fixed in this PR Confirmed by reading: IDatabase.cpp:271-275 renders from tryGetCreateTableQuery(name, ...), and the iterator snapshots the table map once per database per block (DatabasesCommon.cpp:562-567), so a late row can render well after its snapshot. SHOW CREATE DICTIONARY guards exactly this by validating kind and content in a single lookup. RenderedCreateQuery now carries whether the rendering is itself a CREATE DICTIONARY, and a rendering authorized only by SHOW DICTIONARIES is discarded unless it is. The race direction has no deterministic test without a new failpoint in this hot path; a mutation arm proves the guard is reached and does not blank genuine dictionary rows.
7 ❌ In a database with lazy_load_tables = 1, Alias definitions are wrapped in StorageTableProxy, so the alias-target SHOW COLUMNS conjunct never fires and the target's keys and index types are readable DISAGREE The mechanism is real: DatabaseOrdinary::shouldLazyLoad does not exclude Alias, as<T> is exact-typeid so a proxy never matches StorageAlias, and the materialized proxy forwards the nested alias's metadata, which is the target's. What it does not do is expose anything the interpreters withhold. InterpreterDescribeQuery.cpp:253-255 and InterpreterShowCreateQuery.cpp:166-173 run the identical as<StorageAlias>() on the storage returned by DatabaseWithOwnTablesBase::tryGetTable, which is the same registered proxy the iterator snapshots and is never unwrapped, so under that setting all three surfaces skip the target check alike and the parity this PR is about holds. The pre-existing can_expose_metadata target check has the same blind spot, and the new gate is strictly tighter than before even there, since it still requires table-level SHOW COLUMNS on the alias row itself. Fixing it here alone would make system.tables stricter than both interpreters. Disclosed as a pre-existing cross-surface issue, not changed here.
8 ⚠️ The new Required privileges documentation states the SHOW COLUMNS rule unconditionally, which the dictionary branch and the Alias target conjunct both contradict AGREE, fixed in this PR Correct, and I had raised the same gap independently. The page said those columns read as empty without SHOW COLUMNS, which stopped being true for a CREATE DICTIONARY row once finding 3 was fixed, and it never mentioned the Alias target requirement at all. Both are now stated, with the CREATE DICTIONARY versus ENGINE = Dictionary distinction explicit so the page cannot be read as covering the latter.
9 💡 Two flags in the new dictionary assertion are empty for any dictionary row regardless of privileges, so they cannot discriminate the branch AGREE, fixed in this PR Confirmed: StorageDictionary initializes only columns, comment and virtual columns, so it has no key expressions and no skip indices. The flags are kept, because they do pin that nothing starts emitting there, but the comment no longer attributes their zeros to the gate. The branch's width is proved by the create_table_query transition and the ENGINE = Dictionary control.
10 💡 SHOW INDEX degrades to one PRIMARY row with an empty column_name rather than to no row DISAGREE Already stated in the description: a keyless engine such as Memory yields that same row today for any user, so InterpreterShowIndexesQuery is deliberately left alone.
11 💡 can_show_columns is evaluated per row even when no gated column was selected DISAGREE The pre-existing can_expose_metadata immediately above it is equally unconditional, and the names-only listing path still short-circuits. No measurement supports a change.
12 💡 No opt-in server setting, although this area has precedent for one defaulting permissive DISAGREE Deliberate: #105367 carried pr-backward-incompatible with no flag and I committed to reproducing that choice. Happy to add one if you would rather it were opt-in.

| 13 | ⚠️ | The alias-target check is decided on the object the tables iterator captured while the CREATE query is resolved again by name, so a name snapshotted as an ordinary table and recreated as Alias(hidden) renders the alias definition without checking the target | DISAGREE | Every step of that is real; what it does not do is disclose anything about hidden beyond its name. Alias rejects explicit column definitions (StorageAlias.cpp:544-549, pinned by 03636_storage_alias_syntax.reference:43), so an alias's whole rendering is CREATE TABLE t ENGINE = Alias('hidden'), engine_full is the same expression and as_select is null. A target's name is SHOW TABLES-grade, and its guard here is the pre-existing can_expose_metadata target check, which is keyed on the same snapshot and is bypassed identically on master. The seven metadata columns this conjunct actually protects are read from the snapshotted storage, the same object identity the authorization used, so they are not in this window at all. The cheap remedy would also blank every lazily-loaded alias, since DatabaseOrdinary::shouldLazyLoad does not exclude Alias and such a row is a StorageTableProxy by design, making system.tables stricter than both SHOW CREATE TABLE and DESCRIBE. Disclosed as a residual of the snapshot-versus-name split, not changed. |
| 14 | ⚠️ | The temporary-table path has its own copy of the schema gate and no test creates a temporary Alias, so that conjunct could be hard-coded in either direction with the suite green | AGREE, fixed in this PR | Confirmed, and it is load-bearing rather than cosmetic: StorageAlias::getInMemoryMetadataPtr forwards to the target's metadata, so skipping_indices_types and parameterized_view_parameters on such a row are the target's. Covered by a new test that keeps one HTTP session alive across the grant, the read, the revoke and the read again, which is deterministic and needs no timing window; both directions are proved by forcing the conjunct true and false. |
| 15 | ⚠️ | loading_dependencies_* is filtered in its own loop and only its hidden element is asserted, so dropping every element for a restricted user would keep the suite green | AGREE, fixed in this PR | Confirmed: the two loading arrays are two separate loops, and only the dependents direction had a positive assertion. The dependencies direction now asserts that a visible same-database dependency survives for the restricted user, and the fixture already proved that edge exists through the reciprocal assertion on the other side. |
| 16 | 💡 | The restoration instruction names only SHOW COLUMNS on the row's table, which does not restore an Alias row's schema or the filtered dependency names | AGREE, fixed in this PR | Correct, and it is the one sentence an operator acts on. The changelog entry now also names SHOW COLUMNS on an Alias target and SHOW TABLES on the tables the dependency columns name, matching what the documentation page already said. |

| 17 | ⚠️ | The temporary-table path applies the schema gate a third time when filling parameterized-view metadata, and no test selects that column for a temporary Alias, so removing the guard from that one call would keep the suite green | AGREE, fixed in this PR | Confirmed, and it is the per-site gap the previous round's conjunct-level fix left behind: the two mutation arms there hard-code the whole conjunct, so they redden through create_table_query and skipping_indices_types and say nothing about this call. The column is not incidental, because StorageAlias::getInMemoryMetadataPtr forwards to the target's metadata, so such a row emits the target view's parameter names and types, which this PR's own changelog and documentation both put behind SHOW COLUMNS, and which InterpreterDescribeQuery gates on the same privilege. An Alias over a parameterized view is already exercised on master, so the fixture is constructible; the existing temporary-alias test gains a second alias whose target is a parameterized view, and the guard is proved live by removing it from that one call and observing only the new assertion move. |
| 18 | 💡 | The linked pull request appears as a full URL only inside the template's HTML comment, so it does not render; make the visible line a full URL | DISAGREE, then reversed | The relationship is recorded as a full URL exactly where the template asks for one, in the commented links block, which is filled verbatim after deleting the unused line, and that is the shape two of my own merged pull requests shipped in. The visible Related: #105367 is not a non-rendering artifact either: it renders as a working link and creates the cross-reference, which is the point of keeping it outside the comment. Substituting a bare URL changes nothing a reader or GitHub does with it. I reversed this a round later anyway, on my own review rather than the gate's: the repository's own rulebook asks for full GitHub URLs one relationship per line, which outranks my budget argument, and GitHub renders a same-repo full URL as #105367 so the visible line is unchanged. The visible line is now the full URL. |
| 19 | 💡 | The residual disclosure names an expr column on all three sibling system tables, but only one of them has a column by that name | AGREE, fixed in this PR | Raised by my own cold review. system.data_skipping_indices has expr, while system.projections has query and system.constraints has expression. The residual class is real and worth stating, so the sentence now says each exposes a definition naming columns, which is true of all three. |
| 20 | 💡 | The information_schema documentation page does not mention that view_definition now needs SHOW COLUMNS | Noted, not changed | Raised by my own cold review. The page states no privilege rule that this change falsifies, the changelog entry carries the operator-facing statement, and the localized copies of that page are generated output. Adding a privileges section to a second documentation page is scope I would rather you asked for than assume. |
| 21 | ⚠️ | 05057 creates two temporary Alias tables as a restricted user without granting TABLE ENGINE ON Alias, which the functional-test configuration enforces | AGREE, fixed in this PR | Confirmed by reading, and it was a certain red on our own new test rather than a style point. InterpreterCreateQuery::getRequiredAccess has no early return for temporary tables: after the isTemporary branch appends CREATE ARBITRARY TEMPORARY TABLE, control falls through to the TABLE ENGINE entry, and getTablePropertiesAndNormalizeCreateQuery re-checks it after setEngine. It is enforced when table_engines_require_grant is set, which tests/config/config.d/enable_access_control_improvements.xml does and tests/config/install.sh links into every functional-test server, so both CREATE TEMPORARY TABLE statements would have failed under CI while passing against a plain local server. 03636 already grants the same privilege for the same engine and user shape, and 02561 shows it applies to the temporary path. The grant is added and the reference is unchanged. The general lesson is ours, not ClickHouse's: a plain repro server enforces none of the access-control switches the stateless-test overlay turns on, so every validation from this round on runs against that overlay. |
| 22 | ⚠️ | 05055 asserts only target_database on the materialized-view target pair, so filtering one half and not the other would keep the reference green | AGREE, fixed in this PR | Confirmed. target_database and target_table are filled by two separate inserts, and the unfiltered one would be the table name, which is the thing being withheld. The probe now asserts both halves in the restricted arm and in the administrator arm, so the fixture is shown to populate them before the restricted arm reads them. Proved live: filtering target_database but not target_table fails the test on exactly one line and leaves the other three tests green, while the pre-target_table version of the test passes under that same mutation. |
| 23 | ⚠️ | The post-render dictionary revalidation has no live oracle: the committed tests use stable object kinds, so deleting it leaves every reference unchanged | AGREE, satisfied | A verification ask, not a defect claim -- the guard itself is finding 6, already implemented. The ask is genuine: the earlier mutation arm proved the branch is on the executed path and that a real dictionary rendering sets the flag, but not that deleting the guard lets a replacement table's DDL through. There is no deterministic non-race way to reach that state, because the only object satisfying the configuration test is one whose tryGetCreateTableQuery returns a CREATE DICTIONARY by construction. So it was answered by measurement rather than by argument -- see the next row. |
| 24 | ⚠️ | Same ask, raised a third time on unchanged code | AGREE, satisfied by measurement | A window was injected between the privilege decision and the rendering. A user holding SHOW TABLES on the database plus SHOW DICTIONARIES on the object and no SHOW COLUMNS -- asserted per run, SHOW CREATE TABLE refused and SHOW CREATE DICTIONARY accepted -- read create_table_query while an administrator exchanged a regular table into the dictionary's name. With the guard present the column came back empty; with its two lines deleted the same read returned CREATE TABLE armdb.x (secret String) ENGINE = Memory. A no-swap control on both arms returned the dictionary's own CREATE DICTIONARY text, so the withheld result is withholding and not a blanket blank, and all four runs logged that the dictionary disjunct was what authorized the rendering. Two harness defects were found and fixed before the result was believed: DROP plus CREATE blocks on the parked scan, so the swap landed after the window closed and the empty read was really the name-absent case -- replaced with an atomic EXCHANGE TABLES whose interleaving is now measured, not assumed -- and attribution by position had been picking up the administrator's own verification query. No committed failpoint: it would mean test-only production code in this path and a test that waits on a server-global failpoint. Say so if you would rather have the failpoint and the test, and I will add them. |
Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are
terminal per finding.

Session id: cron:clickhouse-review-slot-11:20260901-032500

@clickhouse-gh clickhouse-gh Bot closed this Sep 1, 2026
@clickhouse-gh clickhouse-gh Bot reopened this Sep 1, 2026
@clickhouse-gh

clickhouse-gh Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [c920b53]

Summary: ✅


AI Review

Summary

This PR tightens system.tables so schema-revealing columns require SHOW COLUMNS, filters dependency/target-name columns by SHOW TABLES, and adds strong focused stateless coverage for those paths. The remaining problem is an access-control TOCTOU on the persisted-table path: authorization is computed from the snapshotted storage, but create_table_query / engine_full are then rendered by re-resolving the current name, so a concurrent regular-table → Alias swap can still bypass the alias-target SHOW COLUMNS check and disclose hidden metadata. Because that is a live privilege leak, I cannot approve this yet.

Findings
  • ❌ Blockers
  • [src/Storages/System/StorageSystemTables.cpp:661] The persisted-table path still authorizes Alias metadata on the snapshotted storage object, then renders create_table_query / engine_full from database->getRenderedCreateTableQuery(table_name, ...) after re-resolving the current name at src/Storages/System/StorageSystemTables.cpp:784. If the row is snapshotted as a regular table and recreated as ENGINE = Alias(hidden) before that render, can_show_declared_columns stays true because the old object was not an Alias, so the alias-target SHOW COLUMNS check never runs for the new object. engine_full then leaks the hidden target name, and create_table_query can leak the persisted alias schema even though SHOW CREATE TABLE on the current object would withhold it.
  • Suggested fix: revalidate rendered Alias definitions against the current object before emitting them, the same way this patch already revalidates dictionary renderings, or derive the alias-target authorization from the persisted CREATE AST that is actually being rendered. Please also add a focused regression test that swaps a row from a regular table to ENGINE = Alias(...) between snapshot and render and asserts the gated columns stay empty.
Final Verdict
  • Status: ❌ Block
  • Minimum required actions: close the persisted-table Alias TOCTOU for create_table_query / engine_full, and add a regression test for that swap.

@clickhouse-gh clickhouse-gh Bot added the pr-backward-incompatible Pull request with backwards incompatible changes label Sep 1, 2026
@groeneai

groeneai commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate
# Check Result
a Deterministic repro? Yes. GRANT SELECT(public_col) ON db.secret then SELECT create_table_query, partition_key, primary_key FROM system.tables WHERE database = 'db' AND name = 'secret' returns the full DDL on an unpatched build of the same base and empty strings on this branch. No randomization, no timing, 100% on demand. Covered by 05055_system_tables_show_columns_leak.
b Root cause explained? Yes. A column-level grant is promoted to table-level SHOW_TABLES (ContextAccess.cpp, the leaf_or_wildcard clause), so the row passes the row filter, while table-level SHOW_COLUMNS is min_flags_with_children, i.e. "on every column", and stays false. TablesBlockSource::generate derived only the SHOW_TABLES decision and filled every schema column unconditionally.
c Fix matches root cause? Yes. The missing access decision is added where the columns are filled, gating on the same privilege the interpreters already require. No widened bound, no suppression, no defensive check at a symptom site.
d Test intent preserved / new tests? Yes. No test is weakened. 03636's two changed assertions were pinning the leak; they now assert the gated values and gain a paired SHOW CREATE TABLE -> ACCESS_DENIED assertion, so the reference proves the two surfaces agree rather than merely recording new numbers. 03636 also gains the granted-state row for an Alias, so the target-privilege conjunct is observed in both states. New tests 05055, 05056 and 05057. 05057 covers the temporary/external-table copy of the gate, which no test reached before: it creates a temporary Alias inside one HTTP session, reads the row, has an administrator revoke SHOW COLUMNS on the target between two requests of that session, and reads it again. It builds two such aliases, one over a MergeTree and one over a parameterized view, so each of the three columns that branch gates has its own assertion. 05055 also gained the visible half of loading_dependencies_*, whose two loops previously had only a hidden-element assertion, and now asserts target_table next to target_database: the two are filled by separate inserts, so filtering one and not the other left the reference green, and the unfiltered one would have been the table name. 05057 grants TABLE ENGINE ON Alias, which the functional-test configuration requires for an explicit engine independently of CREATE ARBITRARY TEMPORARY TABLE.
e Both directions demonstrated? Yes, and every guard is mutation-checked rather than assumed. 05055 passes on this branch and fails on an unpatched build of the same base, with the diff confined to the predicted positions. Three single-site mutations were built and run as servers: forcing the Alias target conjunct false turns 03636's granted row from 1 1 1 1 1 1 1 to all zeros and nothing else; removing the can_show_columns guard from the unique_key site alone turns 05056's restricted arm from 0 to 1; substituting isDictionary() for the configuration test turns 05055's ENGINE = Dictionary control from 0 to 1, disclosing that table's column list; and forcing the rendered query's is_dictionary flag false turns 05055's granted dictionary arm from 1 0 0 to 0 0 0 on exactly one line, leaving the other two tests green. The temporary path's copy of the guard is pinned at each of the three sites it controls. Forcing it false turns 05057's granted arm from 1 1 1 / 1 1 to 0 0 1 / 0 1, so every column it gates there responds. Removing the conjunct from the parameterized_view_parameters site alone turns the withheld arm's second line from 0 1 to 1 1 and leaves the first line and the granted arm untouched, so no one of the three can be deleted silently; each gated column holds its own position in the reference. The other three tests stay green in both arms. Dropping every loading dependency for a restricted user turns 05055's new visible-dependency line from 1 to 0 and leaves its administrator line at 1; the same binary leaves the suite green when that one assertion is removed, which is why it was added. Filtering target_database but not target_table fails 05055 on exactly one line, the restricted arm's hidden_target_* pair (0 0 -> 0 1), and leaves the other three tests green; the pre-target_table version of 05055 passes under that same mutation, which is why the assertion was added. The re-resolution guard is demonstrated directly rather than argued: with a delay injected between the privilege decision and the rendering, a user holding SHOW DICTIONARIES but not SHOW COLUMNS reads an empty create_table_query while a replacement regular table is exchanged into the dictionary's name, and reads that table's full DDL once the two guard lines are deleted. A no-swap control on both arms returns the dictionary's own CREATE DICTIONARY text, so the withheld result is not a blanket blank. Every mutation was measured against the final text of the tests, and each revert rebuilds deterministically (two independent rebuilds of the reverted source produce the same build ID).
f General across code paths? Yes. Both fill paths are gated and both are now observed by a test, the main loop and the temporary/external-table branch. All eight columns naming another table are filtered by one shared predicate, so no sibling array was left behind. InterpreterShowCreateQuery authorizes a CREATE query with two privileges, SHOW DICTIONARIES for a dictionary and SHOW COLUMNS otherwise, so the rendered-CREATE trio mirrors both branches; the other gated columns stay on SHOW COLUMNS, matching DESCRIBE. fillTableNamesOnly emits only database and name and needs no gate. system.detached_tables carries no DDL column. Because the rendering re-resolves the table by name after the privilege is decided, the emitted rendering is itself checked to be a CREATE DICTIONARY before the SHOW DICTIONARIES branch may emit it.
g Generalizes across inputs? The gate is an access decision, not a data-type path, so type wrappers do not apply. The grant-shape matrix is covered instead: column-scoped SELECT, explicit SHOW COLUMNS, table-level SELECT (which implies SHOW COLUMNS), SHOW TABLES only, and SHOW DICTIONARIES. The third arm is the over-tightening guard and the second is the oracle-sensitivity control; both pass identically on base and on this branch. The object-kind matrix is covered too: a CREATE DICTIONARY object opens to SHOW DICTIONARIES, while a plain table declared ENGINE = Dictionary holding the same privilege stays closed, which is what SHOW CREATE TABLE does for it. Array index alignment is asserted for all three pairs.
h Backward compatible? Deliberately not, matching the pr-backward-incompatible label on #105367; the changelog category is Backward Incompatible Change. No setting default changes, so no SettingsChangesHistory.cpp entry, and no serialization format changes. Recovery is GRANT SHOW COLUMNS ON db.t TO user.
i Invariants and contracts preserved? Yes. res_index and src_index advance on every path, so the emitted block keeps its declared structure whether or not access is granted; a denied column inserts its default rather than being skipped. Both halves of every name pair are skipped together, preserving the index alignment programs/server/schema.html relies on. The new decision is computed before the table lock is taken, so it cannot diverge across the continue that a failed lock takes. Denial renders a default instead of throwing, so SELECT * FROM system.tables still succeeds for a restricted user.

Also verified, on a server carrying the stateless-test configuration overlay that CI installs rather than a plain one: AccessRights* unit tests 34/34; the style checks, each with a deliberate violation confirming the relevant check is sensitive to these files; 16/16 single runs of the four tests; 200/200 randomized runs (--test-runs 50) across them; and 8/8 for each new test plus 32/32 for all four together across 8 concurrent workers, so none of them needs no-parallel. 05056 omits no-fasttest because it never inserts: 04657, which also creates a UNIQUE KEY table without inserting, records 16850 passes in Fast test over 30 days, while the inserting 04046 is skipped there. 05057 carries no tag either, matching 03636 and 04212, which likewise create users and grants and drive HTTP requests as a non-default user. Every regression test that fails does so for a sandbox reason confirmed on an unpatched master build of the same base: S3 server credentials, a hardcoded /var/lib/clickhouse/user_files path, a missing test_shard_localhost cluster, a missing shard macro with no ZooKeeper, and an intermittent draw of a parallel_replicas cluster that a bare configuration does not define, which was observed on the unpatched build as well.

@groeneai

groeneai commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator Author

cc @alexey-milovidov @vitlibar, could you review this? It re-introduces the gate from #105367: the columns of system.tables that describe a table's schema now require table-level SHOW COLUMNS, which a column-level grant such as GRANT SELECT(col) does not imply, and the eight columns that name another table are filtered per element by SHOW TABLES on the table named. Backward incompatible by design, matching the label on #105367, and the adjudication comment leaves two calls to you: whether it should instead be opt-in, and whether the dictionary re-resolution guard should carry a committed failpoint test.

@clickhouse-gh

clickhouse-gh Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing c920b53d6 with master 18b5a991f (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

9 translation units recompiled, 22 s compile time in total, 9 of them have a recent master baseline.

Job report

@groeneai

groeneai commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - fa4f036

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Docs examples / Documentation examples date-dependent doc example, not a code regression: src/Functions/toYYYYMM.cpp documents SELECT toYYYYMM(now(), 'US/Eastern') with a hardcoded 202608, so it self-broke at the September 1 month rollover. The onset time is the proof: first CIDB row 2026-09-01 04:10:16Z, which is midnight in the documented zone rather than 00:00 UTC #117459 (ours, open)
Integration tests (amd_asan_ubsan, db disk, old analyzer, 6/6) / Container memory budget exceeded (/docker) the shard's nested containers breach the /docker cgroup leaf, so the kernel kills processes inside it and the job errors with no test attributed. 678 rows over 318 distinct pull requests in 30 days, including 45 on master, onset 2026-08-30 #117411 / #117412 (external, open)
Integration tests (amd_asan_ubsan, db disk, old analyzer, 6/6) / test_polymorphic_parts/test.py::test_polymorphic_parts_index killed node, same shard and same run as the /docker budget breach: Code: 209. DB::NetException: Timeout: connect timed out: 172.16.1.12:9000 (SOCKET_TIMEOUT) against the node address, so the server was killed under test_polymorphic_parts_index rather than failing it. 5 rows over 4 distinct pull requests in 30 days, onset 2026-08-30, tracking the budget breaches #117411 / #117412 (external, open)
Integration tests (amd_asan_ubsan, db disk, old analyzer, 6/6) / test_polymorphic_parts/test.py::test_polymorphic_parts_non_adaptive killed node, same shard and same run as the /docker budget breach: Code: 209. DB::NetException: Timeout: connect timed out: 172.16.1.12:9000 (SOCKET_TIMEOUT) against the node address, so the server was killed under test_polymorphic_parts_non_adaptive rather than failing it. 5 rows over 4 distinct pull requests in 30 days, onset 2026-08-30, tracking the budget breaches #117411 / #117412 (external, open)
Integration tests (amd_tsan, 2/6) / test_storage_nats/test_nats_jet_stream.py::test_nats_jet_stream_settles_after_one_broker_restart JetStream consumption does not resume after a broker restart: AssertionError: consumption did not resume, view holds 10 of 20 keys. Nothing in this diff touches NATS. 7 rows over 6 distinct pull requests in 30 days, 0 on master, first seen 2026-08-14 #115343 (external, open)
Integration tests (amd_tsan, 2/6) / test_storage_nats/test_nats_jet_stream.py::test_block_based_formats_1 cascade of the silent subscription above, not an independent defect: it leaves the module teardown's DROP DATABASE test failing, so this test dies in nats_setup_teardown at DROP DATABASE IF EXISTS test SYNC before its own body runs #115343 (external, open)
Integration tests (amd_tsan, 2/6) / test_storage_nats/test_nats_jet_stream.py::test_block_based_formats_2 cascade of the silent subscription above, not an independent defect: it leaves the module teardown's DROP DATABASE test failing, so this test dies in nats_setup_teardown at DROP DATABASE IF EXISTS test SYNC before its own body runs #115343 (external, open)
Integration tests (amd_tsan, 2/6) / test_storage_nats/test_nats_jet_stream.py::test_format_with_prefix_and_suffix cascade of the silent subscription above, not an independent defect: it leaves the module teardown's DROP DATABASE test failing, so this test dies in nats_setup_teardown at DROP DATABASE IF EXISTS test SYNC before its own body runs #115343 (external, open)
Integration tests (amd_tsan, 2/6) / test_storage_nats/test_nats_jet_stream.py::test_hiding_credentials cascade of the silent subscription above, not an independent defect: it leaves the module teardown's DROP DATABASE test failing, so this test dies in nats_setup_teardown at DROP DATABASE IF EXISTS test SYNC before its own body runs #115343 (external, open)
Integration tests (amd_tsan, 2/6) / test_storage_nats/test_nats_jet_stream.py::test_max_rows_per_message cascade of the silent subscription above, not an independent defect: it leaves the module teardown's DROP DATABASE test failing, so this test dies in nats_setup_teardown at DROP DATABASE IF EXISTS test SYNC before its own body runs #115343 (external, open)
Integration tests (amd_tsan, 2/6) / test_storage_nats/test_nats_jet_stream.py::test_nats_bad_args cascade of the silent subscription above, not an independent defect: it leaves the module teardown's DROP DATABASE test failing, so this test dies in nats_setup_teardown at DROP DATABASE IF EXISTS test SYNC before its own body runs #115343 (external, open)
Integration tests (amd_tsan, 2/6) / test_storage_nats/test_nats_jet_stream.py::test_nats_drop_mv cascade of the silent subscription above, not an independent defect: it leaves the module teardown's DROP DATABASE test failing, so this test dies in nats_setup_teardown at DROP DATABASE IF EXISTS test SYNC before its own body runs #115343 (external, open)
Integration tests (amd_tsan, 2/6) / test_storage_nats/test_nats_jet_stream.py::test_nats_format_factory_settings cascade of the silent subscription above, not an independent defect: it leaves the module teardown's DROP DATABASE test failing, so this test dies in nats_setup_teardown at DROP DATABASE IF EXISTS test SYNC before its own body runs #115343 (external, open)
Integration tests (amd_tsan, 2/6) / test_storage_nats/test_nats_jet_stream.py::test_nats_jet_stream_resumes_consuming_multiple_subjects_after_broker_restart cascade of the silent subscription above, not an independent defect: it leaves the module teardown's DROP DATABASE test failing, so this test dies in nats_setup_teardown at DROP DATABASE IF EXISTS test SYNC before its own body runs #115343 (external, open)
Integration tests (amd_tsan, 2/6) / test_storage_nats/test_nats_jet_stream.py::test_nats_no_connection_at_startup_1 cascade of the silent subscription above, not an independent defect: it leaves the module teardown's DROP DATABASE test failing, so this test dies in nats_setup_teardown at DROP DATABASE IF EXISTS test SYNC before its own body runs #115343 (external, open)
Integration tests (amd_tsan, 2/6) / test_storage_nats/test_nats_jet_stream.py::test_nats_no_connection_at_startup_2 cascade of the silent subscription above, not an independent defect: it leaves the module teardown's DROP DATABASE test failing, so this test dies in nats_setup_teardown at DROP DATABASE IF EXISTS test SYNC before its own body runs #115343 (external, open)
Integration tests (amd_tsan, 2/6) / test_storage_nats/test_nats_jet_stream.py::test_nats_predefined_configuration cascade of the silent subscription above, not an independent defect: it leaves the module teardown's DROP DATABASE test failing, so this test dies in nats_setup_teardown at DROP DATABASE IF EXISTS test SYNC before its own body runs #115343 (external, open)
Integration tests (amd_tsan, 2/6) / test_storage_nats/test_nats_jet_stream.py::test_row_based_formats cascade of the silent subscription above, not an independent defect: it leaves the module teardown's DROP DATABASE test failing, so this test dies in nats_setup_teardown at DROP DATABASE IF EXISTS test SYNC before its own body runs #115343 (external, open)

Note for anyone re-checking this against gh pr checks or the report page. This commit has two
parallel PR workflow runs, created 9 seconds apart, and each ran the whole matrix. Three
further failure rows in the CI database belong to the losing run and are deliberately not owned
above, because those legs never executed a test: AST fuzzer (amd_debug, targeted),
AST fuzzer (amd_debug, targeted, old_compatibility) and
Stateless tests (amd_debug, flaky check) each died after 22 to 24 seconds with the step list
Set up job / Checkout code / Prepare env script green and Run failed, inside praktika's
pre-run artifact fetch: PreconditionFailed on GetObject for
PRs/117448/fa4f03609a19645e0150c284627af6c6e6003952/pr/build_amd_debug/clickhouse, surfacing as
S3DownloadFailedError from ci/praktika/s3.py. Both runs write that same key, so the loser's
ETag precondition failed against a binary the other run had just overwritten. Each of those three
contributes a job-level row only and no test-level row at all. The same three job names ran to
completion in the surviving run and all passed, taking 1892 to 1954 seconds, with the flaky check
reporting Failed: 0, Passed: 200, Skipped: 0. result_pr.json belongs to whichever run finished
last, so it shows those three as OK and shows the reds owned above.

Session id: cron:our-pr-ci-monitor:20260901-093000

@clickhouse-gh clickhouse-gh Bot added the comp-system-table system.* tables (introspection, system metadata, performance visibility). label Sep 4, 2026
…les-show-columns-gate

Conflicts in the 03636 pair only, both from the split that landed with ClickHouse#117490:
the "database-level access shortcuts" section moved out to
03636_storage_alias_metadata_database_grants and a "CREATE TABLE ... AS an Alias"
section took its place. Kept master's new section and this branch's
"table and persisted metadata with target permission" block, which asserts the
seven flags come back once the target grants SHOW COLUMNS.
Comment thread docs/reference/system-tables/tables.mdx Resolved
The dictionary probe asserted only create_table_query, so nothing pinned
whether the exception carried by can_show_create_query also emits the other two
rendered columns. It does not: engine_full is rendered from
ASTCreateQuery::storage and as_select from its select node, and
ParserCreateDictionaryQuery sets neither, so a CREATE DICTIONARY row reads both
as empty for every reader, including one holding every privilege.

Add engine_full to both selects and run the probe as admin first. That arm is
the ceiling: local_dict reads engine_full 0 there, so no grant can widen it,
while dict_engine_tbl reads 1, which is what makes the zeros in the two
restricted arms withholding rather than a structurally empty column. The
dict_engine_tbl control previously asserted only create_table_query and could
have agreed for the wrong reason.
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - ddff9e9

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task whose
fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Stress test (arm_debug) / Logical error: Unexpected return type from A. Expected B. Got C (STID: 3262-3243) logical error, not caused by this PR: arrayElement over a LowCardinality JSON path infers LowCardinality(Nullable(UInt32)) but returns LowCardinality(UInt32), and columnMatchesType aborts on the mismatch. 23 occurrences across 23 distinct pull requests plus 1 master run in 30 days, across 9 check flavours #119892 (mine, open)
AST fuzzer (amd_release, oracle) TLP Aggregate oracle mismatch, not caused by this PR: count() IGNORE NULLS over a STREAM BOUNDED CURSOR read is answered from part metadata, so the reference and metamorphic rewrites disagree. 86 job-level errors across 84 distinct pull requests plus 2 master runs in 30 days #117188 (mine, open)
Build profile diff infra: the CI logs cluster read raises inside has_pr_data, so the job aborts with a traceback instead of degrading to "no baseline" #120121 (mine, open)

Mergeable Check and PR are also red, with no independent failure of their own: they are aggregators
that roll up the three rows above, so they carry no separate owner.

This PR touches src/Databases/RenderedCreateQuery.{h,cpp}, src/Storages/System/StorageSystemTables.cpp,
one docs page and four stateless tests. None of the three failures is on that surface: the first two are
analyzer and storage read-path defects reproduced on unrelated schemas, and the third is a CI job talking to
the logs cluster. So nothing here is PR-caused.

Session id: cron:our-pr-ci-monitor:20260916-200109

/// The dictionary disjunct is decided on the object the iterator captured, while
/// the rendering resolves the name again. Emit it only when that one rendering is
/// itself a dictionary, as `SHOW CREATE DICTIONARY` requires.
if (!can_show_columns && !rendered->is_dictionary)

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.

The dictionary TOCTOU is closed here, but the same authorize-on-snapshot / render-by-name split still exists for Alias. can_show_columns was computed from tables_it.table() earlier, so if this row is snapshotted as a regular table and then recreated as ENGINE = Alias(hidden) before getRenderedCreateTableQuery runs, the rendered DDL now comes from the alias while the alias-target SHOW COLUMNS check never runs. SHOW CREATE TABLE on the current object would deny the same user, but system.tables.engine_full still leaks the hidden target name, and create_table_query can leak the persisted alias schema.

Please revalidate rendered Alias definitions against the current storage before emitting them, mirroring the dictionary revalidation in this block, and add a focused race/failpoint regression test for the swap.

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 88cc3d3

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task whose
fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Upgrade check (amd_release) / Error message in clickhouse-server.log (see upgrade_error_messages.txt) the check randomizes Keeper feature flags, and the drawn set omits ones transactions require, so AsyncLoader logs Code: 344. Transactions require Keeper to advertise LIST_WITH_STAT_AND_DATA, FILTERED_LIST, MULTI_READ and CHECK_STAT feature flags while attaching a plain MergeTree table, and the job's <Error> log grep reports it. Not from this diff, which touches RenderedCreateQuery, StorageSystemTables, one docs page and four stateless tests: signature-scoped census over 2 days gives 22 distinct pull requests and 0 true-master runs, essentially all on this one check, onset 2026-09-18 12:00Z #120932 (mine, open)
Performance Comparison (arm_release, master_head, 5/6) measurement run, not a regression of this diff: the job-level summary is 10 errors, 3 too long, 1 unstable while every per-query row on the shard is success or unstable. The shard went from about 1 red/day to 163 reds on 2026-09-18, starting right after #120176 merged at 21:10Z, and it is red on master too #120923 (external, open)
Build profile diff infra: RuntimeError: CI logs cluster query failed, raised in Db.query at ci/jobs/build_profile_diff_job.py:234 from compare_symbols, so the job aborts with a traceback instead of degrading to "no baseline". 74 distinct pull requests carry the identical traceback in the last 24 hours #118708 (mine, open)
Mergeable Check, PR praktika rollups of the three rows above, no independent failure of their own #120932 (mine, open), #120923 (external, open) and #118708 (mine, open)

176 check runs finished as 152 success, 19 skipped, 5 failures, and the head-scoped CIDB read over
310,346 ingested rows returns exactly one FAIL test row, the Upgrade check log-grep leaf above, so
neither of the other two failing jobs carries a failing test of its own.

Session id: cron:our-pr-ci-monitor:20260919-053557

Comment thread docs/reference/system-tables/tables.mdx Resolved
Since cb5903b the whole body of docs/reference/system-tables/tables.mdx is
generated from the system.tables comment in src/Storages/System/attachSystemTables.cpp,
so the hand-written "Required privileges" section landed inside the generated
region and failed the Docs check. Moving it into that comment would also require
regenerating the page in this PR, which the docs guard accepts only with the
pr-autogenerated-docs label. The changelog entry documents the new requirement.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
groeneai and others added 2 commits September 26, 2026 03:50
The system.tables row filter runs before the dictionary exception is
consulted, and SHOW DICTIONARIES does not imply SHOW TABLES, so a user
holding only SHOW DICTIONARIES gets no row for the dictionary at all. The
comment claimed that privilege alone makes the CREATE query readable. This
PR does not change row visibility, so narrow the comment, not the filter.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
dep_user held SHOW TABLES on the whole database and every withheld dependency
lived in another database, so replacing the per-table check in
is_dependency_visible with a database-level one kept 05055 green. Grant SHOW
TABLES on secret and dep_view only, and assert that dep_view stays in
secret's dependencies_table while mv_local, which depends on secret from the
same database, is dropped. The database-level variant now fails on exactly
that line.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Dear @pufit, 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 and others added 2 commits October 10, 2026 11:58
…solete

Since ClickHouse#115141, `SHOW CREATE TABLE` (and `SHOW CREATE TEMPORARY TABLE`) of an
`Alias` no longer throws `ACCESS_DENIED` without `SHOW COLUMNS` on the target;
it strips the inlined columns instead. `03636_storage_alias_metadata_access_rights`
and `05057_system_tables_temporary_alias_show_columns` asserted that refusal next
to the withheld `system.tables` columns, so after the master merge both failed on
exactly that line. Remove the two assertions and their comments, as ClickHouse#115141 did
for the same cases in master's copies of the 03636 tests.

The `system.tables` gate itself is unchanged. `create_table_query` is read from the
stored definition and is not stripped: an `Alias` stored by an older server still
returns the target's columns there (measured: `ATTACH TABLE ... (id UInt64, secret
String) ENGINE = Alias(...)` shows both columns in `create_table_query`, while
`SHOW CREATE TABLE` prints none). So the declared-target `SHOW COLUMNS` check still
protects those definitions; the two comments that justified it by parity with
`SHOW CREATE TABLE` now state that reason instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member

close the persisted-table Alias TOCTOU for create_table_query / engine_full

Out of scope. The fix is already good enough.

@alexey-milovidov alexey-milovidov self-assigned this Oct 16, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 16, 2026
Merged via the queue into ClickHouse:master with commit 9e48032 Oct 16, 2026
163 checks passed
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-system-table system.* tables (introspection, system metadata, performance visibility). groeneai-origin-request PR origin: a maintainer pinged or directed groeneai pr-backward-incompatible Pull request with backwards incompatible changes pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants