Repository navigation
Cherry pick #129850 to 26.8: Apply http_forbid_headers to Basic credentials sent in the Authorization header - #132634
Merged
robot-ch-test-poll3 merged 10 commits intoNov 18, 2026
Conversation
…` 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 #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]>
`ElasticsearchConfiguration::validate` checks the `Authorization` header of `bearer_token` and `api_key` against `http_forbid_headers`, but `authorizationHeaders` is empty for `user` + `password`, which `ElasticsearchClient` sends as Basic credentials in `Authorization`. Check them in the client constructor, i.e. per read, so a stored table still loads after the header is forbidden and only its reads are refused. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…eb disk guards A loaded `HTTP` dictionary keeps its source: a periodic update clones it (`ExternalLoader` calls `clone`, and `HTTPDictionarySource::isModified` is always true), and `DIRECT` and cache layouts call `loadIds`/`loadKeys` on the retained source. So the check at source construction let an already loaded DDL dictionary keep sending its Basic credentials after `SYSTEM RELOAD CONFIG` added `Authorization` to `http_forbid_headers`. Check them in `loadAll`, `loadUpdatedAll`, `loadIds` and `loadKeys` instead; the check at construction is removed, since a `DIRECT` dictionary sends no request when it is created. Tests: - a loaded dictionary with `LIFETIME(MIN 1 MAX 1)` is refused on its next update; - a `web` disk whose `.index` is fetched without credentials reads its data through `ReadBufferFromWebServer` with the userinfo, and a `web_index` disk probes `format_version.txt` with a HEAD request before any listing, so both guards are reached on their own (every other test hits the listing guard first). Also drop the request-counter assertion of the `AvroConfluent` output test, which could not fail: the mock server does not handle POST, so the registration request was never counted. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The initiator of `urlCluster` checked only the host and the explicit headers, then handed each URL to the workers, which check its userinfo under their own `http_forbid_headers`. A worker whose configuration does not forbid `Authorization` therefore still sent the Basic credentials although the initiator refuses an explicit `Authorization` header. The task callback now calls `setCredentialsFromURL` for each failover option of every URL before a worker gets it, parsing the options as the worker does. Test: `test_cluster_node2` has `node2`, whose configuration does not forbid the header, as its only worker; the userinfo is in the second failover option, so checking only the whole URL is not enough. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Drop comments that narrate the new code's design; restore master's wording of the comments the PR only moved or rephrased; shorten the API comments to one line each. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Since #123950 (merged with master in 21e71b8), `SELECT sum(id)` over the web disk table is answered from the per-part `basic` statistics. The statistics are loaded by the first query and kept in memory, so the query after `http_forbid_headers` forbids `Authorization` sent no HTTP request and `test_userinfo_with_forbidden_authorization` failed with "Client expected to be failed but succeeded". A filter disables that optimization, so every query reads `id` from the web server again. The query needs no new setting, so the test stays the same on release branches that do not have `use_statistics_for_sum_avg_aggregation`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The existing failover case puts the credentialed option last, so it cannot tell a refused read from one that skips the forbidden option: with no later option, both end with the same error. With a usable second option, a read that moved on to it would succeed. Cover both the `url()` failover loop and the listing loop of a `url()` wildcard. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ation Apply `http_forbid_headers` to Basic credentials sent in the `Authorization` header
Carry the conflict resolution of the cherry-pick as a tree onto the rebuilt `backport/26.8/129850` branch: the release branch was rewritten, so the earlier resolution cannot be pushed as is without bringing the old history back. Deviations from the original change, all approved: - `HTTPDictionarySource` keeps the `created_from_ddl` field of `Configuration` from #101768, which the original change relies on. - The `Elasticsearch` hunk and the `test_storage_elasticsearch` changes are dropped, the engine does not exist on this branch. - `checkAndNormalizeHeaders` is called instead of `checkHeaders`. - `test_storage_url` gets the helper `server_part_of_error` for the error assertions. - The tests use the setting name `allow_experimental_url_wildcard_from_index_pages`, as it is named on this branch. - The redirect fixture of `index_pages_server.py` puts userinfo into `Location` as on master (from #126184), so that `test_url_redirect_userinfo_is_not_sent_with_forbidden_authorization` exercises the redirect with credentials. The masking of the URL in the error of `rejectOriginChangingRedirect` from #126184 is not ported: it is not part of this change, and the branch keeps its existing behavior.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Original pull-request #129850
Do not merge this PR manually
This pull-request is a first step of an automated backporting.
It contains changes similar to calling
git cherry-picklocally.If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.
The check results does not matter at this step - you can safely ignore them.
Before you resolve anything
Conflicts are often caused by a prerequisite change that has not been backported yet, rather than by a real divergence. The bot re-tries this cherry-pick against the release branch on every run, so if that is the case here it will merge itself as soon as the prerequisite lands, and you will see a comment saying so. Manual resolution is only needed while the conflict persists.
Troubleshooting
If the conflicts were resolved in a wrong way
If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:
pr-cherrypicklabel from the PRYou also need to check the Original pull-request for
pr-backports-createdlabel, and delete if it's presented thereThe PR source
The PR is created in the CI job