Repository navigation
Mask secrets in SHOW CREATE DATABASE of a Backup database - #117429
Conversation
Internal second-model review (click to expand)Three rounds of an independent cold review plus a second-model gate, adjudicated against the recorded ❌ Blockers
|
| # | Finding | Verdict |
|---|---|---|
| 3 | The ALTER DATABASE ... MODIFY COMMENT consequence in the changelog entry (pre-change the rewritten metadata stopped the server from starting) was measured by hand but had no test. |
AGREE, fixed in r1 |
| 4 | BackupInfo::fromAST changes three messages; only the not-a-function one was measured. The literal-argument message is independently reachable and also used to echo its argument. |
AGREE, fixed in r1 |
| 5 | The draft described the printed definition as "valid SQL again". Measured across all 7 commits touching src/Databases/DatabaseBackup.cpp: the locator has been a string literal since 35a5cf694e752cb (2025-02-07), so it was never re-executable and no regression happened. |
AGREE, corrected |
💡 Noted, not blocking
- The commit message credits the
FunctionSecretArgumentsFinderchange with masking
RestorerFromBackup's definition-mismatch message. That message is masked, but by the producer
change plus the archive normalization rather than by the new non-function branch: the normalization
runs atBackupMetadataFinder.cpp:433, ahead of:454, which is the only writer of the AST that
message prints, andDatabaseBackup::parseArgumentsaccepts exactly two arguments, so no definition
a server can write escapes it. The behaviour claimed is real; only the attribution is off. normalizeLegacyBackupDatabaseLocatorcatches every exception and reportsBAD_ARGUMENTS, so a
memory-limit or cancellation raised insideparseQueryis reclassified. Narrowing it needs error-code
inspection, and appending the original message would re-echo the locator, which is what the hunk
exists to prevent.- No test asserts that a reader with
format_display_secrets_in_show_and_select = 1still sees the real
value. It is structurally unreachable:ASTFunction::formatImplWithoutAliasconsults the
secret-arguments finder only underif (!settings.show_secrets), so nothing in this change can affect
an entitled formatter. 05055guarded only its setup block with--send_logs_level 'error'where02843and04327guard
every call. Verified to carry no CI consequence, since.shtests already run aterrorwith
--client_logs_file; aligned with the siblings anyway.- The two statements added to
04510extend an existing test rather than starting a new one. They are
asserted by that test's own aggregate oversystem.query_logfor itscurrent_database, and the
measured1 1 1->1 0 1->1 0 0ladder is defined over that single row, so splitting them out
would duplicate the whole fixture and spread one invariant over two files. - The masked duplicate-definition message prints two identical strings when the two definitions differ
only in their credential.RestorerFromBackuphas had the same property for as long as it has masked,
so this follows the existing behaviour rather than inventing a diff-highlighting scheme. The
comparison itself still usesformatWithSecretsOneLine, deliberately: masking the comparison key
would make two definitions differing only in their credential compare equal.
Suggested and declined
- Classifying this as
Critical Bug Fix (crash, data loss, RBAC). That category is not selected
proactively; if a maintainer wants it, say so on this PR and I will switch it and record the request.
Session id: cron:clickhouse-review-slot-10:20260831-234400
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-41:20260831-223900 Verification: 200/200 randomized runs over |
|
Workflow [PR], commit [44a9802] Summary: ✅
AI ReviewSummaryThis PR rebases the post- Findings❌ Blockers
Final Verdict❌ Request changes. The new Azure named-collection masking helper is still too permissive for unknown overrides, and the author-deferred multi-credential connection-string leak is still reachable on the backup-locator paths introduced here. LLVM Coverage ReportMeasured on commit 44a9802.
Changed lines: Changed C/C++ lines covered: 191/196 (97.45%) · Uncovered code |
|
cc @jkartseva @tavplubix, could you review this? |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units17 translation units recompiled, 71 s compile time in total, 17 of them have a recent master baseline. |
|
Confirmed and fixed in 18822a2. Both cited facts hold at source:
The A locator is printed verbatim only when its engine holds no credential in its arguments ( I did not reconstruct the Azure signature argument by argument: its accepted forms (3 positionals, The regression case joins the The changelog entry and the description claimed |
|
cc @orloffv |
CI finish ledger - e98ca33Every 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.
Both merged owners landed after this tree was built, which is why they are absent from it. I am holding the master merge until #117433 and #117326 merge, so one rebuild picks up every owner instead of four. Session id: cron:our-pr-ci-monitor:20260901-153000 |
|
@groeneai Merge master please |
|
@jkartseva Merged master at Clean merge, no conflicts and no submodule pins moved. The diff against master is unchanged at 13 files, +486/-30. I rebuilt on the merged tree and the four stateless tests this PR touches pass locally ( |
|
TL;DR: the residual this PR discloses ("a metadata file a pre-fix
The forward fix itself looks right — |
|
Both confirmed, and both are fixed here rather than in a follow-up (head 1. The remedy was unreachable, and the description no longer claims it. Measured on the
2. The second consumer now runs the same normalizer. One consequence of accepting the string form was worth closing with it. #118349 is closed by this PR, named in the changelog entry and in the linked-issue block. |
Cherry pick #117429 to 26.9: Mask secrets in SHOW CREATE DATABASE of a Backup database
Cherry pick #117429 to 26.8: Mask secrets in SHOW CREATE DATABASE of a Backup database
|
Confirmed, and on 26.3 and 26.7 the chain is one step longer than that. #118674 edits #114405 itself sits on #110610 ("Add factory-owned backup destination identity", merged 2026-07-23, no backport label): 26.8 and 26.9 need nothing further: #122173 and #122172 landed #118674 there, the robot re-tried my cherry-picks #121968 and #121967 against the moved heads and merged both, and the resulting backports #122202 and #122209 are mergeable with CI still running. I will follow up on those two if anything reds. If the full chain is not worth it for 26.3 and 26.7, there is a cheaper option. On those branches |
Backport #117429 to 26.9: Mask secrets in SHOW CREATE DATABASE of a Backup database
Backport #117429 to 26.8: Mask secrets in SHOW CREATE DATABASE of a Backup database
The bot's base predates the prerequisite (#122640), so 26.3 is merged in first and the cherry-pick on top of that. Conflicts resolved as in the already-merged 26.6 and 26.4 cherry-picks of the same change; the delta is byte-identical to them outside the integration test: - `registerBackupEngineS3.cpp`: kept 26.3's `collectCredentials` call without `->clone()`, and with it master's paragraph about `BackupImpl::writeBackupMetadata` comparing locators as text. - `test_mask_sensitive_info/test.py` and `04510_s3_explicit_url_named_secret_mask.{sql,reference}`: empty release side, took the added blocks. 26.3 gains both new test functions, where private 26.4 gained only the Azure one because it already had the S3 one. Related: #121965 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Cherry pick #117429 to 26.3: Mask secrets in SHOW CREATE DATABASE of a Backup database
Cherry pick #117429 to 26.7: Mask secrets in SHOW CREATE DATABASE of a Backup database
The bot's base predates the prerequisite (#122641), so 26.7 is merged in first and the cherry-pick on top of that. Conflicts resolved as in the already-merged 26.6 cherry-pick and the 26.4/26.3 ones; the applied delta is byte-identical to them: - `registerBackupEngineS3.cpp`: kept 26.7's `collectCredentials` call without `->clone()`, and with it master's paragraph about `BackupImpl::writeBackupMetadata` comparing locators as text. - `04510_s3_explicit_url_named_secret_mask.{sql,reference}`: empty release side, took the added `system.query_log` masking assertion. Related: #121966 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
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]>
`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]>
`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).
`translateAzureSdkParseError` does not cover this: it catches
`std::logic_error`, and the base64 failure is a `std::runtime_error`. 26.7
already has that guard and still fails this arm, so the validator is a
separate, additional backport.
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=122674&sha=f287da9ce8b0c957579b67372272c437d1f35045&name_0=BackportPR
Related: #117429
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Backport #117429 to 26.7: Mask secrets in SHOW CREATE DATABASE of a Backup database
Backport #117429 to 26.3: Mask secrets in SHOW CREATE DATABASE of a Backup database
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed a
Backupdatabase engine printing the credentials of its destination in plaintext.SHOW CREATE DATABASE,system.databases.engine_full,system.query_logand the messages thatreject a malformed locator showed an
AzureBlobStorageaccount_key, a connection string or apresigned URL regardless of
format_display_secrets_in_show_and_select.Description
Related: https://github.com/ClickHouse/clickhouse-private/issues/69069
Related: #118349
Requested by @ nikitamikhaylov; verified by @ oranjeai.
Reading a
Backupdatabase's definition needs onlySHOW_DATABASES, implied by any grant on it.#118674 renders the locator as the function it is, so the pre-existing nested-
S3rule redacts it.This PR covers the shapes that rule does not model, and the messages that reject a locator.
FunctionSecretArgumentsFinder: onlyBackup(database_name, locator)has known slots, so anyother shape hides every argument, as does a locator whose engine is not the reconstructed
S3-unless its arguments are exactly the literals that engine reads, which name a destination and no
credential (
File,Disk,Memory,Null). AnAzureBlobStoragedestination reads a differentsignature than the table engine of the same name, so it gets its own rule, and both now fail
closed on an account url that is no plain storage account URL and on a named-collection override
that is unreadable, repeated, or paired with another credential. Engine names and arity stay
visible, and a statement is logged before validation rejects it.
BackupInfo::fromAST, thedatabase_namecheck ofDatabaseBackup::parseArguments, theS3creator, and bothduplicate-definition messages of
BackupMetadataFinder, database and table.Each change has an arm measured to redden without it:
04510, two new stateless tests, andtest_mask_sensitive_info.Rebased on #118674, which owns #118349. Its definition rendering, its acceptance of a locator held
in a string literal while metadata is replayed, and its refusal of one elsewhere are dropped here,
along with the tests that covered them. Archives still store definitions unmasked, so backups stay
restorable. Unchanged: the shared Azure connection-string helper (#114946, #114964).
Workflow [PR]
Sync PR [sync-upstream/pr/117429]
Version info
26.10.1.565-master(included in26.10and later)26.9.2.37,26.8.11.50,26.7.18.2,26.3.37.3