Skip to content

Forward static S3 credentials for Unity DataLakeCatalog tables - #96910

Merged
fm4v merged 26 commits into
ClickHouse:masterfrom
kgeg401:fix-96798-unity-gcs-static-creds
Jul 6, 2026
Merged

fm4v merged 26 commits into
ClickHouse:masterfrom
kgeg401:fix-96798-unity-gcs-static-creds

Conversation

@kgeg401

@kgeg401 kgeg401 commented Feb 14, 2026 •

Copy link
Copy Markdown
Contributor

Forward static S3-compatible credentials from DataLakeCatalog database settings into Unity catalog table reads when catalog-vended credentials are disabled (vended_credentials = false).

Before this change, if vended_credentials = false, Unity table reads backed by S3-compatible storage (including GCS HMAC via storage.googleapis.com) could run without credentials even when the database settings provided aws_access_key_id and aws_secret_access_key. As a result, Delta kernel object-store requests could be anonymous and fail with HTTP 403.

Closes: #96798

What changed

  • Added DataLake::tryGetStaticStorageCredentials:
    • src/Databases/DataLake/StaticStorageCredentials.h
    • src/Databases/DataLake/StaticStorageCredentials.cpp
  • Updated DatabaseDataLake::tryGetTableImpl:
    • Compute table storage type before credential injection.
    • If catalog-vended credentials are absent, try static credentials from database settings for S3 storage and append them to engine args.
    • Keep existing vended-credential validation behavior as fallback.
    • When static credentials were applied (or vended_credentials = false with no static credentials), suppress the catalog-vended refresh callback so it cannot silently override the user-supplied credentials. Glue provider-chain refresh (STS/role/instance-profile/web-identity) remains active because it is orthogonal to credential vending.
  • Added backward-compatible storage_aws_* settings support, without mixing the two namespaces, and masking for them in SETTINGS_TO_HIDE.
  • Added unit tests (src/Databases/DataLake/tests/gtest_static_storage_credentials.cpp) covering aws_* settings, storage_aws_* compatibility settings, precedence when both are set, missing-key handling, and non-S3 storage handling.
  • Added an integration regression test (tests/integration/test_database_iceberg_lakekeeper_catalog) asserting that with vended_credentials = false and only static credentials in database settings, a read with the correct static pair succeeds and a read with a wrong static pair fails (rather than being silently rescued by a leaked catalog refresh callback).

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

Forward static S3 credentials to Unity DataLakeCatalog table reads when vended_credentials is disabled, preventing anonymous object-storage access failures.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

  • Merged into: 26.7.1.543 (included in 26.7 and later)

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Feb 15, 2026
@clickhouse-gh

clickhouse-gh Bot commented Feb 15, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [adfb275]

Summary: ✅


AI Review

Summary

This PR now does what it claims: for non-Glue DataLakeCatalog S3-compatible table reads, static aws_* / storage_aws_* credentials from database settings are forwarded when vended_credentials = false, while catalog-vended refresh callbacks are suppressed only in the cases where they would override user intent. The earlier Glue provider-chain and leaked-refresh issues raised in review are fixed in the current code, the new masking and setting-description changes are in place, and the added unit plus integration coverage matches the regression being fixed. I found no remaining review findings to post inline. Residual coverage risk is limited to environment-specific Unity/GCS deployments: the checked-in end-to-end test exercises the shared REST/Lakekeeper path rather than a public Unity/GCS setup, but the changed credential wiring itself lives in the common DatabaseDataLake::tryGetTableImpl path and current CI is green.

Final Verdict
  • Status: ✅ Approve

@alexey-milovidov

Copy link
Copy Markdown
Member

Hi @kgeg401! Thanks for the contribution.

Could you please update the PR description to follow the PR template? Specifically, it should include:

  1. A Changelog category section with exactly one category selected (e.g., - New Feature, - Improvement, etc.)
  2. A Changelog entry — a short, user-readable description of the change (unless the category doesn't require one).

This helps us maintain accurate changelogs for our users. Thank you!

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Feb 15, 2026
@kgeg401
kgeg401 force-pushed the fix-96798-unity-gcs-static-creds branch from 10da76e to 84c948d Compare February 28, 2026 16:03
@melvynator melvynator added the comp-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. label Feb 28, 2026
@kgeg401

kgeg401 commented Mar 1, 2026

Copy link
Copy Markdown
Contributor Author

No code changes in this pass for #96910. The branch remains scoped to static credential forwarding and associated unit tests, with prior CI green. Please re-review/merge when maintainer bandwidth allows.

@alexey-milovidov

Copy link
Copy Markdown
Member

@melvynator will review this PR.

@kgeg401

kgeg401 commented Mar 8, 2026

Copy link
Copy Markdown
Contributor Author

@melvynator Scope is unchanged, CI is green, and this is ready for your review when you have a cycle.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

@melvynator

Copy link
Copy Markdown
Member

@kgeg401 Did you test the PR against a real catalog?

On AWS:

CREATE DATABASE unity_demo
ENGINE = DataLakeCatalog('https://<environment>.cloud.databricks.com/api/2.1/unity-catalog/iceberg-rest')
SETTINGS catalog_type = 'rest', catalog_credential = 'client_id:client_secret', warehouse = 'icebench', oauth_server_uri = 'https://<environment>.cloud.databricks.com/oidc/v1/token', auth_scope = 'all-apis,sql', vended_credentials = false, aws_access_key_id = 'key', aws_secret_access_key = 'wrong_secret'
SELECT *
FROM unity_demo.`tpch.nation`
LIMIT 1

Query id: 44a57bde-5629-4991-9d14-3300f22caca1

   ┌─n_nationkey─┬─n_name──┬─n_regionkey─┬─n_comment───────────────────────────────────────────┐
1. │           0 │ ALGERIA │           0 │  haggle. carefully final deposits detect slyly agai │
   └─────────────┴─────────┴─────────────┴─────────────────────────────────────────────────────┘

1 row in set. Elapsed: 0.702 sec.

@alexey-milovidov alexey-milovidov added the close in a month if not active This will be closed in case of no information label Mar 22, 2026
@ryuan-cw

Copy link
Copy Markdown

is there any update on this bug fix? can we have it merged to master?

@melvynator

Copy link
Copy Markdown
Member

From my testing the S3 credentials were not passed correctly.

We need it as part of our E2E testing so we will fix it, but if you want to fix it please go ahead.

When a user sets vended_credentials=false on a DataLakeCatalog database
together with static credentials (aws_access_key_id / aws_secret_access_key),
their intent is that the catalog should not be consulted for object-store
credentials at all. However, the catalog's refresh callback was wired into
every storage created from such a database, so a transient access error
would silently trigger a vended-credentials fetch and overwrite the user's
static credentials. As @melvynator reported on
ClickHouse#96910, this caused a query
to succeed against S3 even when the user supplied a deliberately wrong
secret, masking misconfiguration.

Drop the catalog refresh callback when vended_credentials=false, so the
static credentials configured above remain the only credentials used.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member

@melvynator I traced through the case you reported. The static credentials were being attached to the table engine arguments, but the catalog's getCredentialsConfigurationCallback was passed unconditionally into createObjectStorage. So when the initial S3 request with the wrong secret failed, S3ObjectStorage::getObjectMetadata (and friends) invoked the refresh callback, the catalog handed out vended credentials, and the read succeeded — silently masking the fact that the user's aws_secret_access_key='wrong_secret' had been honored.

I pushed commit 110419bb85c which gates that refresh callback on vended_credentials: when vended_credentials=false, we now pass std::nullopt so the static credentials remain the sole credentials used. With this in place, the scenario in your comment (aws_secret_access_key='wrong_secret', vended_credentials=false) should fail with a proper access-denied error from S3 instead of silently succeeding.

Could you re-run your test against this commit when you get a chance?

…-static-creds

# Conflicts:
#	src/Databases/DataLake/DatabaseDataLake.cpp
@clickhouse-gh clickhouse-gh Bot added the manual approve Manual approve required to run CI label May 19, 2026
…-static-creds

# Conflicts:
#	.github/workflows/pull_request.yml
@zlareb1

zlareb1 commented May 21, 2026

Copy link
Copy Markdown
Member

@melvynator I traced through the case you reported. The static credentials were being attached to the table engine arguments, but the catalog's getCredentialsConfigurationCallback was passed unconditionally into createObjectStorage. So when the initial S3 request with the wrong secret failed, S3ObjectStorage::getObjectMetadata (and friends) invoked the refresh callback, the catalog handed out vended credentials, and the read succeeded — silently masking the fact that the user's aws_secret_access_key='wrong_secret' had been honored.

I pushed commit 110419bb85c which gates that refresh callback on vended_credentials: when vended_credentials=false, we now pass std::nullopt so the static credentials remain the sole credentials used. With this in place, the scenario in your comment (aws_secret_access_key='wrong_secret', vended_credentials=false) should fail with a proper access-denied error from S3 instead of silently succeeding.

Could you re-run your test against this commit when you get a chance?

@alexey-milovidov I verified on Private PR with commit cherry-picked. I added explicit regression tests for scenario — aws_secret_access_key='WRONG_SECRET' + vended_credentials=false — on both dispatch paths:

  • test_database_iceberg_lakekeeper_catalog/test.py::test_wrong_static_creds_with_vended_disabled_must_fail (catalog_type='rest' against Lakekeeper + MinIO).
  • test_e2e_unity_catalog_static_credentials/test.py::test_unity_wrong_static_creds_with_vended_disabled_must_fail (catalog_type='unity' against OSS Unity Catalog + real S3).

Both pass: the SELECT fails with an S3 credential error rather than silently succeeding via the refresh callback.

Workflow files in this branch were stale or had been deleted as a
workaround for GitHub's workflow-scope check. Restoring them to match
`master` so the PR diff no longer contains those unrelated changes.
@alexey-milovidov

Copy link
Copy Markdown
Member

Continued work on this PR:

  • Added the regression test requested in review (35b4d9e9195): test_static_credentials_when_vended_credentials_disabled in tests/integration/test_database_iceberg_lakekeeper_catalog. With vended_credentials = false and static credentials only in database settings, it asserts that a read with the correct static pair succeeds and a read with a wrong static pair fails. Lakekeeper vends working storage credentials, so a leaked catalog refresh callback would silently rescue the wrong-pair read — the test catches exactly the regression class discussed earlier in this PR. Verified locally against the dockerized Lakekeeper + MinIO cluster: 1 passed in 41.16s.
  • Diagnosed the red CH Inc sync (tests failed): the two failed stateless jobs are known-flaky SharedMergeTree tests unrelated to this PR (auto-matched by CI to existing private flaky-test issues), and the Check public build gate asked for precisely the regression test added above. The push re-triggers the sync.

No production code changes in this pass.

The descriptions of `aws_access_key_id`, `aws_secret_access_key` and the
`storage_aws_*` pair only mentioned the `Glue` catalog. Since this PR also
forwards these settings as static S3 storage credentials for non-`Glue`
`DataLakeCatalog` table reads when `vended_credentials = false`, the
descriptions (which feed user-facing settings docs/help) were misleading.
Update them to describe both uses and fix a stray trailing apostrophe in the
secret-key descriptions.

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

zlareb1 commented Jun 18, 2026

Copy link
Copy Markdown
Member

Hi @kgeg401 are you still working on this?

@alexey-milovidov

Copy link
Copy Markdown
Member

Continued work on this PR:

  • Re-merged current master to refresh the merge base (the branch was 2093 commits behind). The merge is conflict-free, and the net diff against master is exactly this PR's 9 files (+347 / -20).
  • Diagnosed and resolved the red CH Inc sync. On the previous head, Check public build in the private sync failed with error: use of undeclared identifier 'Documentation' in src/Databases/DataLake/DatabaseDataLake.cpp. The cause was a stale merge base: between this PR's old base and the snapshot the sync built against (taken mid-way through the "Add embedded documentation for database engines" work), master extended DatabaseFactory::registerDatabase with a trailing Documentation parameter and updated registerDatabaseDataLake to pass Documentation{...}. The Documentation type is provided transitively by <Common/Documentation.h> through <Databases/DatabaseFactory.h>. Merging the now-consistent master carries both master's Documentation{...} registration and this PR's credential changes (which are confined to DatabaseDataLake::tryGetTableImpl), with <Databases/DatabaseFactory.h> still included, so the identifier is back in scope.
  • The other red jobs in that sync run (integration / stress shards) were downstream of the same build skew and of EventFeed S3 PutObject PreconditionFailed races in the runner's post-run step — not this PR's changes.

The re-merge re-triggers public CI and the sync. The new unit tests are unchanged by the merge (StaticStorageCredentialsTest.*, ParserCreateDatabaseQuery.MaskDataLakeCatalogStorageCredentials).

@kgeg401

kgeg401 commented Jun 20, 2026

Copy link
Copy Markdown
Contributor Author

@zlareb1 Yes, still engaged here. Alexey has continued the PR and the latest public CI run is green with review threads resolved.

From my side, the remaining blocker I see is the private CH Inc sync / build status, and master has moved again since the last refresh. I can refresh the branch against current master to retrigger checks; after that, if CH Inc sync stays red, we'll need a maintainer to inspect or rerun the private sync.

…-static-creds

# Conflicts:
#	src/Parsers/tests/gtest_Parser.cpp
@kgeg401

kgeg401 commented Jun 20, 2026

Copy link
Copy Markdown
Contributor Author

Updated the branch against current master in 85dee480abb. The automatic update had one conflict in src/Parsers/tests/gtest_Parser.cpp; I resolved it by keeping both upstream's new parser child-order tests and this PR's MaskDataLakeCatalogStorageCredentials regression test.

The PR is now mergeable again on GitHub; public CI and sync are rerunning on the refreshed head.

@clickhouse-gh

clickhouse-gh Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.50% 85.50% +0.00%
Functions 92.60% 92.70% +0.10%
Branches 77.70% 77.70% +0.00%

Changed lines: Changed C/C++ lines covered: 137/153 (89.54%) · Uncovered code

Full report · Diff report

@fm4v
fm4v added this pull request to the merge queue Jul 6, 2026
@fm4v

fm4v commented Jul 6, 2026

Copy link
Copy Markdown
Member

@zlareb1 please run e2e tests with Unity catalog to validate the fix

Merged via the queue into ClickHouse:master with commit d5648e8 Jul 6, 2026
175 checks passed
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 6, 2026
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Jul 6, 2026
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]>
@scanhex12 scanhex12 added the pr-must-backport Pull request should be backported intentionally. Use this label with great care! label Aug 25, 2026
@robot-ch-test-poll robot-ch-test-poll added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Aug 25, 2026
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Sep 4, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…static-creds

Forward static S3 credentials for Unity DataLakeCatalog tables
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
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]>
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 close in a month if not active This will be closed in case of no information comp-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. manual approve Manual approve required to run CI 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.

Add gcs unity catalog support to DataLakeCatalog

10 participants