Skip to content

Hide Azure credentials that were logged in clear in system.query_log - #123651

Merged
Algunenano merged 7 commits into
ClickHouse:masterfrom
groeneai:azure-positional-secret-slots
Oct 19, 2026
Merged

Algunenano merged 7 commits into
ClickHouse:masterfrom
groeneai:azure-positional-secret-slots

Conversation

@groeneai

@groeneai groeneai commented Oct 3, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #123364

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):

Fixed secret masking of the Azure table functions and engines: a SAS token, account key or client secret was logged in clear in system.query_log for the azureBlobStorage(url, sas_token) form, argument lists with a key = value argument, extra_credentials(...) (now hidden whole), connection strings with a second or repeated secret key or an endpoint url with a query, named-collection overrides with a key Azure does not accept, and after_processing_move_connection_string. A SAS is no longer shown in the remote_url_allow_hosts error and system.schema_inference_cache, nor a SAS or a disk's account key in the backup log.

Description

On 26.9.1.1629 and 26.8.10.6, azureBlobStorage('<url>', '<sas_token>'), '...;AccountKey=...;SharedAccessSignature=<sas>' and extra_credentials(client_secret = '...') log the secret in clear in system.query_log.

On top of #123364, this fixes what leaks on master c873902b:

  • The table function takes the engine's credential slot (azureCredentialArgument), including (url, sas_token).
  • azureSlotArguments gives SETTINGS and a key = value no slot, and hides its value unless the explicit form reads the key, or all of it for an unknown key (also in EXPLAIN QUERY TREE); a second extra_credentials(...) hides everything; a *Cluster call keeps its cluster name.
  • extra_credentials(...) is hidden whole, keys included.
  • A named-collection override with a key Azure does not accept, a non-literal value, or one of several connection overrides is hidden (table function) or hides everything (engine, backup).
  • maskAzureConnectionStringSecrets replaces maskConnectionStringKey and follows the SDK's ParseConnectionString: every AccountKey and SharedAccessSignature (exact keys) and any value with ? or @ is hidden, and the whole string if a url query or userinfo is left or sits outside the pairs. after_processing_move_connection_string uses it too.
  • ConnectionParams::getConnectionURLWithoutQuery drops the url query (a SAS) for the remote_url_allow_hosts check, getDataSourceDescription and the backup description; getConnectionURL, which builds clients, keeps it. The backup log masks a connection_string disk's description, that string.

Validation: 35 new lines in 05316_secret_arguments_declared_by_engines (32 leak on master, 3 pin shapes master hides), two test_allowed_url_from_config cases and a test_backup_restore_azure_blob_storage case (SAS backup of a key disk) fail on master and pass with the fix; 04510, 05338 and the test_mask_sensitive_info Azure tests pass.


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

Version info

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

@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-review-bot PR origin: review-bot finding on a groeneai PR labels Oct 3, 2026
@groeneai

groeneai commented Oct 3, 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; 4 rounds, 5 findings, all fixed; the last round found none).

# Sev Finding Verdict Evidence / action
1 ❌ A connection string was masked at its first AccountKey= / SharedAccessSignature= only; the SDK keeps the last copy, uses both keys and reads a SAS in BlobEndpoint AGREE, fixed @ 2f4b0d7 maskAzureConnectionStringSecrets masks every part; arms CS1-CS6
2 ❌ extra_credentials(client_secret = ...) was logged as written AGREE, fixed @ 2f4b0d7 nested secret map in both Azure finders; arms X1, X2
3 ❌ The table-function named-collection form showed a SAS storage_account_url and a connection string beside account_key AGREE, fixed @ aa31f0a the engine's override check; arms N1-N3
4 ❌ after_processing_move_connection_string = 'https://...?sig=...' was read as a connection string, so its SAS was shown AGREE, fixed @ 1015fd5 an http value with ?, # or @ is hidden whole; arm Q1
5 ❌ A call in the cluster-name position of a *Cluster function shifted the slots AGREE, fixed @ 1015fd5 such a call hides every argument; arm K1 (a key = value there was already hidden on master, arm K2 pins it)
6 💡 Over-masking: the data-lake SETTINGS disk = ... form with two positionals, client_id/tenant_id in EXPLAIN AST, a named-collection form with an unreadable override, a constant-expression cluster name noted, not blocking display only, fail closed
7 💡 A url the server reads as a connection string (leading space, upper-case scheme) keeps its query text noted, not blocking the server reads no credential from such a value

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are
terminal per finding. Findings on hunks unchanged by the fix round are auto-dropped.

Session id: cron:clickhouse-review-self-slot-58:20261003-041000

@groeneai groeneai added the groeneai-origin-review-bot PR origin: review-bot finding on a groeneai PR label Oct 3, 2026
@groeneai

groeneai commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. 05317_azure_positional_secret_slots fails on every run on master (26 statements show a secret in system.query_log); no endpoint needed.
b Root cause explained? Both finders counted raw arguments while the parser drops extra_credentials(...) first; a connection string was masked at its first AccountKey= / SharedAccessSignature= only, while the Azure SDK keeps the last value, uses both keys and reads BlobEndpoint with its query; also missing: the nested extra_credentials map, the table functions' named-collection override check, the move-setting url rule and the cluster-name slot.
c Fix matches root cause? Yes. One helper computes the parser's slots for both finders; one connection-string helper is shared by the finder and AzureQueue; each missing rule is added. No guard at the formatter.
d Test intent preserved / new tests added? New SQL test: 27 shapes (26 leak on current master) + 6 controls; eleven throwaway mutations each redden their arms.
e Both directions demonstrated? Master snapshot: FAIL, controls identical. Fix: OK, 50/50 randomized runs. Official 26.8.10.6 and 26.9.1.1629 servers: 6 of 6 probe shapes leak in system.query_log (controls masked); fix binary: 0.
f Fix is general across code paths? Covers azureBlobStorage, icebergAzure, deltaLakeAzure, paimonAzure, their *Cluster forms, the AzureBlobStorage/AzureQueue engines, positional and named-collection forms and after_processing_move_connection_string; no caller of the old first-occurrence helper remains.
g Fix generalizes across inputs (params/datatypes/wrappers)? 130 argument shapes against master (0..10 positionals, SAS/plain/userinfo/connection-string urls, extra_credentials at every position, cluster offset) plus connection-string variants (both keys, repeated key, endpoint SAS, case, spacing, empty parts). String literals only, so type wrappers do not apply.
h Backward compatible? (maintainer-approved exception only) Yes. Display-only change. client_id / tenant_id now stay visible inside extra_credentials(...), as role_arn does.
i Invariants and contracts preserved? markSecretArgument's replacement.empty() precondition holds; every unmasked byte of a connection string is preserved.

Session id: cron:clickhouse-impl-self-slot-57:20261003-033029

@clickhouse-gh

clickhouse-gh Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [5fdb925]

Summary: ✅


AI Review

Summary

PR #123651, reviewed at 5fdb9251f3bb13905d3834eb24877561b9ed399a, fixes Azure credential masking across query formatting, explain output, connection strings, schema-cache descriptions, host-filter errors, and backup logging. No unresolved actionable findings remain. The latest whole-argument masking of extra_credentials addresses the outstanding prior finding; that bot-authored thread has been resolved.

Missing context / blind spots
  • ⚠️ The current head's targeted functional/integration tests and bugfix-validation jobs are still pending in Praktika. Their completed results would independently confirm the source-level regression coverage and the author's recorded before/after validation. No local build or test execution was performed.
Final Verdict

Status: ✅ Approve. No additional code changes requested.

@clickhouse-gh clickhouse-gh Bot added pr-bugfix Pull request with bugfix, not backported by default comp-azure Azure Blob Storage integration (credentials, multipart, Azure-specific IO). labels Oct 3, 2026
@clickhouse-gh

clickhouse-gh Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Commit 5fdb9251f3bb13905d3834eb24877561b9ed399a was not compared: the CI logs cluster did not answer (every POST attempt failed with an exception; stopped retrying after the 1250 s read budget).

See the job log for details.

@groeneai

groeneai commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - cd4a3a7

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
Stateless tests (arm_binary, ParallelReplicas, s3 storage, parallel) / 04825_quantile_deterministic_alter_add_modify_column flaky (1/148 reruns): the version-1 column returns 506014 instead of 492708 because the -Merge state travels between replicas at version 0; 7 PRs in the last 24 hours on this new job #123070 (mine, open)
Stateless tests (arm_binary, s3 storage, DBReplicated, parallel, 1/2) / 05237_with_expression_alias_scope_descendant deterministic under a Replicated database (the rerun does not use one, so it passes there): the replicated CREATE VIEW stores a nested WITH alias qualified with the database, so the view reads the same-named table; 52 PRs in the last 24 hours on this new job a fix task is created (fix in progress, fixing-PR link to follow here)
Mergeable Check, PR rollups, red only because of the rows above #123070 and the fix task above

All 157 check runs completed and Finish Workflow is green; CIDB has no other FAIL or ERROR row on this head.

Session id: cron:our-pr-ci-monitor:20261003-143124

@groeneai

groeneai commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator Author

Fixing PR for 05237_with_expression_alias_scope_descendant (DBReplicated): #123774

@Algunenano Algunenano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Holding of until the refactor in #123364 is merged

@groeneai

groeneai commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator Author

Understood, holding until #123364 is merged.

For the port: I ran this PR's test 05317_azure_positional_secret_slots against the #123364 CI build (c7aadb7 merged into master 9303f58). It fixes the extra_credentials slot shift, the SAS url form and the named-collection storage_account_url, but 28 of the 36 shapes in the test still log the secret in clear in system.query_log, for example:

  • azureBlobStorage('http://host/cont/data.csv', 'sp=r&sig=...'), the two-argument form (also azureBlobStorageCluster and icebergAzure)
  • AzureBlobStorage(url, sas, partition_strategy = 'none')
  • a connection string with a second AccountKey= or with SharedAccessSignature=
  • after_processing_move_connection_string = 'https://...?sig=...'
  • extra_credentials(client_secret = ...) and named-collection overrides such as account_key = ... or sas_token = ...

Once #123364 is merged I'll rebase onto it, keep only the remaining cases in the per-engine declarations, and re-request review.

@Algunenano

Copy link
Copy Markdown
Member

@groeneai Please rebase/merge master now. Patch should be much smaller or innecessary

…still log

Rebased onto ClickHouse#123364, which moved the Azure secret rules to
`AzureSecretArguments.cpp` and fixed the `extra_credentials(...)` slot
shift, the SAS-url form and the named-collection `storage_account_url`.
On master c873902 these statements still log a SAS token, account key
or client secret in clear in `system.query_log`:

- the `(url, sas_token)` table function form, also `*Cluster` and the
  data lake functions: the table function never had the engine's
  two-argument credential slot. It now uses the same
  `azureCredentialArgument` as the engine, and hides it before the
  connection string, since hiding that sets a whole-argument replacement.
- a `key = value` argument or a second `extra_credentials(...)` among the
  positionals: `azureSlotArguments` gave them a slot. A `key = value` now
  takes none and its value is hidden unless the explicit form reads the
  key; with two `extra_credentials(...)` the slots are unknowable and
  everything is hidden. A `*Cluster` call keeps its first argument as the
  cluster name, whatever it is.
- `extra_credentials(client_secret = ...)`: Azure registered no nested
  secret map. Only `client_id` and `tenant_id` are shown now.
- a named-collection override with a key `StorageAzureConfiguration` does
  not accept (`client_secret`, `sas_token`, `AccountKey`) or with a value
  that is no plain literal: the table function hides its value, the engine
  and backup forms hide everything. The table function also hides every
  connection override when there are several (only one is read, and only
  one can be partly shown), and no longer skips `account_key` when a
  connection string was masked.
- connection strings: `maskConnectionStringKey` hid only the first
  `AccountKey=` or `SharedAccessSignature=`, but the Azure SDK keeps the
  last copy of a repeated key (case-insensitively), uses both keys, and
  reads `BlobEndpoint` with its query. `maskAzureConnectionStringSecrets`
  hides every such value and any value with `?` or `@`, and the whole
  string when a url query, fragment or userinfo is left. It also replaces
  the rule of `after_processing_move_connection_string`, whose `http`
  value is read as a url with its SAS after `?`.

Tests: 22 lines in 05316, each logging a secret on master and none with
the fix. Two cluster calls in test_mask_sensitive_info used
`container_name`/`blobpath`, which Azure does not accept, so their values
are now hidden; renamed to `container`/`blob_path`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai
groeneai force-pushed the azure-positional-secret-slots branch from cd4a3a7 to 06a327e Compare October 9, 2026 12:04
@groeneai

groeneai commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator Author

Rebased onto master (c873902, with #123364) and cut the PR down to what still leaks there: 06a327e. The source diff is now AzureSecretArguments.cpp, maskURIPassword.h and AzureQueue_fwd.h (+154/-84). The extra_credentials flag through ASTFunction.cpp is gone (maskNestedSecretMap covers it), and the 05317 test is replaced by 22 lines in 05316, each of which logs the secret on master:

  • azureBlobStorage(url, sas_token), also *Cluster and icebergAzure: the table function has no two-argument credential slot
  • a key = value among the positionals (partition_strategy = 'none', account_key = '...') and extra_credentials(client_secret = '...')
  • connection strings: only the first AccountKey= or SharedAccessSignature= is masked, and an endpoint with ?sig= is kept
  • named-collection overrides with a key Azure does not accept (client_secret, sas_token), a second connection override, or account_key next to a masked connection string
  • after_processing_move_connection_string = 'HTTPS://...?sig=...'

#114946 (SAS in the url) is fixed by #123364, so this PR no longer closes it.

@groeneai
groeneai requested a review from Algunenano October 9, 2026 12:05
@groeneai

groeneai commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 06a327e

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
Stateless tests (arm_binary, s3 storage, DBReplicated, parallel, 1/2) / 05316_secret_arguments_declared_by_engines test regression from merged #123364, not from this PR: under DatabaseReplicated the CREATE DICTIONARY row is counted twice in system.query_log (0 2 instead of 0 1). This PR edits the same test, but the failing line is that existing row; the lines added here pass, and the test passed 50/50 in all five flaky checks. 16/16 reruns pass; 82 PRs show it in this lane since 2026-10-09 09:47Z #124928 (external, open)
Stateless tests (arm_binary, ParallelReplicas, s3 storage, parallel) / 05317_local_read_throttler_filesystem_cache flaky, not from this PR: the cache-bytes check reads 0 instead of 1 because under parallel replicas the read can land only in a remote replica's query_log row, which the current_database = currentDatabase() filter drops. 148/148 reruns pass; 7 PRs in this lane #124920 (mine, open)
Stateless tests (arm_binary, AsyncInsert, s3 storage, parallel) / 05239_written_rows_quota_interval_rollover flaky, not from this PR: the rollover checkpoint line 1 1 is missing when the inserts run asynchronously. 6/6 reruns pass; 4 PRs in this lane #124935 (mine, open)
Mergeable Check, PR praktika rollups of the three rows above #124928 (external, open), #124920 (mine, open), #124935 (mine, open)

The Bugfix validation (integration tests) jobs are green: their test_mask_sensitive_info FAIL rows are the expected inverted results on the base build.

Session id: cron:our-pr-ci-monitor:20261009-163012

@Algunenano Algunenano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Two things: the connection string masker should point to its source of truth, and there is a SAS leak in a path this PR does not cover.

1. Document what maskAzureConnectionStringSecrets is modelled on

There is no ClickHouse spec for Azure connection strings: the docs only link to Microsoft, and the real reader is the SDK's Azure::Storage::_internal::ParseConnectionString (contrib/azure/sdk/storage/azure-storage-common/src/storage_credential.cpp). It is used by every consumer (CreateFromConnectionString of the blob, container and data lake clients, Delta Lake's KernelHelper.cpp, ConnectionParams::getConnectionURL). Its rules: the key runs to the next = (searched across ;), the value to the next ;, pairs go into a std::map (last copy of a repeated key wins), keys match exactly and case-sensitively without trimming, and the *Endpoint values become Azure::Core::Url, so a query in them is a working SAS.

I checked the new masker against that tokenizer (copied verbatim) with 20M random strings made of ;, =, ?, @, #, spaces, key names and URL pieces, tagging each value with a marker: no secret (AccountKey, SharedAccessSignature, an endpoint's query or userinfo) survived masking. The same harness finds leaks in master's maskConnectionStringKey immediately, e.g. DfsEndpoint=?<sas>;AccountKey=<key> keeps the SAS. So the logic looks right, but the code is hard to follow because none of its rules are tied to that parser. Please:

  • Add a short comment on maskAzureConnectionStringSecrets naming ParseConnectionString as the reference, with one example string per rule (secret keys, repeated keys, endpoint with a query or userinfo, the whole-string fallback).
  • Either drop the case-insensitive key match and the whitespace trimming, or justify them: the SDK ignores accountkey, so they only over-mask.

2. A SAS in a connection string still leaks through getConnectionURL

For the connection string form, ConnectionParams::getConnectionURL returns the SDK's BlobServiceUrl, to which ParseConnectionString has appended ?<sas>. (The https://...?sig= URL form is fine: the SAS is split off into endpoint.sas_auth.) That URL reaches:

  • StorageAzureConfiguration::check → RemoteHostFilter::checkURL, which throws UNACCEPTABLE_URL with the URL in the message. Its masking (maskURIUserinfo, maskPresignedURLParameters) knows only S3/GCS parameter names, so Azure's sig passes through: running both on https://acc.blob.core.windows.net/?sv=2022-11-02&sr=c&sp=r&se=2026-12-01&sig=SECRETSIG returns it unchanged. On a server with remote_url_allow_hosts set, azureBlobStorage('BlobEndpoint=https://not-allowed.host/;SharedAccessSignature=...&sig=...', ...) would put the SAS into the client error, system.query_log.exception and the server log. I verified the masking functions directly, not end to end.
  • BackupReaderAzureBlobStorage::copyFileToDisk, whose LOG_TRACE prints data_source_description.description (the same URL), so a restore from an Azure backup with a SAS connection string logs the SAS at trace level (server log, system.text_log). Traced in code only.

Could you verify both end to end and fix them? One option is to strip the query in getConnectionURL, as getAzureDestinationIdentity already does for backups, after checking that Delta Lake still gets its SAS through azure_storage_sas_key and nothing else relies on the query in that URL. A line in 05316_secret_arguments_declared_by_engines (or a small test with remote_url_allow_hosts) for the exception path would be good too.

…g keys exactly

For a connection string, `ConnectionParams::getConnectionURL` returned the SDK's
`BlobServiceUrl`, to which `ParseConnectionString` appends `SharedAccessSignature` as the
query. That url is checked by `RemoteHostFilter::checkURL` (its `UNACCEPTABLE_URL` message
masks only S3 and GCS parameters), printed by the Azure backup reader and writer at trace
level, and used as the schema inference cache key (`system.schema_inference_cache.source`).
No client is built from it: the SDK clients use the connection string, and Delta Lake gets
the SAS as `azure_storage_sas_key`. So it is returned without the query.

`maskAzureConnectionStringSecrets` now matches `AccountKey` and `SharedAccessSignature`
exactly, without trimming, as `ParseConnectionString` does, and its comment names that
parser and gives one example per rule.

The `remote_url_allow_hosts` rejection gets a case in `test_allowed_url_from_config`.

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

Copy link
Copy Markdown
Collaborator Author

Thanks, done in 1fb5186.

1. maskAzureConnectionStringSecrets now names Azure::Storage::_internal::ParseConnectionString as its reference, with one example per rule. I dropped the case-insensitive match and the trimming: keys are matched exactly, as the SDK does. No line of 05316 relied on them.

2. Verified end to end on master d245b78 (debug build, Azurite, an account SAS in BlobEndpoint=...;SharedAccessSignature=..., remote_url_allow_hosts set). Both leak, and there is a third path:

  • UNACCEPTABLE_URL: URL "https://not-allowed.host/?sig=<sig>&sp=r&sr=c&sv=2022-11-02" is not allowed, in the client error, system.query_log.exception and the server log.
  • BACKUP / RESTORE with that connection string: the Source description ..., destination description ... trace line of both BackupWriterAzureBlobStorage::copyFileFromDisk and BackupReaderAzureBlobStorage::copyFileToDisk prints the url with the sig (11 + 10 lines for a 10-row table, also in system.text_log).
  • system.schema_inference_cache.source (via getDataSourceDescription): http://127.0.0.1:<port>/devstoreaccount1?se=...&sig=<sig>&.../cont/data.csv.

Fixed as you suggested: getConnectionURL drops the query of the SDK's BlobServiceUrl. Nothing reads the SAS from it: the SDK clients are built from the connection string, getAzureDestinationIdentity already strips it, and Delta Lake takes it from its own ParseConnectionString call as azure_storage_sas_key. With the fix the error is URL "https://not-allowed.host" is not allowed, the sig appears 0 times in the server log, text_log, query_log and the schema cache, and BACKUP/RESTORE, a read and a deltaLakeAzure read through the same SAS connection string still work (with a wrong sig the Delta read fails, so the kernel does use the separate key).

The test is a case in test_allowed_url_from_config::test_rejected_url_credentials_masked, since 05316 runs without remote_url_allow_hosts; it fails on master with the URL above and passes with the fix. Adding sig to maskPresignedURLParameters is in my open #121348; it would only have hidden the error text, so this PR fixes the url itself.

clickhouse-gh Bot added a commit that referenced this pull request Nov 3, 2026
Backport #123651 to 26.10: Hide Azure credentials that were logged in clear in `system.query_log`
Algunenano pushed a commit that referenced this pull request Nov 3, 2026
Port of #123651 onto the 26.9 secret arguments finder. The Azure rules it
changes live in src/Parsers/FunctionSecretArgumentsFinder.cpp here (#123364
moved them to src/Storages/ObjectStorage/Azure/AzureSecretArguments.cpp on
master and is not on 26.9), so they are ported as member functions, with
the slot counting of #123364 they build on: the SETTINGS clause,
extra_credentials(...) and key = value arguments take no positional slot,
and a positional argument after a named collection is hidden.

05316_secret_arguments_declared_by_engines does not exist on 26.9, so its
Azure lines are a new test, 05458_azure_credentials_hidden_in_logged_queries.
test_allowed_url_from_config has no test_rejected_url_credentials_masked
here, so that hunk is dropped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Algunenano pushed a commit that referenced this pull request Nov 3, 2026
Port of #123651 onto the 26.8 secret arguments finder. The Azure rules it
changes live in src/Parsers/FunctionSecretArgumentsFinder.cpp here (#123364
moved them to src/Storages/ObjectStorage/Azure/AzureSecretArguments.cpp on
master and is not on 26.8), so they are ported as member functions, with
the slot counting of #123364 they build on: the SETTINGS clause,
extra_credentials(...) and key = value arguments take no positional slot,
and a positional argument after a named collection is hidden.

05316_secret_arguments_declared_by_engines does not exist on 26.8, so its
Azure lines are a new test, 05458_azure_credentials_hidden_in_logged_queries.
test_allowed_url_from_config has no test_rejected_url_credentials_masked
here, so that hunk is dropped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Algunenano pushed a commit that referenced this pull request Nov 3, 2026
Port of #123651 onto the 26.3 secret arguments finder. The Azure rules it
changes live in src/Parsers/FunctionSecretArgumentsFinder.cpp here (#123364
moved them to src/Storages/ObjectStorage/Azure/AzureSecretArguments.cpp on
master and is not on 26.3), so they are ported as member functions, with
the slot counting of #123364 they build on: the SETTINGS clause,
extra_credentials(...) and key = value arguments take no positional slot,
and a positional argument after a named collection is hidden.

26.3 also lacks two pieces 26.8 and 26.9 have from the backport of #122770,
which the slot counting needs: AbstractFunction::Argument::isSettings(), and
hiding a positional argument written after a key = value one (called from
the two Azure rules only). The connection string regular expressions of the
finder and of AzureQueue are replaced by maskAzureConnectionStringSecrets.

05316_secret_arguments_declared_by_engines does not exist on 26.3, so its
Azure lines are a new test, 05458_azure_credentials_hidden_in_logged_queries.
test_allowed_url_from_config has no test_rejected_url_credentials_masked
here and test_backup_restore_azure_blob_storage has no
node_legacy_native_copy, so those hunks are dropped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
robot-ch-test-poll4 added a commit that referenced this pull request Nov 3, 2026
Cherry pick #123651 to 26.3: Hide Azure credentials that were logged in clear in `system.query_log`
robot-clickhouse added a commit that referenced this pull request Nov 3, 2026
robot-ch-test-poll4 added a commit that referenced this pull request Nov 3, 2026
Cherry pick #123651 to 26.8: Hide Azure credentials that were logged in clear in `system.query_log`
robot-clickhouse added a commit that referenced this pull request Nov 3, 2026
robot-ch-test-poll4 added a commit that referenced this pull request Nov 3, 2026
Cherry pick #123651 to 26.9: Hide Azure credentials that were logged in clear in `system.query_log`
robot-clickhouse added a commit that referenced this pull request Nov 3, 2026
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Nov 3, 2026
clickhouse-gh Bot added a commit that referenced this pull request Nov 3, 2026
Backport #123651 to 26.8: Hide Azure credentials that were logged in clear in `system.query_log`
clickhouse-gh Bot added a commit that referenced this pull request Nov 3, 2026
Backport #123651 to 26.9: Hide Azure credentials that were logged in clear in `system.query_log`
Algunenano added a commit that referenced this pull request Nov 3, 2026
Backport #123651 to 26.3: Hide Azure credentials that were logged in clear in `system.query_log`
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Nov 3, 2026
The Azure SDK reads the last copy of a repeated `AccountKey` or
`SharedAccessSignature`, so every copy must be hidden. Since ClickHouse#123651 the
`after_processing_move_connection_string` rule masks every segment, and the
system tables use the same rule. A first-only masker leaks the later copies
in both new rows.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
leshikus pushed a commit that referenced this pull request Nov 13, 2026
leshikus pushed a commit that referenced this pull request Nov 13, 2026
leshikus pushed a commit that referenced this pull request Nov 13, 2026
leshikus pushed a commit that referenced this pull request Nov 13, 2026
Manerone added a commit that referenced this pull request Nov 13, 2026
The key of a `key = value` argument that the parser rejects can be the secret
itself (`'secret' = 'x'`, `password_<secret> = 1`), so hide such an argument
whole instead of only its value. The same holds for a key that is not a plain
literal. This matches the masking of Azure named-collection overrides
(#123651).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Manerone added a commit that referenced this pull request Nov 17, 2026
A key of `extra_credentials(...)` can be written as anything, a credential too
(`extra_credentials('secret' = 'x')`), and the nested-map masking kept every key
visible. Hide the whole map in every S3 form, `url` and the `Backup` database
engine, the same as the Azure engines
(#123651). The whole-argument mask
covers the formatter, `EXPLAIN QUERY TREE` and `EXPLAIN AST`.

The `extra_credentials` parser no longer repeats an invalid key in its
exception. `isNonSecretExtraCredentialsKey` has no users left and is removed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Manerone added a commit that referenced this pull request Nov 17, 2026
Follow #123651 where this
masking still differed:
- The explicit-url S3 form ignores a `key = value` argument it does not read:
  an unknown key hides the whole argument, a valid S3 key that this form does
  not read hides its value.
- MySQL, PostgreSQL and `Remote`: the value of an accepted key that is not a
  plain literal or identifier is hidden, as it can nest a secret.
- In the named-collection form of a table or database engine, an override
  hidden by these rules (and, for `S3`, a positional argument after the
  collection name) hides every argument
  (`SecretArgumentsSpec::hide_every_argument_if_override_hidden`).
- An explicit S3 form with more than one `extra_credentials(...)` hides every
  argument: the parser strips only the first, so the others shift the slots.

Also update the references of `04510` and `05255`, whose logged query text
includes the comments changed in the previous commit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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-azure Azure Blob Storage integration (credentials, multipart, Azure-specific IO). groeneai-origin-review-bot PR origin: review-bot finding on a groeneai PR pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-bugfix Pull request with bugfix, not backported by default pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR 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.

5 participants