Skip to content

Hide legacy storage_* credential settings of DataLakeCatalog - #108470

Merged
alexey-milovidov merged 3 commits into
ClickHouse:masterfrom
groeneai:fix-datalake-catalog-storage-credential-leak
Jul 11, 2026
Merged

alexey-milovidov merged 3 commits into
ClickHouse:masterfrom
groeneai:fix-datalake-catalog-storage-credential-leak

Conversation

@groeneai

@groeneai groeneai commented Jun 25, 2026 •

Copy link
Copy Markdown
Collaborator

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 a credential leak where the legacy storage_aws_access_key_id, storage_aws_secret_access_key, storage_catalog_credential, and storage_auth_header settings of the DataLakeCatalog database engine were shown in plaintext in system.databases.engine_full and SHOW CREATE DATABASE. They are now redacted as [HIDDEN].

Closes: #104951

Description

DataLakeCatalog accepts the legacy storage_* family of settings at CREATE DATABASE (originally added for the Glue catalog), but four credential-bearing ones were missing from DataLake::SETTINGS_TO_HIDE. Their secret values leaked verbatim into system.databases.engine_full and SHOW CREATE DATABASE, readable by any user with SELECT on system.databases. The canonical aws_* / catalog_credential / auth_header names were already redacted; only the storage_* aliases leaked.

engine_full is built at format time via the SETTINGS_TO_HIDE map in src/Parsers/ASTSetQuery.cpp, which bypasses the runtime SensitiveDataMasker (that masker only covers system.query_log). Adding the four storage_* aliases to the map fixes the leak for engine_full, SHOW CREATE DATABASE, and the formatted query in the server log.

These four are the complete set of credential-bearing storage_* settings declared in src/Storages/ObjectStorage/DataLakes/DataLakeStorageSettings.h. The remaining storage_* settings are non-secret (storage_auth_scope, storage_oauth_*, storage_warehouse, storage_region, storage_aws_role_arn, storage_aws_role_session_name, object_storage_endpoint, storage_catalog_url, disk).

Regression test 04401_datalake_catalog_hide_storage_credentials formats a CREATE DATABASE ... ENGINE = DataLakeCatalog query carrying all four storage_* aliases and the four canonical names, and asserts each prints [HIDDEN]. It fails on master (the storage_* values print verbatim) and passes with this fix.

Version info

  • Merged into: 26.7.1.806 (included in 26.7 and later)
  • Backported to: 26.6.4.64, 26.3.29.5, 25.8.34.4

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. echo "CREATE DATABASE d ENGINE = DataLakeCatalog('http://x/c') SETTINGS catalog_type='rest', storage_aws_secret_access_key='SECRET'" | clickhouse format prints storage_aws_secret_access_key = 'SECRET' verbatim on master (all 4 storage_* aliases leak); the canonical aws_secret_access_key already prints [HIDDEN].
b Root cause explained? engine_full / SHOW CREATE DATABASE are built at format time by ASTSetQuery::formatImpl, which redacts a setting only when DataLake::SETTINGS_TO_HIDE.contains(change.name). The map listed aws_* / catalog_credential / auth_header but not their legacy storage_* aliases, so those four printed raw. This path bypasses the runtime SensitiveDataMasker (which only covers system.query_log).
c Fix matches root cause? Yes. Adds exactly the four missing credential-bearing aliases (storage_catalog_credential, storage_auth_header, storage_aws_access_key_id, storage_aws_secret_access_key) to SETTINGS_TO_HIDE, next to their canonical counterparts. No symptom band-aid.
d Test intent preserved / new tests added? New regression test 04401_datalake_catalog_hide_storage_credentials asserts each of the four storage_* aliases and the four canonical names format as [HIDDEN], and that the secret literal never appears.
e Both directions demonstrated? Yes. Test FAILS on the unpatched binary (the four storage_* values print verbatim, leak guard reports FAIL) and PASSES on the patched binary (10/10 runs through clickhouse-test).
f Fix is general across code paths? Yes. SETTINGS_TO_HIDE is the single redaction map consumed by ASTSetQuery::formatImpl for the DataLakeCatalog engine; it covers engine_full, SHOW CREATE DATABASE, and the formatted query in the server log in one place. The four added are the complete credential-bearing storage_* set in DataLakeStorageSettings.h; the remaining storage_* settings are non-secret.
g Fix generalizes across inputs? Redaction is keyed purely on the setting NAME and replaces the value with a constant [HIDDEN], independent of the value's type/length/content. There is no storage_* alias for the onelake/google/dlf secrets (already hidden), so the matrix is complete.
h Backward compatible? Yes. No setting default, on-disk/wire format, or validation changes. The only observable change is that previously-leaked secrets now render [HIDDEN], matching the existing canonical-name behavior. show_secrets/format.show_secrets still reveals them as before.
i Invariants and contracts preserved? Yes. SETTINGS_TO_HIDE is a name→masking-func map; the four new entries reuse DEFAULT_MASKING_RULE exactly like the existing credential entries. No parser/formatter contract or data-structure invariant is touched.

Session id: cron:clickhouse-worker-slot-1:20260625-120100

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @kssenii @alesapin - could you review? Adds the four legacy storage_* credential aliases (storage_catalog_credential, storage_auth_header, storage_aws_access_key_id, storage_aws_secret_access_key) to DataLake::SETTINGS_TO_HIDE; they were leaking plaintext into system.databases.engine_full while the canonical names were already redacted.

@nikitamikhaylov nikitamikhaylov added the can be tested Allows running workflows for external contributors label Jun 25, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [61a84bd]

Summary: ✅


AI Review

Summary

This PR broadens DataLake secret redaction in ASTSetQuery::formatImpl so the shared DataLakeStorageSettings secrets are masked for non-DataLakeCatalog engines as well, and adds a regression test for the formatter path. I reviewed the current diff together with the existing discussion and did not find a remaining correctness or security issue in the patched code.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Jun 25, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger — 4ca07ba

Every failure below has an owner: a fixing PR (ours or external). Only CH Inc sync (private sync) is exempt. None are caused by this PR (it only adds the four legacy storage_* credential aliases to SETTINGS_TO_HIDE + a stateless test); all are pre-existing chronic-trunk / flaky signatures (CIDB 30d cross-PR counts shown).

Check / test Reason Owner / fixing PR
Stress test (arm_release) / Hung check failed, possible deadlock found chronic trunk deadlock (447 PRs, 342 master / 30d) #105905 / #101680 (ours, open)
Integration tests (amd_msan, 4/6) / test_s3_plain_rewritable[...metadata_cache...] (REPLACE PARTITION from empty source) flaky (12 PRs, 2 master / 30d) #108350 (ours, open)
Stress test (arm_asan_ubsan) / Not-ready Set is passed as the second argument for function (STID 0250-4e52) chronic trunk logical error (29 PRs, 6 master / 30d) #102192 (external, open)
CH Inc sync private sync CH Inc sync (private, not actionable)
Mergeable Check / PR aggregator roll-up of the rows above, no independent failure

Session id: cron:our-pr-ci-monitor:20260625-180000

@SmitaRKulkarni SmitaRKulkarni self-assigned this Jun 29, 2026

@SmitaRKulkarni SmitaRKulkarni 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.

LGTM

@groeneai
groeneai force-pushed the fix-datalake-catalog-storage-credential-leak branch from 4ca07ba to 63d7f57 Compare July 6, 2026 14:39
The DataLake credential-bearing settings (catalog_credential, auth_header,
aws_access_key_id, aws_secret_access_key and their legacy storage_* aliases)
are declared in DataLakeStorageSettings.h, which is shared by the DataLakeCatalog
database engine AND the Iceberg*/Paimon*/DeltaLake* table engines via
registerStorageObjectStorage.

ASTSetQuery::formatImpl only redacted them when create_engine_name equalled
'DataLakeCatalog', so SHOW CREATE TABLE, system.tables.engine_full and the
formatForLogging path printed the secret values verbatim for the table engines.
Any user with the relevant SELECT/SHOW grant could read them. hasSecretParts()
already treats these settings as secret without an engine gate, so the format
path was inconsistent with it.

Redact DataLake::SETTINGS_TO_HIDE settings regardless of engine name, matching
hasSecretParts(). Extend the regression test to cover the IcebergLocal table
engine in addition to the DataLakeCatalog database engine.

Also adds storage_catalog_credential and storage_auth_header to the redaction
map (storage_aws_* were already added on master by ClickHouse#96910).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@groeneai
groeneai force-pushed the fix-datalake-catalog-storage-credential-leak branch from 63d7f57 to 8968d7d Compare July 6, 2026 15:33
@groeneai

groeneai commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. echo "CREATE TABLE t (x Int32) ENGINE = IcebergLocal('/tmp/x') SETTINGS storage_catalog_credential='SECRET', storage_auth_header='SECRET', aws_secret_access_key='SECRET'" | clickhouse format --oneline prints the secrets verbatim on the pre-fix binary.
b Root cause explained? ASTSetQuery::formatImpl redacted DataLake settings only when create_engine_name == "DataLakeCatalog". DataLakeStorageSettings is shared with the Iceberg*/Paimon*/DeltaLake* table engines, whose create_engine_name is the table-engine name, so the gate never fired and the values printed raw in SHOW CREATE TABLE / system.tables.engine_full.
c Fix matches root cause? Yes. Removed the engine-name gate for DataLake::SETTINGS_TO_HIDE in format_if_secret(), so these settings are redacted regardless of engine, aligning with hasSecretParts() which was already ungated.
d Test intent preserved / new tests added? Extended 04401_datalake_catalog_hide_storage_credentials to assert [HIDDEN] for the IcebergLocal table engine in addition to the DataLakeCatalog database engine. Existing DB-engine assertions unchanged.
e Both directions demonstrated? Pre-fix binary (Build ID e8ca2e56): IcebergLocal leaks all secrets, DataLakeCatalog still hides (proving the leak is table-engine specific). Post-fix binary (Build ID 76d14717): both engines print [HIDDEN]; test output matches .reference.
f Fix is general across code paths? Yes. The single format path (ASTSetQuery::formatImpl) is the common code for SHOW CREATE, engine_full and formatForLogging, for every engine that uses these settings. No sibling format path exists.
g Fix generalizes across inputs? Applies to all four credential settings and their canonical names, for the DB engine and all table engines that share DataLakeStorageSettings. Redaction is keyed on setting name, independent of value/type.
h Backward compatible? Yes. Behavior change is strictly redacting previously-leaked secrets; no setting default, on-disk/wire format, or new data validation is affected.
i Invariants and contracts preserved? Yes. Now consistent with hasSecretParts() (which already reported these as secret). format.show_secrets still bypasses redaction for the internal show-secrets path, unchanged.

Session id: cron:clickhouse-worker-slot-1:20260706-152500

@alexey-milovidov

Copy link
Copy Markdown
Member

Updating the branch to fix the 04001_join_reorder_through_expression test, which was broken today in master.

@groeneai

groeneai commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger — 63c8c41

Every failure below has an owner: a fixing PR (ours 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
Fast test (arm_darwin) / 03230_keeper_cp_mv_commands flaky (macOS ENOTCONN socket teardown in ZooKeeper::finalize; 7 unrelated PRs / 0 master, 30d) #107438 (ours, open)
Stress test (arm_tsan) / ThreadSanitizer data race (STID 1464-31ed) trunk data race (UniqExactSet two-level parallel merge; 17 PRs / 1 master, 30d) #109389 (ours, open)
Mergeable Check / PR aggregator roll-up of the above —

No PR-caused failure: this PR only adds DataLake storage_* credential settings to the redaction map (+ removes the engine-name gate so they redact on all engines) and a stateless format test. Neither failing area (KeeperClient teardown, uniqExact parallel merge) is touched by the diff.

Session id: cron:our-pr-ci-monitor:20260706-233000

@SmitaRKulkarni

Copy link
Copy Markdown
Member

@groeneai : unrelated fails in fasttest, could you please merge master again to rerun all tests

@groeneai

groeneai commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author

@SmitaRKulkarni merged current master (into 61a84bd), pushed. CI re-running.

@clickhouse-gh

clickhouse-gh Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.70% 85.70% +0.00%
Functions 92.70% 92.70% +0.00%
Branches 77.90% 77.90% +0.00%

Changed lines: Changed C/C++ lines covered: 5/5 (100.00%) · Uncovered code

Full report · Diff report

@SmitaRKulkarni

Copy link
Copy Markdown
Member

@groeneai please merge master again to rerun ci

robot-clickhouse-ci-1 added a commit that referenced this pull request Aug 27, 2026
Cherry pick #108470 to 25.8: Hide legacy storage_* credential settings of DataLakeCatalog
robot-clickhouse added a commit that referenced this pull request Aug 27, 2026
robot-clickhouse-ci-1 added a commit that referenced this pull request Aug 27, 2026
Cherry pick #108470 to 26.3: Hide legacy storage_* credential settings of DataLakeCatalog
robot-clickhouse added a commit that referenced this pull request Aug 27, 2026
robot-clickhouse-ci-1 added a commit that referenced this pull request Aug 27, 2026
Cherry pick #108470 to 26.5: Hide legacy storage_* credential settings of DataLakeCatalog
robot-clickhouse added a commit that referenced this pull request Aug 27, 2026
robot-clickhouse-ci-1 added a commit that referenced this pull request Aug 27, 2026
Cherry pick #108470 to 26.6: Hide legacy storage_* credential settings of DataLakeCatalog
robot-clickhouse added a commit that referenced this pull request Aug 27, 2026
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Aug 27, 2026
alexey-milovidov added a commit that referenced this pull request Aug 27, 2026
Backport #108470 to 26.5: Hide legacy storage_* credential settings of DataLakeCatalog
alexey-milovidov added a commit that referenced this pull request Aug 27, 2026
Backport #108470 to 25.8: Hide legacy storage_* credential settings of DataLakeCatalog
clickhouse-gh Bot added a commit that referenced this pull request Aug 31, 2026
Backport #108470 to 26.6: Hide legacy storage_* credential settings of DataLakeCatalog
alexey-milovidov added a commit that referenced this pull request Sep 1, 2026
Backport #108470 to 26.3: Hide legacy storage_* credential settings of DataLakeCatalog
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…og-storage-credential-leak

Hide legacy storage_* credential settings of DataLakeCatalog
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 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.

DataLakeCatalog: storage_aws_* setting secrets leak into system.query_log (not in SETTINGS_TO_HIDE)

8 participants