Repository navigation
Conversation
…sts signed with the server-configured keys With the default `s3_allow_server_credentials_in_user_queries = 0`, the bare-URL user-query paths (`S3StorageParsedArguments::fromAST` and the backup `makeS3Client`) dropped all server `<s3>` request material, including the `header` of the endpoint section that matched the URL. That drop came from ClickHouse#106855 and is meant to keep a `NOSIGN` request, or one made with the query's own credentials, free of server material. It also hit requests signed with the endpoint section's own static keys: those keys and the section's `session_token` still reached the endpoint, but its header did not, so a requester-pays read (`x-amz-request-payer: requester`) failed with 403 on HeadObject, ListObjectsV2, `S3` schema inference and BACKUP (ClickHouse#131473, item 2). Under the restriction, keep `headers` when the URL matched an endpoint section and the request is signed with the server config's key pair: no keys, token or `role_arn` from the query (a query `role_arn` has already emptied the keys at this point) and no `NOSIGN`. With the server keys, a global `<s3>` header still never reaches a URL outside the endpoint sections: the section's keys are what vouch for the host. `access_header` and the SSE keys stay dropped (a changed SSE behaviour would break reads of objects written without the key since 26.7). A BigLake catalog credential and a DataLake catalog refresh callback replace the server keys after the parse, so `createObjectStorage` drops the kept headers again in that case, before `headers()` from the query are appended. It only drops what was dropped before. When the server loads an `S3` table at startup, `getClient` dropped all its headers under the restriction, on the premise that the table is downgraded to an anonymous client. A table with a complete key pair is not downgraded (`getCredentialsProvider` signs with the pair), so it lost the header kept for its keys on every restart. Drop the headers there only for `NOSIGN` or without a complete key pair. Tests: a proxy in front of MinIO in `test_s3_credentials_hardening` refuses requests without `x-amz-request-payer`, like a requester-pays bucket. Red on master and on 26.10.2.103 at the first request; each condition of the rule except a query `role_arn` (it needs STS) has a negative case that a mutant without that condition turns red. The key-pair condition of the table path is not observable on master: a configuration without keys is not static, so `update()` merges the endpoint auth settings, headers included, again on each query (ClickHouse#131104 removes that), and only the BACKUP path can show it. Related: ClickHouse#131473 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Shorten the fromAST restriction comment to two lines and drop the parse-time reference from the getClient comment. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review (3 rounds, final verdict: clean)
|
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-4:20261114-040200 |
|
Workflow [PR], commit [c948056] Summary: ❌
AI ReviewSummaryThe PR restores endpoint-configured Missing context / blind spots
Final VerdictStatus: ✅ Approve. No new inline findings or thread changes are needed. |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Slowest function optimization changes (ThinLTO)Median per-function time ratio to the master baseline:
Compile time of recompiled translation units11 translation units recompiled, 48 s compile time in total, 11 of them have a recent master baseline. Median compile-time ratio to the baselines is ×0.95 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio. |
…headers` `getClient` checks the headers of every `s3` table function and `S3` table client against `http_forbid_headers`, but `makeS3Client` did not. Now that a restricted bare-URL BACKUP/RESTORE keeps the matched endpoint section's `header` when the server keys sign the request, such a header could reach the endpoint although the operator forbade it. Check the headers before the client is created, as `getClient` does. The new case configures an endpoint section with static keys and a header that `http_forbid_headers` forbids: the `s3` read, BACKUP and RESTORE all fail with the "forbidden" error, and the proxy records no request. Co-Authored-By: Claude Opus 5.5 <[email protected]>
CI finish ledger - c948056Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
Session id: cron:our-pr-ci-monitor:20261114-113014 |
|
Fixing PR for |
Algunenano
left a comment
There was a problem hiding this comment.
🤖 Requesting changes because the implementation relaxes the credential boundary much more broadly than the requester-pays use case requires.
The motivating behavior only needs x-amz-request-payer: requester. This patch instead retains every generic <s3> header whenever the merged settings contain a complete static key pair. Generic headers can contain reusable credentials such as Authorization: Bearer ..., cookies, or API keys. The presence of a SigV4 key pair does not establish that those unrelated headers are safe to send.
There are two concrete problems:
-
S3SettingsByEndpoint::loadFromConfigconstructs endpoint settings by copying the global<s3>defaults and overlaying the endpoint section. Therefore,endpoint_settings.has_value()plus a complete merged key pair does not prove that either the header or the keys came from the matched endpoint section. A global header can be sent to a matched endpoint, and global keys can make a keyless endpoint header passsigned_with_server_keys. -
PocoHTTPClientreappliesextra_headersafter a 307 redirect. Retaining arbitrary endpoint headers therefore allows a bearer token or API key to be forwarded to a different redirect target.http_forbid_headersis a blocklist and cannot establish that every otherwise permitted generic header is non-sensitive.
PR #131104 is a prerequisite because it prevents server authentication settings from being merged back into a restricted persistent S3 table. Please wait for #131104 to merge, merge the updated master into this branch, and rerun the focused tests before proceeding.
Please narrow this change to the exact requester-pays requirement instead of restoring arbitrary headers. A first-class request_payer = requester/s3_request_payer implementation, as proposed in #131512, is the safer shape. Alternatively, only synthesize the exact x-amz-request-payer: requester header from a typed, validated option. General <s3> header entries should remain stripped under s3_allow_server_credentials_in_user_queries = 0.
The minimum requested changes are:
- Do not retain the complete generic
auth.headerscollection. - Support only the typed requester-pays behavior needed by the issue.
- Wait for #131104 and merge the resulting
masterchanges. - Add a negative test proving that an arbitrary endpoint header such as
Authorizationremains absent, including after table reload and on redirects.
|
Thanks. Agreed on both problems, and that generic The typed shape you describe is already #131512: the Narrowed to the typed option, this PR would duplicate #131512. So my proposal: close this PR, and after #131104 merges, merge Should I close this PR in favour of #131512? |
|
Done in #131512: master (with #131104) is merged in, and |
Related: #131473
Related: #131104
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed the
headerof an<s3>endpoint section (for examplex-amz-request-payer: requesterfor a requester-pays bucket) being ignored by thes3ands3Clustertable functions,S3tables andBACKUP/RESTOREto S3 with the defaults3_allow_server_credentials_in_user_queries = 0, so their requests failed with 403 even though they were signed with theaccess_key_idandsecret_access_keyfrom the server configuration. The header is still not sent withNOSIGNrequests, with requests that use keys from the query, or to a URL that matches no endpoint section.Description
On 26.7 and later (measured on 26.10.2.103), with the default
s3_allow_server_credentials_in_user_queries = 0, theheaderof an<s3>endpoint section is not sent bys3(),S3tables orBACKUP TO S3, even when the request is signed with that endpoint's keys, so a requester-pays read fails withHTTP response code: 403(item 2 of #131473).#106855 drops all server
<s3>request material on the bare-URL user-query paths so that aNOSIGNrequest, or one with the query's own keys, carries none of it. It also drops it from a request signed with the static keys of the endpoint section that matched the URL, which still sends those keys and itssession_token.Under the restriction,
S3StorageParsedArguments::fromASTand the backupmakeS3Clientnow keepheaderswhen the URL matched an endpoint section and the request is signed with the server config's key pair (no keys, token orrole_arnfrom the query, noNOSIGN).createObjectStoragedrops them when a catalog credential replaces those keys. When the server loads anS3table at startup,getClientnow drops its headers only if it has no complete key pair.access_headerand SSE keys stay dropped. LikegetClient,makeS3Clientnow checks its headers againsthttp_forbid_headers.New cases in
test_s3_credentials_hardeningput a proxy in front of MinIO that refuses requests withoutx-amz-request-payer: HEAD, GET, ListObjectsV2,S3schema inference, a read of theS3table after a server restart, BACKUP and RESTORE carry the header (red on master and on 26.10.2.103 at the first request);NOSIGN, query keys, an unmatched URL, an explicit-key BACKUP and a BACKUP to an endpoint section without keys do not. An endpoint header forbidden byhttp_forbid_headersfailss3(), BACKUP and RESTORE before any request.Workflow [PR]
Sync PR [sync-upstream/pr/131529]