Repository navigation
Conversation
|
Workflow [PR], commit [b793cb5] Summary: ✅
AI ReviewSummaryThis PR extends Azure secret masking to the data-lake engines and to several SAS-bearing URL forms. The original Findings❌ Blockers
Tests
Final VerdictChanges requested. The PR fixes the original data-lake engine leak, but the current head still exposes Azure credentials in several user-reachable failure paths and in the unified LLVM Coverage ReportMeasured on commit b793cb5.
Changed lines: Changed C/C++ lines covered: 165/179 (92.18%) · Uncovered code |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction. Object file sizes3 object files changed (+19.06 KiB total), 0 added.
737 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 units21 translation units recompiled, 88 s compile time in total, 21 of them have a recent master baseline. |
`IcebergAzure`, `DeltaLakeAzure` and `PaimonAzure` were listed in neither branch of the table engine dispatch in `FunctionSecretArgumentsFinder::findTableEngineSecretArguments`, so none of their arguments was ever marked secret. The storage account key stayed verbatim in `SHOW CREATE TABLE`, in `system.tables.engine_full` and in the logged query text, at the default `format_display_secrets_in_show_and_select = 0` and without the `displaySecretsInShowAndSelect` privilege, in both the connection string form and the five argument form. The three engines take the same leading arguments as `AzureBlobStorage`, whose finder already handles both forms, so route them to it. The Azure table functions were already covered, which is why a view over `icebergAzure` masked while the engine did not. Closes: ClickHouse#114939
20c2335 to
dce0111
Compare
|
@arsenmuk maybe you can also review this PR? |
A storage account url authenticates with the shared access signature in its query string: when the url contains a '?', `processURL` takes everything after it as `sas_auth`. `maskAzureConnectionString` skipped any argument starting with `http`, so that token stayed verbatim in `SHOW CREATE TABLE`, in `system.tables.engine_full` and in `system.query_log.query`, while the same credential spelled as a connection string (`SharedAccessSignature=`) was hidden. A shared access signature is a bearer credential: it grants the container access it was issued for until it expires. Mask the `sig` parameter, the HMAC over the signed fields and the only part of the token that cannot be guessed. The rest (version, permissions, expiry, resource) grants nothing on its own and stays visible for diagnostics, the same way `maskPresignedURLParameters` keeps a presigned S3 url readable. The url is replaced in place rather than hidden whole, so a positional `account_key` in the same call is still masked by the caller. This covers the `AzureBlobStorage` and `AzureQueue` engines and the `azureBlobStorage` table function with its cluster and named collection forms, which all reach the same finder. Closes: ClickHouse#114946
AzureStorageParsedArguments::fromAST reads the second argument of the two argument signature as a shared access signature, so it is a credential in every Azure table function and table engine, the data lake ones included. The masker only knew the account_key slot of the longer signatures, so the token stayed verbatim in the logged query text. Also carries the url named collection and URL database engine fixes, and the 04909 reference correction, from the same series.
| } | ||
| if (key != "connection_string" && key != "storage_account_url") | ||
| { | ||
| if (key == "account_key" || key == "client_id" || key == "tenant_id") |
There was a problem hiding this comment.
maskAzureConnectionString(..., argument_is_named = true) still leaves one Azure credential carrier visible in the named-collection path: sas_token. The same parser this PR mirrors reads the 2-argument signature as (connection_string/storage_account_url, sas_token) in src/Storages/ObjectStorage/Azure/Configuration.cpp:398-405, but here key == "sas_token" falls through the non-secret branch.
That means ENGINE = IcebergAzure(nc, sas_token = 'SEKRIT') still formats the raw bearer token into SHOW CREATE, system.tables.engine_full, and the logged query text, while SELECT * FROM azureBlobStorage(nc, sas_token = 'SEKRIT') still leaks it in the logged query text, before the named-collection machinery decides whether to use, ignore, or reject the override. Please treat sas_token as a secret key here as well, or share one Azure secret-key set between the positional and named-collection paths.
|
|
||
| if (url_arg_idx >= positional.size()) | ||
| return; | ||
| if (maskAzureConnectionString(positional[url_arg_idx])) |
There was a problem hiding this comment.
This early return is still too strong for the Azure parser underneath it. maskAzureConnectionString returns true after hiding the first secret it sees in argument 0, and both callers stop checking the rest of the argument list (findAzureBlobStorageFunctionSecretArguments here and the table-engine copy at src/Parsers/FunctionSecretArgumentsFinder.cpp:1109). But AzureStorageParsedArguments::fromAST still consumes slot 4 as account_key on the 5+-argument forms based only on arity / the format check, even when slot 0 is a connection string rather than a plain storage-account URL (src/Storages/ObjectStorage/Azure/Configuration.cpp:446-455, 484-486, 545-547, 584-586, 614-615, 650-652).
So azureBlobStorage('DefaultEndpointsProtocol=http;AccountName=acct;AccountKey=K1;BlobEndpoint=http://127.0.0.1:1/acct;', 'cont', 'p', 'acct', 'K2') hides K1 inside the connection string but still logs the raw fifth argument K2. The same short-circuit also leaves any second secret inside the connection string visible (AccountKey=...;SharedAccessSignature=... or duplicated keys), because the helper masks only one field before telling the caller it is done. Please keep masking the remaining Azure credential carriers after the first replacement instead of short-circuiting here.
Carries the same fix as ClickHouse#114964: the named collection fail closed rule hid the one positional the Azure backup locator accepts after a collection, which is the blob path and not a credential, and a mixed case scheme left the sig parameter visible in the logged query.
| return false; | ||
|
|
||
| const String scheme = url.substr(0, scheme_end); | ||
| if (!equalsCaseInsensitive(scheme, "az") && !equalsCaseInsensitive(scheme, "azure") |
There was a problem hiding this comment.
findURLSecretArguments still misses the most common Azure SAS spelling for the url / URL surfaces: a plain https://account.blob.core.windows.net/...?...&sig=... URL. Here we only mask the generic userinfo password and then call maskDispatchedAzureURLCredentials, which returns false unless the scheme is az / azure / abfs*.
That means SELECT * FROM url('https://account.blob.core.windows.net/cont/data.csv?sp=r&sig=SECRET', 'CSV'), ENGINE = URL('https://account.blob.core.windows.net/...'), and CREATE DATABASE ... ENGINE = URL('https://account.blob.core.windows.net/...') still format the raw SAS into the query tree, SHOW CREATE, and the logged query text. Please treat Azure SAS on the known Azure HTTPS hosts the same way as the custom schemes (or share a host-aware Azure URL masker) so the leak does not depend on whether the user wrote az://... or the equivalent HTTPS URL.
| markSecretArgument(i, /* argument_is_named= */ true); | ||
| continue; | ||
| } | ||
| if (key != "connection_string" && key != "storage_account_url") |
There was a problem hiding this comment.
This named-collection branch no longer mirrors the fail-closed guard we already have in classifyS3Arguments and findURLSecretArguments. For every key other than connection_string, storage_account_url, account_key, client_id, and tenant_id, we just continue, even when the value is a non-literal expression.
That still leaks secrets on the error path because tryGetNamedCollectionWithOverrides evaluates override values only after the query has been formatted for logging. A query like SELECT * FROM azureBlobStorage(nc_04909_missing, format = headers('Authorization' = 'SEKRIT')) or CREATE TABLE ... ENGINE = IcebergAzure(nc, container = headers(...)) will print the nested header value verbatim: maskNestedSecretMaps only records top-level headers(...) / extra_credentials(...), and the nested equals(...) node has no masking rule of its own.
Please fail closed here for visible Azure overrides whose value is neither a plain literal / identifier nor a safe scalar literal, the same way the S3 and url named-collection paths do.
Closes: #114939
Related: #114964
IcebergAzure,DeltaLakeAzureandPaimonAzuretake the same credential bearing arguments asAzureBlobStorage: anAccountKey=inside a connection string, asigin a storage account url, or a positionalaccount_key. None of the three was listed in the table engine dispatch of the secret argument finder, so the credential stayed verbatim inSHOW CREATE, insystem.tables.engine_fulland in the logged query text for every user able to read them.The three engines now go through the Azure masker, which also learns the credential of the two argument signature
(connection_string|storage_account_url, sas_token).AzureStorageParsedArguments::fromASTreads that second argument as a shared access signature, and it belonged to no masked slot before, so it leaked from every Azure table function and table engine.This pull request is built on top of #114964 and contains its commits, so its diff shrinks to the data lake part once that one is merged. Both target
master.Changelog category (leave one):
Bug Fix (user-visible misbehavior in an official stable release)
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Hide Azure account keys and shared access signatures used by IcebergAzure, DeltaLakeAzure, and PaimonAzure table engines.
Workflow [PR]
Sync PR [sync-upstream/pr/114963]