Repository navigation
Conversation
…_forbid_headers Add an integration test with `Authorization` forbidden in `http_forbid_headers`. It checks that `url`, `urlCluster`, the `URL` engine, the `|` failover syntax, `url` wildcards from index pages, the `HTTP` dictionary source with `CREDENTIALS`, `format_avro_schema_registry_url` and a `web` disk defined in a query reject credentials that would be sent in the `Authorization` header, and that no request with them reaches the server. Also add unit test cases for `HTTPHeaderFilter::checkBasicCredentials` and `HTTPHeaderFilter::checkURIUserInfo`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…on header
The userinfo of a URL (`http://user:password@host/`) and the `CREDENTIALS` of an `HTTP` dictionary are sent as Basic credentials in the `Authorization` header, but this header was not checked against `http_forbid_headers`. Forbidding `Authorization` rejected only an explicit `headers('Authorization' = ...)`.
Add `HTTPHeaderFilter::checkBasicCredentials` and `HTTPHeaderFilter::checkURIUserInfo`, which run a synthetic `Authorization` header through `checkHeaders`, and call them where such credentials are used: for every URL option read by `url`, `urlCluster` and the `URL` engine (outside of the failover handling, so that a forbidden option fails the read instead of being skipped), for `url` wildcards from index pages, for the `HTTP` dictionary source created by DDL, for `format_avro_schema_registry_url` and for a `web` disk defined in a query.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Workflow [PR], commit [4b59a24] Summary: ❌
AI ReviewSummaryThe PR applies Missing context / blind spots
Findings
Tests
Final Verdict
|
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units59 translation units recompiled, 452 s compile time in total, 59 of them have a recent master baseline. |
…st `http_forbid_headers` Add a case where `format_avro_schema_registry_url` has no authority and so no userinfo, while the URL of the schema request resolved from its path has one. The error is expected when the schema is fetched. Add a case where a `web` disk with a userinfo in its endpoint is created while `Authorization` is allowed, and a `CREATE TABLE` with the same definition reuses it after `SYSTEM RELOAD CONFIG` forbids `Authorization` again. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…d `web` disk `ConfluentSchemaRegistry` resolves the URL of a request from the path of `format_avro_schema_registry_url`, so for a URL without an authority, such as `http:http://user:password@host/`, the request URL has a userinfo that the URL checked in `getFormatSettings` has not. Check the URL of each request in `ConfluentSchemaRegistry::applyAuth`, with the filter of the global context, as the format has no context. The remote host filter is not added there: for a base URL with a host, the appended path starts with `/`, so the request URL keeps the host and the userinfo of the base URL. The endpoint of a `web` disk was checked in the object storage factory, which `Context::getOrCreateDisk` does not call for an existing disk, so a definition equal to that of a disk loaded from existing metadata, or created before `Authorization` was forbidden, was not checked. Move the check to `validateResolvedWebDiskEndpoints`, called in `getOrCreateCustomDisk` before the disk is looked up for every definition not loaded from existing metadata, as for the `Enforce` level of the remote host filter check. It reads the endpoint with `getWebObjectStorageEndpoint`, extracted from the factory. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ttp_forbid_headers` Add a case where a `web` disk with a userinfo in its endpoint is created while `Authorization` is allowed, and a new `cache` disk that names it is defined after `SYSTEM RELOAD CONFIG` forbids `Authorization` again. The definition is expected to fail with the forbidden header error before the `cache` disk is created, so that no table reads the endpoint through it. The creation of a `web` disk without a table is moved to a helper shared with the case of a reused `web` disk, and each case creates its own disk. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…he` or `encrypted` disk A `cache` or `encrypted` disk names the disk it wraps with the `disk` key and uses that disk as it is, so a new `cache` disk over a `web` disk created before `Authorization` was forbidden, or loaded from existing metadata, sent the userinfo of its endpoint in the `Authorization` header. `validateResolvedWebDiskEndpoints` checked only the endpoints of the definition itself. For a definition not loaded from existing metadata, look up the disk named by `disk` and, if it was created from user SQL, follow it through `encrypted` and `cache` layers to its `web` object storage and check the userinfo of its URLs. As in `getCustomDiskServerIdentity`, the walk stops at a disk from the server configuration, whose endpoint is not user input. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… against `http_forbid_headers` Replace the `format_avro_schema_registry_url` case, which read another format, by a read of `AvroConfluent` that requests the schema, and expect the error when the schema is fetched, for a URL with a userinfo as for a URL without an authority. Add a case where a `URL` table with a wildcard and a userinfo in its URL is created while `Authorization` is allowed. After `SYSTEM RELOAD CONFIG` forbids `Authorization` again, a short `ATTACH` of its stored definition is expected to succeed, and a fresh `CREATE TABLE` with the same definition to fail with the forbidden header error. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ldcard `URL` tables Remove the check of the userinfo of `format_avro_schema_registry_url` from `getFormatSettings`, which builds the settings of every format, so that a query that requests no schema is not refused for it. The userinfo is still checked for the URL of each request in `ConfluentSchemaRegistry::applyAuth`. A `URL` table with a wildcard is served by `StorageWebConfiguration`, whose `check` refused a userinfo forbidden by `http_forbid_headers` for any definition, so a stored one, for example on server startup or a short `ATTACH`, could not load. Add `StorageWebConfiguration::check_userinfo` and clear it in `registerStorageURL` for a replayed definition that is not restored from a backup. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ntials The checks of the previous commits were made when an object was defined, and every new path to the same request was a new bypass, e.g. a stored wildcard `URL` table. Observe the requests themselves: the index-page server of `test_storage_url` counts the requests that carry `Authorization`, and every case has a positive control with the header allowed. A stored wildcard `URL` table still attaches, but its reads are refused, and the userinfo of a redirect `Location` is not sent. The cases move from their own module to `test_storage_url`, which already has the server, the cluster for `urlCluster` and `http_forbid_headers`. The unit test is dropped in favour of the integration test.
…ets them Checking the userinfo when a table, disk or wrapper is defined missed every path that reaches the same request without that definition: stored wildcard `URL` tables, `MergeTree` tables on a `web` disk after a restart, and consumers of an existing disk by name. `setCredentialsFromURL` is the only place where a userinfo becomes credentials, right before each request, so it now takes the `HTTPHeaderFilter` and refuses a userinfo with a username when `Authorization` is forbidden. Stored objects keep loading, and each request is refused before it is sent, also after `SYSTEM RELOAD CONFIG`. A forbidden failover option fails the operation instead of being skipped. This replaces the definition-time checks of `web` disks, the disk wrapper walk and the `check_userinfo` flag. The Avro schema registry keeps its check in `applyAuth`, without a branch for a missing global context, which every program parsing formats creates.
| setCredentialsFromURL(credentials, uri); | ||
| /// credentials — happens in `nextImpl`, long after `initialize` returns. Outside of the `try` below: an option | ||
| /// whose credentials <http_forbid_headers> forbids must fail the read, not fall through to the next one. | ||
| setCredentialsFromURL(credentials, uri, context->getHTTPHeaderFilter()); |
There was a problem hiding this comment.
web disk request guards
The new forbidden-wildcard cases throw from MetadataStorageFromIndexPages::tryListDirectory before either WebObjectStorage::tryGetObjectMetadata or ReadBufferFromWebServer::initialize runs. None of the other added cases uses a web disk. Consequently, removing the credential checks from both of those methods would leave all added tests passing, although disks already registered or referenced through wrappers could send the forbidden Authorization header again.
Please add focused regressions that reach the metadata probe and file-read paths independently, using a credential-bearing disk registered while the header is allowed and reused after the configuration reload. Include successful authenticated requests as positive controls and assert zero authenticated requests when the header is forbidden. For the file-read case, keep the metadata available so an earlier listing/probe rejection cannot hide missing enforcement here. These cases can reuse an existing integration cluster.
`{a|b}` in the authority is expanded only by a wildcard read from index pages, so a
plain `url` read failed to parse the URI before any request. Failover options of a
plain read are separated by `|`.
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=128998&sha=e02da536bf27299a8da36b440acc0dbc8dd602ff&name_0=PR&name_1=Integration%20tests%20%28amd_asan_ubsan%2C%20flaky%29
PR: #128998
…` header
When `http_forbid_headers` forbids `Authorization`, an explicit
`url(..., headers('Authorization' = ...))` is refused, but Basic credentials
from the userinfo of a URL (`http://user:password@host/`) were still sent in
that header: `setCredentialsFromURL` builds `HTTPBasicCredentials`, and
`ReadWriteBufferFromHTTP::prepareRequest` synthesizes `Authorization` from them
after the explicit headers, never through `HTTPHeaderFilter`.
Check a synthetic `Authorization` header with the existing filter where each
sender gets its Basic credentials, at request time:
- `HTTPHeaderFilter::checkBasicCredentials` (no-op for an empty username,
which sends nothing) and `checkURIUserInfo` (for `ConfluentSchemaRegistry`,
which authenticates on any non-empty userinfo).
- `setCredentialsFromURL` takes the filter and checks there, which covers
`url`, `urlCluster` workers, the `URL` engine, url wildcards from index
pages, `web` disks and schema inference. Its four callers moved the call out
of their failover `try`, so a forbidden option fails the read instead of
being skipped.
- `HTTP` dictionaries created by DDL (`credentials(user, password)`), and
every schema registry request of `AvroConfluent` input and output.
Request time rather than definition time, so stored definitions keep loading
(startup, `ATTACH`, replicated replay, `RESTORE`) after an administrator adds
`Authorization` to the list; only their requests are refused. Admin-defined
senders that do not go through these paths (interserver credentials of
`DataPartsExchange`, XML-config dictionaries) are unchanged.
Based on the draft ClickHouse#128998 by
@ kolsha (its final request-time design, unchanged), plus a test for the
`AvroConfluent` output path.
Co-authored-by: Nikolai Ovchinnikov <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Credentials from the userinfo of a URL (
http://user:password@host/) and from theCREDENTIALSof anHTTPdictionary are sent as Basic credentials in theAuthorizationheader. When<http_forbid_headers>forbadeAuthorization, only an explicitheaders('Authorization' = ...)was rejected, while these credentials were still sent.This adds
HTTPHeaderFilter::checkBasicCredentialsandHTTPHeaderFilter::checkURIUserInfo, which validate a syntheticAuthorizationheader the same way as explicit headers. They are applied to every URL option read byurl,urlClusterand theURLengine (a forbidden failover option fails the read instead of being skipped), tourlwildcards from index pages, toHTTPdictionaries created by DDL, to the URL of eachformat_avro_schema_registry_urlschema registry request, and towebdisks defined in a query (checked before an existing disk with the same definition is reused, and for acacheorencrypteddisk over an existing one).Stored definitions keep loading: a stored wildcard
URLtable (startup, shortATTACH, replicated replay) is not refused, whileRESTOREis checked like a new definition.urlClusteris checked on the workers, under their own configuration, when they read.The first commit adds the tests, the second contains the fix (the unit test needs the fix to compile).
🤖 Generated with Claude Code
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
When
http_forbid_headersforbids theAuthorizationheader, credentials in a URL (http://user:password@host/) used byurl,urlCluster, theURLengine,webdisks andformat_avro_schema_registry_url, andCREDENTIALSofHTTPdictionaries created by DDL, are now rejected instead of being sent in this header.Workflow [PR]
Sync PR [sync-upstream/pr/128998]