Repository navigation
Implement http header validation for DataLakeCatalog - #98827
Conversation
|
Workflow [PR], commit [5198f32] Summary: ❌
AI ReviewSummaryThis PR adds creation-time validation for Missing context
Findings❌ Blockers
Tests
ClickHouse Rules
Final Verdict
|
| { | ||
| throw Exception(ErrorCodes::BAD_ARGUMENTS, "Invalid auth header format. Expected 'HeaderName:HeaderValue'"); | ||
| } | ||
| } |
There was a problem hiding this comment.
Header validation runs during ATTACH blocking server restart
High Severity
The new forbidden-header validation runs unconditionally in the factory's create_fn, which is invoked for both CREATE DATABASE and ATTACH DATABASE (server restart). The comment says "during creation" but there's no !args.create_query.attach guard. If a server admin later adds a previously-allowed header to http_forbid_headers, existing databases using that header will fail to attach on restart, potentially preventing the server from starting. The HTTPDictionarySource avoids this by guarding with created_from_ddl, and the other checks in the same file (lines 1007, 1020, etc.) already use !args.create_query.attach.
| } | ||
| else | ||
| { | ||
| throw Exception(ErrorCodes::BAD_ARGUMENTS, "Invalid auth header format. Expected 'HeaderName:HeaderValue'"); |
There was a problem hiding this comment.
Duplicated header parsing logic with RestCatalog's parseAuthHeader
Low Severity
The header-format parsing logic (finding :, splitting into name/value, throwing on missing :) duplicates parseAuthHeader in RestCatalog.cpp (lines 85–94). If the expected format ever changes, both copies need updating. Reusing the existing function would keep the format validation consistent and reduce maintenance risk.
|
@michael-anastasakis let's also adjust |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
|
@kssenii : I actually think the output of that test is okay since it throws an error on wrong format, not a forbidden header. The missing part was the change of line in the reference file which I updated. WDYT? |
|
I think it is supposed to be wrong header, not wrong format header. The test was added in #96680 and has a comment |
| else | ||
| { | ||
| throw Exception(ErrorCodes::BAD_ARGUMENTS, "Invalid auth header format. Expected 'HeaderName:HeaderValue'"); | ||
| } |
There was a problem hiding this comment.
I think it does make sense to have this validation, why remove? For the failed test I think it could be enough to have something like Authorization: Wrong header
There was a problem hiding this comment.
I assumed from the PR #96680 the goal was to allow the lazy creation of the database and have it fail on the format when executed.
If I re-introduce the error throwing there then the test will still fail. I'm all for re-introducing and preventing the creation to begin with so maybe I misunderstood your initial point.
There was a problem hiding this comment.
My idea was that in that test we could just switch Wrong header to Authorization: Wrong header -- so your new exception will not apply to it, but the header will still not allow to connect successfully - which the test checks that it does not lead to failed system.tables query.
And add a separate test to test your change specifically - that header validation works.
There was a problem hiding this comment.
@michael-anastasakis so let's take that validation back and just update the test to use Authorization: Wrong header instead of just Wrong header? (Since the test, which used to to fail, tests behaviour on incorrect credentials, not incorrect credentials format)
…der format Restore the `else` branch in `registerDatabaseDataLake` that throws an exception when `auth_header` is provided without a colon (i.e. not in `name: value` format). This was removed in a previous commit but kssenii asked to keep this validation. Update `03913_datalake_restful_catalog_bad_format` to use `Authorization: Wrong header` instead of `wrong.header` so the test continues to exercise the "bad credentials" path (verifying `system.tables` does not fail) without triggering the format-validation exception. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
| if (database_engine_define->settings) | ||
| database_settings.loadFromQuery(*database_engine_define, args.create_query.attach); | ||
|
|
||
| const auto & auth_header_str = database_settings[DatabaseDataLakeSetting::auth_header].value; |
There was a problem hiding this comment.
This validation now runs for both CREATE and ATTACH because it is unconditional in create_fn. That creates a backward-compatibility risk: existing DataLakeCatalog metadata with legacy auth_header values (without :) that previously attached may now start failing during ATTACH/startup.
Please gate strict format validation to non-attach flows (for example if (!args.create_query.attach)) or provide a compatibility setting/migration path.
| * Fix query obfuscator (`clickhouse-format --obfuscate`) to produce parseable SQL in more cases. [#97584](https://github.com/ClickHouse/ClickHouse/pull/97584) ([Alexey Milovidov](https://github.com/alexey-milovidov)). | ||
|
|
||
| #### Bug Fix (user-visible misbehavior in an official stable release) | ||
| * `DataLakeCatalog` now respects the server's `http_forbid_headers` configuration when validating the `auth_header` setting. [#98827](https://github.com/ClickHouse/ClickHouse/pull/XXXXX) ([Michael Anastasakis](https://github.com/michael-anastasakis)). |
There was a problem hiding this comment.
The changelog link still contains placeholder XXXXX, so the rendered entry points to a broken PR URL. Please replace it with the actual PR number (98827).
Add `test_invalid_auth_header_format` to the three iceberg catalog integration test suites (REST, Nessie, Lakekeeper). Each test verifies that `CREATE DATABASE` with an `auth_header` that has no colon (e.g. `wrong.header`) is rejected at creation time with `Invalid auth header format`. These tests fail on master (where no format validation exists) and pass on this PR, satisfying the Bugfix validation CI requirement. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
| * Fix query obfuscator (`clickhouse-format --obfuscate`) to produce parseable SQL in more cases. [#97584](https://github.com/ClickHouse/ClickHouse/pull/97584) ([Alexey Milovidov](https://github.com/alexey-milovidov)). | ||
|
|
||
| #### Bug Fix (user-visible misbehavior in an official stable release) | ||
| * `DataLakeCatalog` now respects the server's `http_forbid_headers` configuration when validating the `auth_header` setting. [#98827](https://github.com/ClickHouse/ClickHouse/pull/XXXXX) ([Michael Anastasakis](https://github.com/michael-anastasakis)). |
There was a problem hiding this comment.
The changelog entry currently describes only http_forbid_headers enforcement, but this PR also changes behavior by rejecting malformed auth_header values (without :) during CREATE DATABASE.
Please expand the entry to mention both user-visible changes, for example:
DataLakeCatalog now validates auth_header during CREATE DATABASE: malformed values without name: value are rejected with BAD_ARGUMENTS, and formatted headers are checked against http_forbid_headers.
| auto pos = auth_header_str.find(':'); | ||
| if (pos != std::string::npos) | ||
| { | ||
| DB::HTTPHeaderEntries header_entries{{auth_header_str.substr(0, pos), auth_header_str.substr(pos + 1)}}; |
There was a problem hiding this comment.
The new validation only checks for the presence of :, so values like ': token' (empty header name) still pass creation-time validation, despite the error text saying we expect HeaderName: HeaderValue.
This keeps a malformed auth_header reachable and can still fail later in request construction, so the strict validation is currently incomplete.
Could we additionally reject empty header names (and likely all-whitespace names) here before calling checkAndNormalizeHeaders?
| * Fix query obfuscator (`clickhouse-format --obfuscate`) to produce parseable SQL in more cases. [#97584](https://github.com/ClickHouse/ClickHouse/pull/97584) ([Alexey Milovidov](https://github.com/alexey-milovidov)). | ||
|
|
||
| #### Bug Fix (user-visible misbehavior in an official stable release) | ||
| * `DataLakeCatalog` now respects the server's `http_forbid_headers` configuration when validating the `auth_header` setting. [#98827](https://github.com/ClickHouse/ClickHouse/pull/98827) ([Michael Anastasakis](https://github.com/michael-anastasakis)). |
There was a problem hiding this comment.
AFAIK we do not need to manually modify changelog, it will be auto-generated under a patch release number.
LLVM Coverage Report
Changed lines: 90.00% (9/10) · Uncovered code |
Cherry pick #98827 to 26.2: Implement http header validation for DataLakeCatalog
Backport #98827 to 26.2: Implement http header validation for DataLakeCatalog
Cherry pick #98827 to 26.3: Implement http header validation for DataLakeCatalog
Backport #98827 to 26.3: Implement http header validation for DataLakeCatalog
Resolve conflicts for the backport of #98827 to 25.8: - Keep only the new `HTTPHeaderFilter.h` include (25.8 has no `FailPoint.h` include here). - `test_database_iceberg`: keep only the new `test_invalid_auth_header_format`, dropping master-only tests. - `test_database_iceberg_nessie_catalog` does not exist in 25.8, keep it deleted. - `03913_datalake_restful_catalog_bad_format`: keep only the forbidden-header check added by this PR. The first half of the master test relies on #96680, which is not in 25.8. Co-Authored-By: Claude Fable 5 <[email protected]>
Cherry pick #98827 to 25.8: Implement http header validation for DataLakeCatalog
Backport #98827 to 25.8: Implement http header validation for DataLakeCatalog


Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
DataLakeCatalognow respects the server'shttp_forbid_headersconfiguration when validating theauth_headersetting.Note
Medium Risk
Changes
CREATE DATABASE ... ENGINE=DataLakeCatalogvalidation behavior by rejecting forbidden HTTP headers earlier, which could break existing configs that relied on previously-accepted headers.Overview
DataLakeCatalognow enforces server-level forbidden header rules at database creation time. Whenauth_headeris provided inname: valueform, it is checked/normalized viaHTTPHeaderFilter(respectinghttp_forbid_headers) and rejected if forbidden.Tests are updated to use a properly formatted
auth_header(e.g.Authorization: ...) and a new stateless test case asserts that malformed headers without a colon still create successfully (lazy failure later), while explicitly forbidden headers fail duringCREATE DATABASE.Written by Cursor Bugbot for commit 35cb194. This will update automatically on new commits. Configure here.
Version info
26.4.1.997(included in26.4and later)26.3.11.22,25.8.29.8