Skip to content

Backport #117429 to 26.3: Mask secrets in SHOW CREATE DATABASE of a Backup database - #122669

Merged
PedroTadim merged 6 commits into
26.3from
backport/26.3/117429
Sep 29, 2026
Merged

PedroTadim merged 6 commits into
26.3from
backport/26.3/117429

Conversation

@robot-ch-test-poll4

@robot-ch-test-poll4 robot-ch-test-poll4 commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Original pull-request #117429
Cherry-pick pull-request #121965

This pull-request is a last step of an automated backporting.
Treat it as a standard pull-request: look at the checks and resolve conflicts.
Merge it only if you intend to backport changes to the target branch, otherwise just close it.

The PR source

The PR is created in the CI job

Version info

  • Merged into: 26.3.37.3

@robot-ch-test-poll4 robot-ch-test-poll4 added pr-backport Changes, backported to release branch. Do not use manually - automated use only! pr-bugfix Pull request with bugfix, not backported by default labels Sep 28, 2026
@clickhouse-gh

clickhouse-gh Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [BackportPR], commit [23252a1]

Summary: ✅

All 7 builds failed on `src/Parsers/FunctionSecretArgumentsFinder.cpp` with `isAlphaASCII`,
`isAlphaNumericASCII` and `equalsCaseInsensitive` undeclared (the `std::all_of` error is a
cascade of the second, used inside the lambda).

On master those come from `<Common/StringUtils.h>`, which that file includes - but the include
was added there by a different commit, not by #117429, so 26.3 never got it. 26.3 also has only
the `(char, char)` overload of `equalsCaseInsensitive`, while the backported call site passes a
`std::string_view`, so the overload is taken verbatim from master rather than rewriting the call
sites to something 26.3 already has.

The four existing `equalsCaseInsensitive` call sites on this branch all pass `char`, which
`std::string_view` cannot be converted from, so none of them becomes ambiguous.

https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=122669&sha=b297f764fdbb6ce824c8285dc637330b72c40f3e&name_0=BackportPR&name_1=Build%20%28amd_debug%29

Related: #122669

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator

@PedroTadim the remaining reds here, and the same ones on #122674 (26.7), come from two master-only prerequisites that #117429's tests assume, not from the backported masking code. Measured on a local debug build of this head and on #122674's own amd_debug binary:

  1. test_mask_sensitive_info and 05234 need Fix empty tables in a second Backup database from the same backup #113378, which 26.8/26.9 have and 26.3/26.7 do not. There buildStoragePolicyName embeds BackupInfo::toString(), so a Backup database over a credentialed locator carries the secret in its storage policy name: in the StoragePolicy ... created trace line both integration jobs caught, in system.storage_policies, and in each table's storage_policy in SHOW CREATE TABLE. The official 26.3.33.24 image shows the same. That cache key also makes a second Backup database over one backup read 0 rows, which is 05234's must be 3. With Fix empty tables in a second Backup database from the same backup #113378 cherry-picked onto this head, 05234 and Fix empty tables in a second Backup database from the same backup #113378's own 04750 pass and the secret is gone from all three places. It applies cleanly to 26.7; on 26.3 the only conflict is its new integration test landing next to 26.3's quoted-locator test (keep both). Could you add v26.3-must-backport to Fix empty tables in a second Backup database from the same backup #113378? 26.8/26.9 already contain it.

  2. 04510 needs Add factory-owned backup destination identity #110610's Azure URL check, which neither branch has, so some statements fail inside the Azure SDK with STD_EXCEPTION instead of BAD_ARGUMENTS (4 on 26.3, 3 on 26.7). Two more cannot stay on 26.3: the 3-argument connection-string control resolves a.blob.core.windows.net, and the userinfo URL makes Azure::Core::Url throw std::invalid_argument, which aborts debug and sanitizer builds. The masked query_log transcript is otherwise identical to the reference on both branches. Test-only commits, one per branch on top of the current heads, 3/3 green with random settings:

git fetch https://github.com/groeneai/ClickHouse groeneai/fix-04510-backport-26.3-117429   # 48dc5503
git push origin FETCH_HEAD:backport/26.3/117429
git fetch https://github.com/groeneai/ClickHouse groeneai/fix-04510-backport-26.7-117429   # 5bbbbaf4
git push origin FETCH_HEAD:backport/26.7/117429

PedroTadim and others added 3 commits September 29, 2026 11:11
`04510_s3_explicit_url_named_secret_mask` asserts `BAD_ARGUMENTS` for
`AzureBlobStorage('DefaultEndpointsProtocol=...;AccountKey=...;', 'cont',
'blob', 'acct', 'key')`, a connection string written where the five-argument
shape requires a plain storage account URL. On master that arm never reaches
the SDK: `validatePlainStorageAccountURL` rejects it first. Without that
validator the SDK base64-decodes the account key instead and throws
`std::runtime_error`, which surfaces as `STD_EXCEPTION` (Code 1001).

The helper is transplanted verbatim from master and is called from the same
two sites: the five-argument form, and a named collection carrying explicit
credentials. The three-argument form is left unvalidated, as on master.

The failures this fixes:
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=122669&sha=dd96fc97dd7c07ee43e7a484c08090bae8485a01&name_0=BackportPR

Related: #117429

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`Azure::Core::Url` has no userinfo support, so the three-argument
destination `AzureBlobStorage('http://user:pass@host:port/acct', 'cont',
'blob')` is parsed with `user` as the host, and `std::stoi` then throws a
bare `std::invalid_argument`. On a thread-pool thread a non-`DB::Exception`
reaching `tryLogCurrentException` is a logical error, so a debug or sanitizer
build calls `abortOnFailedAssertion` and the server dies.

`validatePlainStorageAccountURL` does not cover this arm: master validates
the five-argument and named-collection forms only, so the three-argument one
still reaches the SDK and relies on this guard. 26.5, 26.7, 26.8 and master
already have it; 26.3 and 26.4 are the branches without it.

It is transplanted verbatim, so the helper and the three catch sites are
byte-identical to 26.7. With it in place the userinfo arm of
`04510_s3_explicit_url_named_secret_mask` passes here as it does there.

The failures this fixes:
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=122669&sha=dd96fc97dd7c07ee43e7a484c08090bae8485a01&name_0=BackportPR

Related: #117429

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator

The last red here, 04510 on db46dd3 (job), has one cause: 26.3 has no zip-archive check for AzureBlobStorage backups. On 26.7 and master, #101770 rejects the test's two 3-argument destinations, which write visible_04510_dir/b.zip, with BAD_ARGUMENTS before any request. #101770 is pr-backward-incompatible, so it is not a backport candidate. On 26.3 both statements reach the Azure SDK: the connection-string control resolves a.blob.core.windows.net (the DNS_ERROR in the job), and the account-url control fails the SDK's non-https bearer-token check with STD_EXCEPTION.

Test-only fix on top of db46dd3, 3 lines in the .sql, reference unchanged: the connection-string control gets an account key that is not valid base64, so the SDK rejects it while signing, before anything is sent, and both statements also accept STD_EXCEPTION. Their logged query text is masked the same way, so the transcript still matches. On this head's amd_debug CI binary it passes 3/3 with random settings, and the unchanged test fails with the CI error.

git fetch https://github.com/groeneai/ClickHouse groeneai/fix-04510-backport-26.3-117429-v2   # 3119eead, tree 563b98cc
git push origin FETCH_HEAD:backport/26.3/117429

Both commits in my earlier comment are obsolete now. #122674 (26.7) needs nothing for 04510: it has the zip check and passes unchanged 3/3 on its own CI binary.

Master rejects a `.zip` blob path for an object-storage backup destination
before it builds a client, and that is what made both three-argument Azure
controls fail with `BAD_ARGUMENTS` there. 26.3 has no such rejection --
`hasSupportedZipExtension` reaches `registerBackupEngineAzureBlobStorage`
only on 26.7 and later -- so the destination is built, and the
connection-string control spent 4.3s resolving `a.blob.core.windows.net`
before failing with `STD_EXCEPTION`.

Drop that control. What it asserts, that a connection string hides its
AccountKey and nothing else, is already asserted by the named-collection
override control, which keeps `AccountName=visible_04510_acct` visible
beside the hidden key.

Keep the plain-url control, which is the only assertion that a locator
carrying no credential stays visible whole. On 26.3 it fails client-side
with `STD_EXCEPTION` ("Bearer token authentication is not permitted for non
TLS protected (https) endpoints"), reaching no network.

Verified against this PR's own amd_release binary: the test output now
matches the reference exactly.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=122669&sha=db46dd35373525298e5eecb9430e53c83d1607c1&name_0=BackportPR&name_1=Stateless%20tests%20%28amd_asan%2C%20distributed%20plan%2C%20parallel%2C%201%2F2%29

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@PedroTadim
PedroTadim merged commit 1e82882 into 26.3 Sep 29, 2026
36 checks passed
@PedroTadim
PedroTadim deleted the backport/26.3/117429 branch September 29, 2026 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backport Changes, backported to release branch. Do not use manually - automated use only! pr-bugfix Pull request with bugfix, not backported by default

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants