Repository navigation
Conversation
The hosts of `RESTORE ... ON CLUSTER` run the internal restore with no user, so
the only check that runs as the user is the `CHECK_ACCESS_ONLY` preflight on the
initiator. It required `CREATE TABLE` / `CREATE VIEW`, `INSERT` and the export
grants, but not the `TABLE ENGINE` grant that a local `RESTORE` checks when it
creates the table and, for a view, its inner table. For a source engine such as
`File` that grant is implied only by `READ` / `WRITE` on the source, so a user
without any `FILE` grant, refused a local restore of an `ENGINE = File` table,
could restore it `ON CLUSTER` and read and write the server file through it
(measured on 26.10.2.103 and master).
The preflight now requires `TABLE ENGINE` on the table's engine and on every
inner engine of `create.targets` (the walk `getExportAccess` already does there,
and the element `CREATE ... ON CLUSTER` requires on its initiator), in
`CHECK_ACCESS_ONLY` mode only: a local restore already checks the engine it
actually creates. `restore_replace_external_engines_to_null` does not exempt the
engine on this path, because the hosts may not apply the initiator's value.
Grants checked inside a storage creator (e.g. the `File` delegate of
`URL('file://...')`) stay unchecked on the hosts, as for `CREATE ... ON CLUSTER`,
until the hosts run as the initiating user.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 1 finding).
Severity: ❌ blocker / Session id: cron:clickhouse-review-self-slot-58:20261105-115200 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-self-slot-57:20261105-100900 |
|
cc @pufit @pamarcos, could you review this and add the |
|
Workflow [PR], commit [1b0827e] Summary: ✅
AI ReviewSummaryPR #129468 adds initiator-side Final VerdictStatus: ✅ Approve. |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 13 s compile time in total, 7 of them have a recent master baseline. |
…flight With `restore_replace_external_engines_to_null`, the hosts of `RESTORE ... ON CLUSTER` replace an external engine, of the table or of a view's inner table, with `Null`, as a local restore does. The preflight now requires `TABLE ENGINE ON Null` for such an engine instead of the grant for the engine named in the backup, so a user who may restore the table locally is no longer refused on the cluster. Only a value in the `SETTINGS` clause of the `RESTORE` is trusted: it is sent in the query text, and a host applies it or fails the restore. A session value travels in the distributed DDL entry, which a host clamps to its own constraints and which an entry of `distributed_ddl_entry_format_version = 1` does not carry at all (measured: with a session value at format 1 the hosts created a `File` table), so for it the preflight still requires the engine named in the backup. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Since ClickHouse#129468 the initiator of `RESTORE ... ON CLUSTER` asks `TABLE ENGINE ON Null` for a source-backed table that every host replaces by `Null`. The last case of 05569 tests that a value of `restore_replace_external_engines_to_null` in the query lifts the export settings of such a table, so its user now also needs that grant; the case and its reference are otherwise unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Post-merge note: this fix (merge commit 9565f05) is not on 26.3, 26.8, 26.9 or 26.10, and no backport PR exists. The bypass was measured on 26.10.2.103 (see the description). If it should reach the release branches, the robot needs a |
Related: #113073
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed
RESTORE ... ON CLUSTERnot checking theTABLE ENGINEgrant for the engines of the restored tables and of the inner tables of materialized views, so a user without the grant could restore, for example, aFiletable and read the server file through it. Such a restore now needs the same grant asRESTOREwithoutON CLUSTER, e.g.GRANT TABLE ENGINE ON FileorGRANT READ, WRITE ON FILE.Description
On 26.10.2.103, a user without any
FILEgrant who is refusedRESTORE TABLE db.t FROM Disk('backups', 'b')of anENGINE = File(...)table (Code: 497 ... TABLE ENGINE ON File) can run the same restore withON CLUSTER test_shard_localhost, get the table, and read the file.Root cause: the hosts of
RESTORE ... ON CLUSTERrun the internal restore with no user, so the only check that runs as the user is the preflightRestorerFromBackup::checkAccessForObjectsFoundInBackupinCHECK_ACCESS_ONLYmode on the initiator. It requiresCREATE TABLE/CREATE VIEW,INSERTand the export grants, but not theTABLE ENGINEgrant that a local restore checks when it creates the table. For a source engine such asFile, that grant is implied only byREAD/WRITEon the source, so this is reachable on the default configuration.Change: in
CHECK_ACCESS_ONLYmode, requireTABLE ENGINEon every engine the hosts will create (the table's engine and each inner engine), the same element asCREATE ... ON CLUSTERrequires. Withrestore_replace_external_engines_to_nullin theSETTINGSof theRESTORE, an external engine becomesNullon the hosts, which needsTABLE ENGINE ON Null, as locally; a session value is not trusted, as a host may clamp it. A localRESTOREis unchanged.Grants checked inside a storage creator (e.g. the
Filedelegate ofURL('file://...')) remain unchecked on the hosts, as forCREATE ... ON CLUSTER, until the hosts run as the user (distributed_ddl_use_initial_user_and_roles).Validation: the new test covers a
Filetable, a materialized view and a refreshable materialized view with aFileinner engine,restore_replace_external_engines_to_nullset in the query and in the session, and a positive control; it fails on master and passes 50/50 with randomized settings.test_backup_restore_on_cluster,test_restore_external_enginesandtest_backup_restore_newpass.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/129468]
Version info
26.11.1.2004-master(included in26.11and later)