Repository navigation
Scrub the request's bearer token from the reason phrase of an HTTP error response - #126180
Conversation
…ror response ClickHouse#120407 scrubs the request's bearer token (`requestCredentialSecrets`) from the body of an HTTP error response, but `HTTPException::makeExceptionMessage` formatted the reason phrase raw. The reason phrase is remote content too, so a peer that answers `401 invalid token <token>` to a `url()` request carrying `headers('Authorization' = 'Bearer <token>')` put the token into the client error, the server log and `system.query_log.exception`. Apply the same scrub to the reason phrase, in the formatter that already holds the secrets and is reached by both callers that pass them. Rename the parameter `body_secrets` to `response_secrets`, since it no longer applies to the body only. The new test starts a local peer that reflects the token in its reason phrase: ClickHouse's own HTTP server never puts request content there, so no existing test reaches this path. Closes ClickHouse#125282 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 1 finding) plus my own cold review (2 nits).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-9:20261016-020600 |
|
Workflow [PR], commit [916614f] Summary: ✅
AI ReviewSummaryThe PR extends bearer-token scrubbing from HTTP error bodies to reason phrases in Missing context / blind spots
Final VerdictStatus: ✅ Approve. |
|
cc @hanfei1991 @alexey-milovidov, could you review this? After #120407, |
97b74a2
Closes: #125282
Related: #120407
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
The reason phrase of an HTTP error response from a remote server is now scrubbed of the request's bearer token in the error message, as the response body already is.
Description
#120407 scrubs the request's bearer token from the body of an HTTP error response, but
HTTPException::makeExceptionMessagestill formats the reason phrase raw. A peer that answersurl(..., headers('Authorization' = 'Bearer <token>'))with401 invalid token <token>puts the token into the client error, the server log andsystem.query_log.exception, while the query text itself is already masked. This is the second gap named in #125282.The change applies the existing scrub to the reason phrase as well, in the one formatter that holds the secrets and is reached by both callers that pass them (
ReadWriteBufferFromHTTPfor reads,receiveResponseforWriteBufferFromHTTP). The parameterbody_secretsis renamed toresponse_secrets, since it no longer applies to the body only.The Avro schema registry 409 branch from #125282 needs no change: the registry only sends
Basicauthentication, andrequestCredentialSecretsreturns nothing forBasic, so no registry error body is scrubbed on any status and the 409 path already matches the common one.05401_http_error_reason_phrase_credentials_masked.pystarts a local peer that reflects the token in its reason phrase and checks both the error and thesystem.query_logrow. With only the reason scrub reverted it prints the token in cleartext; with the fix it passes, also under the parallel replicas profile.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/126180]
Version info
26.11.1.83-master(included in26.11and later)