Repository navigation
Backport #115914 to 26.7: check the target engine's grant when ATTACH carries a URL engine definition - #115966
Merged
clickhouse-gh[bot] merged 1 commit intoAug 23, 2026
Conversation
…hen ATTACH carries a URL engine definition
The URL engine dispatches by scheme to File/S3/AzureBlobStorage/HDFS. The
delegate's TABLE ENGINE privilege was re-checked only when the mode was
CREATE, so a user holding TABLE ENGINE ON URL alone could ATTACH a table with
a full URL('file://...') definition and then read it, while the equivalent
CREATE and a direct ENGINE = File(...) ATTACH were both denied. The outer
engine check is not mode-gated, so the inner one was the only gap.
The predicate now exempts only a definition replayed from this server's own
metadata: server startup, force-restore, a short ATTACH TABLE t, and the
tables an ATTACH DATABASE loads. Those were validated when the table was
created and must stay loadable after a revoke. Every other statement, ATTACH
with a definition and RESTORE included, supplies a fresh definition and is
checked.
The cherry-pick ClickHouse#115950 conflicts only because master renamed
04401_url_engine_s3_dispatch.sh to 04401_url_engine_s3_dispatch_engine_grant.sh,
which makes the pair a modify/delete on this branch. The source hunk applies
unchanged: tryDispatchURLEngineByScheme is byte-identical between master and
26.7. This is that resolved tree as a single commit on the 26.7 tip.
Validated in both directions on a server configured like the stateless one,
after asserting that table_engines_require_grant denies a no-grant user and
that the backups disk accepts a backup. Against the released 26.7.6.8 binary
the test fails on attach-file-engine-denied, attach-azure-engine-denied,
restore-file-engine-denied and restore-rejected-not-created, the same four
lines it inverted against pre-fix master; against the fixed build it passes
with no diff. The bypass itself reproduces on 26.7.6.8: ATTACH of a
URL('file://...') table is accepted and the following SELECT returns the file
contents, while both the CREATE and a direct File engine ATTACH are denied.
The four older branches are unaffected and need no backport: URL scheme
dispatch does not exist there, so a URL('file://...') read fails with
Code: 36, Unknown protocol in the URL.
Contributor
|
Workflow [BackportPR], commit [8642b76] Summary: ✅ |
This was referenced Aug 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed a
TABLE ENGINEprivilege bypass in theURLtable engine. A user granted onlyTABLE ENGINE ON URLcouldATTACH TABLE ... ENGINE = URL('file://...')(ors3://,az://,hdfs://) and read through it, because the privilege re-check on the backend the scheme dispatches to ran only forCREATE. It now runs for every statement that supplies a fresh definition,ATTACHandRESTOREincluded, while a definition replayed from the server's own metadata stays exempt so existing tables keep loading.Description
Backport of #115914 to
26.7.26.7is the only active release branch affected: URL scheme dispatch does not exist on 25.8, 26.3, 26.5 or 26.6, where aURL('file://...')read failsCode: 36, Unknown protocol in the URL.The robot cherry-pick #115950 is
CONFLICTING, but only in the two test files, and only becausemasterrenamed04401_url_engine_s3_dispatch.shto04401_url_engine_s3_dispatch_engine_grant.sh, which makes the pair a modify/delete here.StorageURL.cppitself merges cleanly:tryDispatchURLEngineBySchemeis byte-identical betweenmasterand26.7, so the fix hunk applies unchanged. This is that resolved tree as a single commit on the26.7tip.The bypass reproduces on the released
26.7.6.8: as a user holding onlyURLandTABLE ENGINE ON URL, theCREATEand a directENGINE = File(...)ATTACHare both deniedCode: 497, whileATTACH TABLE ... ENGINE = URL('file://.../secret.csv')is accepted and the followingSELECTreturns the file contents.Validated in both directions against a server configured like the stateless one, after asserting live that
table_engines_require_grantdenies a no-grant user and that thebackupsdisk accepts a backup. On26.7.6.8the ported test fails on exactlyattach-file-engine-denied,attach-azure-engine-denied,restore-file-engine-deniedandrestore-rejected-not-created, the same four lines it inverted against pre-fixmaster; on the fixed build it passes with no diff. So the port is not a silent no-op.I opened this from my fork because I have no push access to this repository, which is where the
cherrypick/26.7/115914branch lives, so its conflicts cannot be resolved in place. Same route as #112916 and #112899.Version info
26.7.6.9