Repository navigation
Conversation
Callers that authenticate with a bearer token currently splice an `Authorization: Bearer` entry into the header list themselves and must also remember not to pass HTTP Basic credentials, because both occupy the same header. The builder now owns that rule: `withBearerToken` attaches the header, and a non-empty token takes precedence over the Basic credentials passed to `create`. Co-Authored-By: Claude Fable 5 <[email protected]>
UnityCatalog spliced the bearer into the header list itself and passed never-used HTTP Basic credentials alongside. The catalog helpers now take the token and hand it to the builder, which owns the header formatting and the bearer-over-Basic precedence. Co-Authored-By: Claude Fable 5 <[email protected]>
|
Workflow [PR], commit [18a2816] Summary: ✅
AI ReviewSummaryThis PR centralizes bearer-token handling in Findings❌ Blockers
Final VerdictChanges requested: the bearer-token validation introduced by this refactor is still incomplete for bare carriage returns. LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 73/96 (76.04%) · Uncovered code |
The token has one entry point now — the terminal create call — so a conflicting withBearerToken-plus-create state cannot be constructed. Three overloads cover the auth modes: Basic credentials, a bearer token, and both (the non-empty token wins; the two occupy the same `Authorization` header, so a request carries one or the other). Co-Authored-By: Claude Fable 5 <[email protected]>
`create` appended the bearer `Authorization` header to the builder's `http_header_entries` member, so reusing a builder would carry over a stale token. Append it to a local copy passed to `ReadWriteBufferFromHTTP` instead, so `create` no longer mutates the builder. Co-Authored-By: Claude Opus 4.8 <[email protected]>
`RestCatalog` (with `OneLakeCatalog`, `BigLakeCatalog`) and `PaimonRestCatalog` built the `Authorization: Bearer` header by hand and passed unused Basic credentials to `create`. `getAuthHeaders` now returns an `AuthHeaders` of a bearer token plus extra headers: the bearer goes to `create` and only genuine extra headers (a user-supplied `auth_header`, `x-goog-user-project`, `User-Agent`) stay in the header list. `OneLakeCatalog`'s pre-obtained token likewise moves from a spliced header to the bearer, so every catalog bearer now flows through `create`. Co-Authored-By: Claude Opus 4.8 <[email protected]>
`.create({})` brace-initializes both one-argument overloads, making such
calls ambiguous. Two overloads remain: `create(credentials)` and
`create(bearer_token, credentials)` (the non-empty token wins). The catalog
helper passes empty credentials explicitly.
Co-Authored-By: Claude Fable 5 <[email protected]>
…http-builder-bearer-token
`.create({})` brace-initializes both one-argument overloads, making such calls
ambiguous. Two overloads remain: `create(credentials)` and
`create(bearer_token, credentials)` (the non-empty token wins). The catalog
call sites pass empty credentials explicitly.
Co-Authored-By: Claude Fable 5 <[email protected]>
A bearer-token overload of `create` would be ambiguous with
`create(credentials)` for `.create({})` call sites, and bearer-only callers
had to pass a throwaway empty credentials object because the buffer stores the
credentials by reference. A distinct `createWithBearerToken` removes the
ambiguity and needs no credentials argument; the single empty-credentials
object now lives once inside the builder instead of at every call site.
Co-Authored-By: Claude Fable 5 <[email protected]>
The previous commit renamed the declarations but left the out-of-line definitions on the old `create` names; align them. Co-Authored-By: Claude Fable 5 <[email protected]>
`getAuthHeaders` returned an `AuthHeaders` of a bearer token plus extra headers, so every `RestCatalog` call site had to unpack it. Match `PaimonRestCatalog`'s existing shape instead: `getAuthHeaders` appends its extra headers to a caller-owned list and returns the bearer token. The struct is gone and the call sites just forward their header list and the token to `createWithBearerToken`. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…aders `createWithBearerToken` appends the `Authorization: Bearer` header internally without going through the `HTTPHeaderFilter` check, so a user-supplied `onelake_bearer_token` that contains a forbidden or malformed value could reach the request path unchecked. Add the same validation that `RestCatalog` applies to a user-supplied `auth_header` in its own constructor: call `validateAuthHeaders` with the synthetic `Authorization: Bearer <token>` header before storing the token. This restores the pre-refactor behavior where the value went through the header list and was subject to `http_forbid_headers` / CR-LF checks. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Resolve the conflict in `RestCatalog.{h,cpp}`: master's `CatalogState`-based
auth refactor (atomic credential snapshots plus the ALTER framework
`prepareSettingsChanges`/`applySettingsChangesToState`, and `getAuthHeaders`
returning `HTTPHeaderEntries` from a state snapshot) superseded this branch's
`getAuthHeaders` simplification, so `RestCatalog.{h,cpp}` are taken from master.
The branch's remaining contribution is preserved: `createWithBearerToken` on
`BuilderRWBufferFromHTTP` and its adoption in `HTTPBasedCatalogUtils`,
`PaimonRestCatalog` and `UnityCatalog` (which master did not refactor).
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Construct OneLakeCatalog with a bearer token containing a newline and assert the constructor rejects it with BAD_ARGUMENTS via validateAuthHeaders, before any request is issued. Locks the fix that routes a pre-obtained bearer token through http_forbid_headers validation instead of splicing it into the header list unchecked. Co-Authored-By: Claude Opus 4.8 <[email protected]>
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 58/80 (72.50%) · Uncovered code |
|
📊 Cloud Performance Report ✅ AI verdict: This is a security/plumbing change confined to data-lake catalog HTTP bearer-token auth (Unity/Paimon/OneLake) and the generic HTTP read-buffer builder. None of that code is on the ClickBench or TPC-H query-execution path, which runs entirely on local tables. All 14 flagged deltas are improvements pointing in the same direction (~8% to ×8.6 faster), which is the signature of a measurement-environment difference between the source and base runs, not a code effect. All 14 are downgraded to not sure; no action needed on these numbers. clickbenchFlagged queries (12 of 43)
Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on. tpch_adapted_1_officialFlagged queries (2 of 22)
Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on. Debug info
|
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction. Object file sizes15 object files changed (-16.28 KiB total), 0 added.
737 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units50 translation units recompiled, 341 s compile time in total, 50 of them have a recent master baseline. |
createWithBearerToken synthesizes an `Authorization: Bearer <token>` header from a raw token but did not validate it. Unity and Paimon route user-supplied bearer tokens / catalog_credential through this path, so a token with an embedded newline could smuggle a second header into the request, or send an `Authorization` header that `http_forbid_headers` forbids. OneLake already validated its auth header explicitly. Add a shared `DataLake::validateBearerToken` that runs the same `HTTPHeaderFilter` check on the synthesized header and call it on every bearer-token path. Co-Authored-By: Claude Opus 4.8 <[email protected]>
`HTTPHeaderFilter::checkAndNormalizeHeaders` rejected an embedded `\n` but not a bare `\r`. A lone CR also terminates a header line, so a value like "token\rX-Injected: evil" could still smuggle a second header. Reject `\r` as well as `\n`, which closes the gap for every caller (the bearer-token catalog paths and the OneLake auth-header path). Co-Authored-By: Claude Opus 4.8 <[email protected]>
This reverts commit 790eaf0.
|
Superseded by #115400 (attempt 2), which is in the merge queue. |
…pt 2) Clone of ClickHouse#110313 on a fresh branch off current master — same changes, reconciled onto master. Opened because the original PR's sync pair got wedged. Co-Authored-By: Claude Opus 4.8 <[email protected]>
`HTTPHeaderFilter::checkAndNormalizeHeaders` rejected an embedded `\n` but not a bare `\r`. A lone CR also terminates a header line, so a value such as "token\rX-Injected: evil" could still smuggle a second header (request/response splitting). Reject `\r` alongside `\n` for both header names and values, closing the gap for every caller of the shared filter. Deferred from ClickHouse#110313 to keep that pull request focused on refactoring. Co-Authored-By: Claude Opus 4.8 <[email protected]>
BuilderRWBufferFromHTTPhad no way to authenticate with a bearer token: callers spliced anAuthorization: Bearerentry into the header list themselves and had to remember not to pass HTTP Basic credentials at the same time, because both occupy the same header.createnow takes the credential directly, in three overloads: Basic credentials, a bearer token, or both — with a non-empty token taking precedence, so the either/or rule lives in one place instead of in every caller.createalso appends the bearer header to a local copy of the header list rather than mutating the builder, so a builder can be reused without carrying over a stale token.Every bearer-token call site of the class is migrated to the new overloads:
HTTPBasedCatalogUtilsandUnityCatalog: built the header by hand and passed never-used HTTP Basic credentials alongside; now callcreatewith the token.RestCatalog,OneLakeCatalog,BigLakeCatalog:getAuthHeadersnow returns anAuthHeaders(a bearer token plus extra headers). The bearer goes tocreate; only genuine extra headers (a user-suppliedauth_header,x-goog-user-project,User-Agent) stay in the header list.OneLakeCatalog's pre-obtained token also moved from a spliced header to the bearer.PaimonRestCatalog: thebearertoken provider (thedlfrequest-signing branch keeps its own signed headers).Out of scope — different transport (plain Poco requests or S3-client headers), not
BuilderRWBufferFromHTTP:OpenAIProvider,CloudJWTProvider, ArrowFlightAuthMiddleware, GCSdiskSettings.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Workflow [PR]
Sync PR [sync-upstream/pr/110313]