Repository navigation
Reject invalid characters in HTTP header names - #118830
Conversation
HTTPHeaderFilter compares a header name against each <http_forbid_headers>
entry, but a name like "Cookie:x" is not equal to "Cookie", so it passed
the filter, while a peer still parses a forbidden "Cookie" header from it
because a field name ends at the first ':'. This let a SQL-supplied header
smuggle a forbidden header past the restriction.
Reject a header name that contains ':', CR or LF, checked on the original
bytes so a caller that validates and then sends its own copy cannot emit
them. Whitespace and control characters in a name are still stripped (not
rejected) before the forbidden-header lookup, so attaching a table stored
with such a name keeps working. Values are unchanged (':' stays legal, for
example "Host: example.com:8080"); a value is still rejected for bare
CR/LF. The schema-inference and RestCatalog paths validate and send the
same normalized headers, and schema inference rejects a Range header.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Workflow [PR], commit [608a177] Summary: ✅
AI ReviewSummaryThis PR hardens Findings
Tests
Final VerdictStatus: Minimum required actions:
LLVM Coverage ReportMeasured on commit 608a177.
Changed lines: Changed C/C++ lines covered: 57/60 (95.00%) · Uncovered code |
Build profile diff (arm_release)Commit See the job log for details. |
Keep this PR to the ':' header-name fix. The Range guard was inference-correctness, not the security fix, and a behaviour change from master (which allows a Range header in url() schema inference); it also covered only the direct StorageURL inference path. Dropped per review; the normalized-header copy sent during inference is kept. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Mirror the drop in the base PR #118830 — keep only the return-normalized API refactor here, no Range guard. See #118830 for rationale. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
@tavplubix what do you thing about the case where we have wrong header name in a schema that is persistent? If we throw it may lead to crashes that require manual intervention to fix the schema. On the other hand, if we don't throw - we will have an unsecured headers. Maybe we just check it for new queries and read as-is from persisted? But it also sounds a bit fragile to me. |
The header filter runs in the StorageURL ctor on every construction, including ATTACH replay of stored metadata, so a table persisted by an older release with a now-rejected header name (e.g. a ':') would fail to attach after upgrade. Gate the validation to freshly supplied definitions (CREATE / url()) via LoadingStrictnessLevel and skip it when replaying existing metadata. New input — including the url() table function — is still rejected; a pre-existing table attaches and sends its stored headers unchanged. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Mirror the base PR #118830: gate the StorageURL header validation to fresh definitions (CREATE / url()) and skip it on ATTACH replay of existing metadata, so a table persisted by an older release keeps attaching. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
@groeneai, investigate the failure: https://github.com/ClickHouse/ClickHouse/actions/runs/34691904517/job/103567576644 and provide a fix in a separate PR. If the fix is already in progress, link it here. Stress test (amd_msan) fails with STID 2508-49e2: |
|
A fix is already in progress: #111928, open since 2026-07-26. Your attribution is right, this is not the header name validation. The abort comes from the refreshable materialized view refresh path: #111928 covers the exact frame in that stack. I re-checked No reviewer has ever been requested on #111928, which is why it has been open for 7 weeks; three earlier carriers of the same assertion got this same link. If you assign a reviewer or review it yourself, the red goes away for all carriers at once. |
See a similar discussion https://github.com/ClickHouse/clickhouse-private/issues/69188#issuecomment-5477882208 https://github.com/ClickHouse/clickhouse-private/issues/69188#issuecomment-5496411954 TL;DR don't listen to the bot, just break it |
Per maintainer guidance, don't carve out backward-compat for persisted headers: a stored header name with ':' / CR / LF never worked correctly and may indicate a security incident, so reject it everywhere — including when replaying existing metadata on ATTACH — and make the breakage visible, rather than reading it back unchecked. Reverts the fresh-vs-replay gate; the filter again validates unconditionally in the StorageURL ctor. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Okay, done |
Reject any name byte outside the RFC 7230 token set rather than only ':', whitespace and control characters, so separators such as '/' or '=' no longer pass. Add a regression test. Co-Authored-By: Claude Opus 4.8 <[email protected]>
The auth_header setting is already validated on every path that sets it (construction and ALTER, via validateAuthHeaders), so re-validating it in getAuthHeaders was unreachable as a distinct check. Replace the ineffective test with one that asserts an invalid auth_header name is rejected when the catalog is built. Co-Authored-By: Claude Opus 4.8 <[email protected]>
The function validates header names and values and no longer normalizes them, so restore its original name. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…ents RFC 9110 obsoletes RFC 7230 and carries the token/field-name grammar forward unchanged; reference the current spec. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Move the header name/value validation cases into the dedicated filter test (':' , non-tchar separators, empty names rejected; ':' allowed in a value) and drop the duplicates that had accumulated in gtest_gcs_credentials, which reverts to its upstream set.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
I reworked the PR to avoid any normalization, so we are back to where things started before #87172, and weird headers throws an error |
The header-name token validation is already covered directly against the filter in gtest_http_header_filter (WhitespaceOrControlInNameRejected, NameMustBeToken). The RestCatalog test only re-exercised the pre-existing validateAuthHeaders wiring, which this change does not modify, while adding a fragile nine-argument constructor call. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
@groeneai, investigate the failure on this run and provide a fix in a separate PR. If the fix is already in progress, link it here. Failing test: Not related to this PR's HTTP header name validation. |
|
Confirmed, and not related to your PR: the test is mine. Fix in progress: #121820, test-only, opened 2026-09-23 17:58Z. One overlap worth flagging so you are not choosing blindly: #121866 changes the same two files in the same direction, opened about five hours after mine. I have no preference between them; say which one you want kept and I will close #121820 if it is the other. |
…p-header-names Co-Authored-By: Claude Opus 5.5 <[email protected]>
UnityV2Catalog came in from master still calling the old HTTPHeaderFilter::checkAndNormalizeHeaders name. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Reject invalid HTTP header names supplied to SQL-facing HTTP clients (the
urltable function and engine, HTTP dictionaries, S3/object storage, DataLake/REST catalogs). A header name must be a valid RFC 9110 token (letters, digits and!#$%&'*+-.^_`|~); any other byte —:, whitespace, control characters or separators such as/and=— is rejected. Such names could previously bypass the<http_forbid_headers>restriction.Documentation entry for user-facing changes
Follow-up to #115510, which rejected bare CR/LF in header names and values.
A header name is now required to be an RFC 9110 token: a non-empty sequence of
tcharbytes (letters, digits and!#$%&'*+-.^_`|~). Any other byte is rejected, including:, whitespace, control characters and separators such as/or=. A non-token name may not match<http_forbid_headers>in ClickHouse while a downstream server still parses a forbidden header out of it — for exampleCookie:xis not equal toCookie, yet a peer can read aCookieheader from it — so it could bypass the restriction. Previously such a name was normalized (whitespace and control characters stripped) rather than rejected, which left bytes like:untouched. Rejecting non-token names outright closes the gap.The check runs everywhere a SQL-supplied header enters, including when a stored table or dictionary is loaded, so one persisted by an older release with such a header name will fail to attach on restart — such a header never worked correctly. Values are unchanged:
:stays legal in a value (for exampleHost: example.com:8080) and a value is rejected only for bare CR/LF.Workflow [PR]
Sync PR [sync-upstream/pr/118830]
Version info
26.10.1.937-master(included in26.10and later)