Repository navigation
Restrict server-managed Azure credentials - #120343
Conversation
|
Workflow [PR], commit [fef05a0] Summary: ✅
AI ReviewSummaryThe change restricts server-managed Azure credentials in user SQL, adds credential-setting aliases, and handles existing metadata and dynamic-disk opt-ins. At head Missing context / blind spots
Findings❌ Blockers
Tests
Final VerdictStatus: ❌ Block. Validate every backing location during disk reuse and isolate credentials for each query's lifetime, with focused regressions for both bypasses. |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes27 object files changed (+202.72 KiB total), 0 added.
719 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units125 translation units recompiled, 1185 s compile time in total, 125 of them have a recent master baseline. |
…entials Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
I think we should also add check around here: ClickHouse/src/Disks/DiskFromAST.cpp Lines 62 to 72 in 1316ee8 It's needed to prevent an untrusted profile from using an already configured Azure disk |
| .forbid_implicit_credentials = remote_host_filter_check != RemoteHostFilterCheck::None | ||
| && context->shouldRestrictUserQueryAzureCredentials(), |
There was a problem hiding this comment.
[P1] Enforce the Azure restriction when reusing a dynamic disk
This check only runs inside the disk creator. getOrCreateCustomDisk in DiskFromAST.cpp calls Context::getOrCreateDisk, which returns an existing disk without invoking that creator. If a trusted session first creates a dynamic Azure disk with azure_allow_server_credentials_in_user_queries = 1, a session pinned to 0 can create another table with the identical disk(type = azure_blob_storage, ...) definition. The definition has the same hash, passes the existing-disk checks, and reuses the authenticated client with forbid_implicit_credentials = false. Its writes therefore still authenticate with the server's identity despite the restriction.
Validate the current session's Azure credential policy before accepting an existing dynamic disk, including wrapped disks. Please add a two-session regression that creates the disk with the opt-in and then attempts to reuse the same definition under the restricted profile.
There was a problem hiding this comment.
The direct Azure definition is now checked, but reuse through a wrapper still bypasses the restriction in the current code. After a trusted session creates a dynamic Azure disk named trusted_azure, a restricted session can specify:
CREATE TABLE wrapped (x UInt8) ENGINE = MergeTree ORDER BY tuple()
SETTINGS disk = disk(type = encrypted, disk = 'trusted_azure',
key = '0123456789abcdef', path = 'restricted/');validateResolvedAzureDiskCredentials returns at src/Disks/getDiskConfigurationFromAST.cpp:535 because this configuration has type encrypted, with no Azure prefixes. getDiskAndPathFromConfig then takes the existing disk directly from the map at src/Disks/DiskEncrypted.cpp:232-237, without checking its credential policy. Writes through the wrapper retain the underlying authenticated Azure client. A cache wrapper can likewise reference the existing disk by name. Validate the underlying dynamic disk's policy when accepting these references, or require its full definition so it is revalidated.
There was a problem hiding this comment.
The wrapper-reuse bypass is still present for a disk with multiple locations at head 1e69b80a2255f8c379e7e79466595e7a1d8fac44. At src/Disks/getDiskConfigurationFromAST.cpp:542-547, getCustomDiskServerIdentity checks only DiskObjectStorage::getObjectStorage, which returns the local location's backend (src/Disks/DiskObjectStorage/DiskObjectStorage.cpp:82). It returns no identity when that backend has explicit credentials, without examining the other locations.
For example, let an opted-in session create a named dynamic disk trusted_multi with a local Azure location using an explicit account key and a second enabled Azure location using managed identity. A restricted session can then create:
CREATE TABLE wrapped (x UInt64) ENGINE = MergeTree ORDER BY tuple()
SETTINGS disk = disk(type = encrypted, disk = 'trusted_multi',
key = '0123456789abcdef', path = 'restricted/');The new check accepts the explicitly authenticated local backend. However, an insert through the wrapper reaches DiskObjectStorageTransaction::writeFileImpl, which opens a writer for every enabled location (src/Disks/DiskObjectStorage/DiskObjectStorageTransaction.cpp:291-334), including the cached managed-identity client. The restricted session therefore still writes using the server's identity.
Inspect all backing locations when validating reuse, and add a two-session case where only a non-local location uses server credentials.
yes, the upgrade check failed for alias, I have made a fix to upgrade check #127183 |
|
@SmitaRKulkarni @arsenmuk — ClickGap found the following in this PR:
Close anything that's wrong or already addressed. |
…ed-object Conflict in the WriteBufferFromAzureDataLakeStorage constructor: master (ClickHouse#120343) added `drop_credentials` to makeAdlsGen2FileClient, while this branch replaced that client with the staging and publish file system clients. `drop_credentials` is now passed to makeAdlsGen2FileSystemClient and handled the same way, so both clients send no credentials when the server's own identity must not be used. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Since ClickHouse#120343 a SQL-defined Azure storage that uses the server's identity follows the restriction of each accessing session. AzureKernelHelper kept a copy of the connection params taken when the metadata was created, so a restricted session could still forward the workload identity to delta-kernel. Read the params from the object storage in createBuilder, as S3KernelHelper does, and fingerprint the session restriction so a cached kernel engine is rebuilt when it changes. Add a DeltaLakeAzure case to test_azure_workload_identity: after an opted-in read, a restricted session gets ACCESS_DENIED without a token request, and the opt-in still signs its requests. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The release has no Azure server credentials marker (#120343), so only the form without `_server_credentials_allowed` is tried, and the Azure test is dropped. The `storage_policy` check of `ALTER` runs in the per-setting loop of the release. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The release has no Azure server credentials marker (#120343), so only the form without `_server_credentials_allowed` is tried, and the Azure test is dropped. The `storage_policy` check of `ALTER` runs in the per-setting loop of the release. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The release has no Azure server credentials marker (#120343), so only the form without `_server_credentials_allowed` is tried, and the Azure test is dropped. The `storage_policy` check of `ALTER` runs in the per-setting loop of the release. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Azure Blob Storage access from user SQL no longer uses the server's own workload or managed identity unless
allow_server_credentials_in_user_queries(formerlys3_allow_server_credentials_in_user_queries) is enabled; provide explicit credentials instead:account_nameandaccount_key, a connection string, or a SAS token.Details:
Similar to this s3 pr Restrict server-managed S3 credentials in user queries (chokepoint, alternative to #104889) #106855
Workflow [PR]
Sync PR [sync-upstream/pr/120343]
Version info
26.11.1.534-master(included in26.11and later)