You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
security: token-leak bug in canonical redaction package (Z-050) #922
There is a logic gap in the canonical redaction package's
ormalizeKey function that leads to sensitive tokens leaking into logs and other outputs. The current normalization logic splits keys only on non-alphanumeric characters.
As a result, keys using camelCase (e.g., �ccessToken,
efreshToken, �piKey) are normalized to a lowercase string without delimiters (e.g., �ccesstoken,
efreshtoken). If the sensitiveKeys list—which the package uses to identify what needs redaction—expects a different normalization or uses specific matches that don't align with this simplistic alphanumeric split, these tokens are not flagged for redaction.
Impact
High-entropy secrets (API keys, OAuth tokens) may be written to disk in logs or displayed in the TUI/CLI output. This exposes credentials to any process or user with access to the logs, significantly increasing the risk of credential theft.
Recommended Fix
The normalization logic needs to be more sophisticated to recognize common programming naming conventions:
CamelCase Splitting: Modify
ormalizeKey to treat transitions from lowercase to uppercase as delimiters (e.g., �ccessToken $\rightarrow$ �ccess_token).
Unified Registry: Unify the normalization logic between the code that detects keys in the stream and the registry of sensitiveKeys to ensure a consistent match.
Broaden Heuristics: Consider adding specific high-confidence patterns for common token formats if normalization proves insufficient.
Reproduced locally on main. Confirmed, and the end-to-end impact is worse than the report claims — an opaque refresh token leaks verbatim.
The mechanism, verified
normalizeKey (internal/redaction/redaction.go:406-422) splits only on non-alphanumeric runes, so a camelCase boundary produces no delimiter. The registry (redaction.go:33-58) stores the underscored spellings. They cannot meet:
Seven of eight camelCase spellings are unrecognised. apiKey is the sole survivor, and only by accident — apikey happens to be in the registry as a delimiter-free entry, so it is not evidence the mechanism works.
The leak, end to end
RedactValue on the shape an OAuth provider actually returns:
Identical data. The only difference is the key spelling.
The part that makes this worse than "some keys are missed"
accessToken came out redacted — but not because the key was recognised. Its value was sk-ant-api03-…, which the shape matcher catches on its own. The refreshToken value is opaque (1//0eXaMpLe…, the Google refresh-token shape) and has no matchable structure, so with the key unrecognised there was nothing left to save it.
That inverts the usual reasoning about defence in depth here: key-based redaction matters most for exactly the secrets shape-matching cannot see. The current gap fails on the class it is most needed for, and the passing accessToken case makes the failure look narrower than it is.
camelCase is not an unusual spelling — it is what OAuth and OIDC responses use, and what Go's encoding/json produces from an unannotated struct.
What I did not check
Which call sites actually feed provider payloads through RedactValue, so I cannot say how far a leaked token travels in practice — only that redaction does not stop it. I also did not survey ExtraSensitiveKeys usage, which would mask this for any caller that happens to pass camelCase spellings explicitly.
The report's suggested fix (splitting on lower→upper transitions) resolves all seven above; the registry then needs no new entries, which also avoids the two-lists-that-must-agree problem.
Activity
gnanam1990 commentedon Aug 24, 2026
Reproduced locally on
main. Confirmed, and the end-to-end impact is worse than the report claims — an opaque refresh token leaks verbatim.The mechanism, verified
normalizeKey(internal/redaction/redaction.go:406-422) splits only on non-alphanumeric runes, so a camelCase boundary produces no delimiter. The registry (redaction.go:33-58) stores the underscored spellings. They cannot meet:Seven of eight camelCase spellings are unrecognised.
apiKeyis the sole survivor, and only by accident —apikeyhappens to be in the registry as a delimiter-free entry, so it is not evidence the mechanism works.The leak, end to end
RedactValueon the shape an OAuth provider actually returns:Identical data. The only difference is the key spelling.
The part that makes this worse than "some keys are missed"
accessTokencame out redacted — but not because the key was recognised. Its value wassk-ant-api03-…, which the shape matcher catches on its own. TherefreshTokenvalue is opaque (1//0eXaMpLe…, the Google refresh-token shape) and has no matchable structure, so with the key unrecognised there was nothing left to save it.That inverts the usual reasoning about defence in depth here: key-based redaction matters most for exactly the secrets shape-matching cannot see. The current gap fails on the class it is most needed for, and the passing
accessTokencase makes the failure look narrower than it is.camelCase is not an unusual spelling — it is what OAuth and OIDC responses use, and what Go's
encoding/jsonproduces from an unannotated struct.What I did not check
Which call sites actually feed provider payloads through
RedactValue, so I cannot say how far a leaked token travels in practice — only that redaction does not stop it. I also did not surveyExtraSensitiveKeysusage, which would mask this for any caller that happens to pass camelCase spellings explicitly.The report's suggested fix (splitting on lower→upper transitions) resolves all seven above; the registry then needs no new entries, which also avoids the two-lists-that-must-agree problem.
fix(redaction): split camelCase keys in normalizeKey (#994)