Repository navigation
#803: redact the Content-Type before BadResponse cuts it - #805
Open
ephico2real2 wants to merge 1 commit into
Open
ephico2real2 wants to merge 1 commit into
ephico2real2 wants to merge 1 commit into
Conversation
KubeClient._object put the server's Content-Type, cut to 60 characters, into BadResponse without the client's redaction, against docs/02 "Client rules" (redact the whole text, then cut). RFC 9110 §5.6.6 lets a parameter-value be any quoted string, so the field can carry an echoed credential. The parse is now the module function json_object(r, path, redact), with redact required: None names no text of the server's (the old sensitive=True). The instance method _object passes self.redact, so every KubeClient call site is redacted without an edit, and HubImportSource.list calls json_object(r, path, None). The comment in ThanosQuerier._base_url now states the order. Test: test_bad_response_redaction_803.py, a real server on 127.0.0.1 whose Content-Type carries the token whole, split by the cut, and cut by the server. docs/21 citations relocated (27 moved) and the two thanos.py ranges re-read.
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.
Closes #803
Part of #26
Written by Opus 5.5 at
high(all commits). Small security fix: reviewer 1 only, per CLAUDE.md.What was wrong
KubeClient._object(cmapi/src/cmapi/core/clients/kube.py, old line 221) put the server's Content-Type, cut to 60 characters, intoBadResponsewithout the client's redaction, against docs/02 "Client rules" (redact the whole text, then cut). The comment inThanosQuerier._base_urlsaid KubeClient redacts each of these errors.Why a header value is redacted
RFC 9110 (fetched 2026-12-01, https://www.rfc-editor.org/rfc/rfc9110.txt): §8.3 "The "Content-Type" header field indicates the media type of the associated representation ... Content-Type = media-type"; §8.3.1 "media-type = type "/" subtype parameters"; §5.6.6 "parameter-value = ( token / quoted-string )". A quoted-string holds any visible text (§5.6.4 qdtext), so a proxy that echoes the Authorization header can put the token in it. It is the server's text in an error message, so the same rule holds as for a body.
Fix (improves reviewer 2's L1 proposal on #795)
json_object(r, path, redact);redactis required, and None names no text of the server's (the oldsensitive=True). The whole Content-Type is redacted, then cut to 60.KubeClient._objectis now an instance method that passesself.redact(None when sensitive). Every KubeClient call site is redacted with no edit. Reviewer 2 proposed an identity default on the static method, which fails open for a call site that forgets it.HubImportSource.listcallsjson_object(r, path, None), as before naming no server text.thanos.pycomment corrected. docs/21: 27 citations relocated byscripts/doc-citations.py --relocate; the twothanos.pyranges re-read and recorded with--write;--check0 problems.Tests (no cluster; real HTTP server on 127.0.0.1)
cmapi/tests/service/test_bad_response_redaction_803.py: Content-Type holding the token whole, split by the 60-character cut, and cut short by the server, across get, version, whoami, list, get_object, apply and access_review, for a JWT and a token with escaped characters. Before the fix: 6 failed, 2 passed (the two behaviour-preservation tests: an unredacted media type is named as before, and the reader TokenRequest still names no Content-Type). After: 8 passed.Not tested: the full suite locally (CI gates it); any cluster.