Skip to content

Make delta-kernel follow the session restriction on Azure server credentials - #112637

Merged
SmitaRKulkarni merged 45 commits into
ClickHouse:masterfrom
omar12eladawy:fix-53850-delta-kernel-azure-workload-identity
Nov 20, 2026
Merged

SmitaRKulkarni merged 45 commits into
ClickHouse:masterfrom
omar12eladawy:fix-53850-delta-kernel-azure-workload-identity

Conversation

@omar12eladawy

@omar12eladawy omar12eladawy commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Since #128445, DeltaLakeAzure / deltaLakeAzure read through delta-kernel with Azure workload identity (extra_credentials(client_id = ..., tenant_id = ...), use_workload_identity). Since #120343, a SQL-defined Azure storage that uses the server's own identity follows the allow_server_credentials_in_user_queries restriction of each accessing session. The delta-kernel path did not:

  • AzureKernelHelper kept a copy of the connection params taken when the table metadata was created, so a restricted session could forward the server's identity to delta-kernel. It now reads the live getAzureBlobStorageConnectionParams() in createBuilder, as S3KernelHelper does.
  • TableSnapshot caches built kernel engines and rebuilds them only when the credentials fingerprint changes, which was always empty for Azure. The fingerprint now covers the session restriction, so for a restricted session a cached engine is rebuilt and refused with ACCESS_DENIED.
  • getSnapshotStats and the schema getters returned cached values without that check, so with delta_lake_snapshot_version pinned a restricted session could get count() or the schema of a snapshot an opted-in session had cached. They now check first.

Also:

  • connection_string together with client_id / tenant_id is rejected with BAD_ARGUMENTS instead of being accepted.
  • Docs: workload identity for DeltaLakeAzure, deltaLakeAzure, deltaLakeAzureCluster, azureBlobStorage and azureBlobStorageCluster, including the session opt-in; the Azure DeltaLake examples use DeltaLakeAzure.

Tests: test_azure_workload_identity gets DeltaLakeAzure cases on a second node with a plain-HTTP mock that serves a minimal Delta log: after an opted-in read, a restricted session is refused without a token or storage request, also for a pinned count() served from cached stats. Unit tests cover non-default and private-link hosts, explicit IDs surviving reattach, and connection_string with extra_credentials.

Related: #113267 (resolved by #128445), #120343

Changelog category (leave one):

  • Improvement

Changelog entry:

DeltaLakeAzure with the server's own Azure identity (workload or managed identity) now follows the allow_server_credentials_in_user_queries restriction of each querying session in the delta-kernel path, including for cached snapshots.


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

Version info

  • Merged into: 26.12.1.50-master (included in 26.12 and later)

@CLAassistant

CLAassistant commented Jul 30, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@omar12eladawy
omar12eladawy marked this pull request as ready for review July 30, 2026 17:04
@matsjfunke

Copy link
Copy Markdown

would also unblock my usecase, please consider merging

@rschu1ze

rschu1ze commented Aug 4, 2026

Copy link
Copy Markdown
Member

@SmitaRKulkarni Like to check this PR?

@SmitaRKulkarni SmitaRKulkarni self-assigned this Aug 4, 2026
@SmitaRKulkarni SmitaRKulkarni added the can be tested Allows running workflows for external contributors label Aug 4, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [7c9ff00]

Summary: ✅


AI Review

Summary

The PR makes the Azure delta-kernel helper read live connection parameters and checks each session before returning Delta Lake metadata or creating read/write operations. It also documents workload identity and adds direct metadata-entrypoint tests. The earlier coverage finding is addressed. One previously reported credential-selection bypass remains; no new inline findings were identified.

Findings

❌ Blockers

  • AzureBlobStorageCommon.cpp:288: Empty explicit account keys bypass the session restriction. [dismissed by author -- https://github.com/Make delta-kernel follow the session restriction on Azure server credentials #112637#discussion_r4576252726] The author deferred this pre-existing issue to a follow-up, but the current code still permits it: attaching a table with account_name = 'acct', account_key = '', and server credentials enabled creates a StorageSharedKeyCredential with forbid_implicit_credentials = false. usesServerManagedCredentials returns false, so the restricted session passes the new metadata checks. getAzureBuilderOptions then omits both the empty key and azure_skip_signature (KernelHelper.cpp:397). The pinned Rust client consequently selects managed identity, allowing restricted queries to read metadata when that identity has access. This selection follows the credential branches in the object_store 0.13.2 source. Reject empty explicit keys or preserve explicit authentication without implicit fallback. No concrete follow-up is linked in the thread; its resolution and the author's decision are left unchanged.
Tests
  • ⚠️ Cover the empty-key case through getAzureConnectionParams and a restricted metadata entrypoint after an opted-in attach; assert rejection or explicit authentication without a managed-identity request.
Missing context / blind spots
  • ⚠️ No local build or ClickHouse binary is available, so the C++ and Azure integration tests were inspected but not executed here. Targeted CI results would close this runtime-validation gap; the retrieved Praktika report provides no individual results for those jobs.
Final Verdict

Status: ❌ Block. Close the remaining implicit-authentication bypass with regression coverage, or link a concrete tracked follow-up for the explicitly deferred pre-existing issue before treating the security contract as complete.

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Aug 4, 2026
@omar12eladawy

Copy link
Copy Markdown
Contributor Author

@SmitaRKulkarni hello I see the PR / Stress test to be flaky on the master itself is it a review blocker ?

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

Rest all LGTM

@clickhouse-gh

clickhouse-gh Bot commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 7c9ff0009 with master 421e0c4b4 (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Object file sizes

13 object files changed (-29.34 KiB total), 0 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Storages/ObjectStorage/DataLakes/DeltaLake/KernelHelper.cpp.o 410.65 KiB 370.35 KiB -40.30 KiB (-9.81%)

716 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Compile time of recompiled translation units

1465 translation units recompiled, 744 s compile time in total, 1465 of them have a recent master baseline.

Job report

@omar12eladawy

Copy link
Copy Markdown
Contributor Author

Documented the Azure workload-identity surface on the Delta Lake pages:

  • extra_credentials(client_id=, tenant_id=) on DeltaLake / DeltaLakeAzure / deltaLakeAzure / deltaLakeAzureCluster
  • named collections (client_id, tenant_id)
  • env requirement: AZURE_FEDERATED_TOKEN_FILE (IDs optional there if passed in SQL; AZURE_AUTHORITY_HOST optional)

Azure extra_credentials is called out as client_id/tenant_id, not the S3 role_arn form on the same page.

@omar12eladawy

Copy link
Copy Markdown
Contributor Author

@SmitaRKulkarni I addressed your comments. Also the Clickhouse gh pointed out the docs so I updated that too. Please let me know i should instead open a seperate docs PR

omar12eladawy and others added 6 commits August 28, 2026 12:00
The SDK credential does not expose the IDs back, so keep them on
ConnectionParams and prefer them over the environment in the builder.

Co-Authored-By: Claude Fable 5 <[email protected]>
Covers the persistence of the IDs on ConnectionParams, not just the
builder plumbing.

Co-Authored-By: Claude Fable 5 <[email protected]>
Previously only plain-HTTP endpoints were forwarded; for sovereign clouds
or custom domains the object_store builder fell back to the default
public host derived from the account name. Applies to all auth branches,
not only workload identity.

Co-Authored-By: Claude Fable 5 <[email protected]>
@omar12eladawy

Copy link
Copy Markdown
Contributor Author

@SmitaRKulkarni heads-up on a scope change: #128445 (removing the legacy Delta reader) added workload identity to the delta-kernel Azure path on master, so I merged master and took its implementation of getAzureBuilderOptions, the ConnectionParams fields and its unit tests, dropping my duplicates.

What this PR still changes on top of master: AzureKernelHelper reads the live connection params, the credentials fingerprint covers the session restriction, and cached snapshot stats and schema are checked before they're returned (the cases you raised — master still has them since it copies the params at metadata creation). Plus the connection_string + client_id/tenant_id rejection, the docs and the integration tests. I retitled the PR and updated the description and changelog entry accordingly. Let me know if you'd rather have it split differently.

@SmitaRKulkarni

Copy link
Copy Markdown
Member

@omar12eladawy :
The new fingerprint reads forbid_implicit_credentials, a flag every session overwrites in applyNewSettings, so a concurrent opted-in session can let a restricted one reuse the cached engine. Instead, call a check at the top of every DeltaLakeMetadataDeltaKernel entrypoint that has a context (inside the try in totalRows / totalBytes), before getTableSnapshot or kernel_helper is used: throw ACCESS_DENIED when context->shouldRestrictUserQueryS3Credentials() && follows_session_restriction && usesServerManagedCredentials(), without looking at the shared flag. Then keep the fingerprint (it's needed for the opposite direction), drop the initOrUpdateSnapshot calls in getSnapshotStats / initOrUpdateSchemaIfChanged, and add a gtest showing the check throws even when forbid_implicit_credentials = false. wdyt ?

omar12eladawy and others added 2 commits November 12, 2026 17:55
The fingerprint reads forbid_implicit_credentials, which every session
overwrites in applyNewSettings, so a concurrent opted-in session could
let a restricted one reuse a cached engine. Check the querying session
itself at the top of each DeltaLakeMetadataDeltaKernel entrypoint that
has a context (inside the try in totalRows / totalBytes), without the
shared flag, via checkSessionMayUseServerIdentityIgnoringSharedFlag.
Keep the fingerprint for the opposite direction and drop the
initOrUpdateSnapshot calls in getSnapshotStats / initOrUpdateSchemaIfChanged.

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

omar12eladawy commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

@SmitaRKulkarni agreed, done in d7e23a1 (after merging master): added ConnectionParams::checkSessionMayUseServerIdentityIgnoringSharedFlag next to checkSessionMayUseServerIdentity, same condition without forbid_implicit_credentials, plus the matching wrapper in Storages/ObjectStorage/Utils.

It's called at the top of every DeltaLakeMetadataDeltaKernel entrypoint with a context (update, getTableSchema, getTableStateSnapshot, buildStorageMetadataFromState, iterate, prepareReadingFromFormat, getTableChanges, write, createInitial, and inside the try in totalRows / totalBytes).

Kept the fingerprint, dropped the initOrUpdateSnapshot calls in TableSnapshot, and added ServerIdentityCheckIgnoresSharedFlag to gtest_azure_configuration.cpp.

omar12eladawy and others added 2 commits November 13, 2026 15:23
The integration tests are refused earlier, when applyNewSettings rebuilds
the client, so they pass without the entrypoint checks. Call each
DeltaLakeMetadataDeltaKernel entrypoint directly with a restricted
session while forbid_implicit_credentials is false, as a concurrent
opted-in session leaves it: each throws ACCESS_DENIED, and totalRows /
totalBytes return no value after logging the refusal. An opted-in
session and a disk pass the check.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
After a restart the table loads with the shared restriction flag already
set, so applyNewSettings does not rebuild the client for a restricted
session and the metadata checks are the only guard.

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

Copy link
Copy Markdown
Member

@omar12eladawy : Can we update the changelog to
"DeltaLakeAzure with the server's own Azure identity (workload or managed identity) now follows the allow_server_credentials_in_user_queries restriction of each querying session in the delta-kernel path, including for cached snapshots."

As this is not an issue for deltaLakeAzure.
Rest all LGTM

@omar12eladawy

Copy link
Copy Markdown
Contributor Author

@SmitaRKulkarni updated the changelog entry, thanks for the review!

@SmitaRKulkarni

Copy link
Copy Markdown
Member

@omar12eladawy : Looks like the test fails are related. Please add stay_alive=True to the cluster.add_instance("delta_node", ...) . I think this is the reason, please try & check

omar12eladawy and others added 7 commits November 16, 2026 10:02
…ernel-azure-workload-identity

# Conflicts:
#	src/Storages/ObjectStorage/DataLakes/DeltaLake/KernelHelper.cpp
restart_clickhouse needs stay_alive=True. Also return the results of the
entrypoints from the gtest lambdas, as master marks them [[nodiscard]].

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ernel-azure-workload-identity

# Conflicts:
#	src/Storages/ObjectStorage/DataLakes/DeltaLake/KernelHelper.cpp
@clickhouse-gh clickhouse-gh Bot added comp-delta-lake Delta Lake tables: reading Delta metadata through delta-kernel-rs (table snapshots, schema and ty... and removed comp-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. labels Nov 19, 2026
@omar12eladawy

Copy link
Copy Markdown
Contributor Author

@SmitaRKulkarni All addressed and merged master for the tests

@stresshouse

stresshouse Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

📊 Cloud Performance Report

✅ AI verdict: no_change — no significant changes across 28 queries analysed

no significant changes detected. K_source=4 K_base=11 flagged=0/65

clickbench

🟢 No significant changes

tpch_adapted_1_official

🟢 No significant changes

Debug info
  • StressHouse run: 93493375-b935-4a4f-86fe-8b88328946ff
  • MIRAI run: 42e99b20-7b41-40d0-b541-dd1458d52065
  • PR check IDs:
    • clickbench_486527_1795185181
    • clickbench_486533_1795185181
    • tpch_adapted_1_official_486567_1795185181
    • tpch_adapted_1_official_486588_1795185181

@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

@SmitaRKulkarni
SmitaRKulkarni added this pull request to the merge queue Nov 20, 2026
Merged via the queue into ClickHouse:master with commit 49d3a0a Nov 20, 2026
198 checks passed
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 20, 2026
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-delta-lake Delta Lake tables: reading Delta metadata through delta-kernel-rs (table snapshots, schema and ty... external Author is not a member of the ClickHouse organization pr-improvement Pull request with some product improvements 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.

8 participants