fix: redact credentials in the wire logger and widen the field set - #5
Merged
Merged
Conversation
The httplib completion logger printed the request body verbatim, which is the path an OAuth2 token POST takes - so client_secret went straight into the trace, bypassing RedactBody entirely. The response preview had the same problem for access_token and refresh_token. Both now go through RedactBody. RedactBody also bailed out of a JSON value with no closing quote. Trace bodies are truncated before they reach it, so the cut regularly lands mid token and the visible prefix of an access_token was printed verbatim. An unterminated value is now redacted to the end of the string. Widened the credential set with id_token, client_assertion, code and code_verifier: a signed assertion and an authorization code with its verifier are as exchangeable as a secret.
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.
Three credential-leak paths in DEBUG tracing, found by a final review and verified against a live Microsoft OAuth2 token exchange.
The leaks
client_secretwent straight into the trace, bypassingRedactBodyentirely.access_tokenandrefresh_token.RedactBodybailed out of a JSON value with no closing quote. Trace bodies are truncated before they reach it, so the cut regularly lands mid-token — and the visible prefix of anaccess_tokenwas then printed verbatim. This one only appeared after the truncate-before-redact change made for performance, which is a good argument for testing redaction against real traffic rather than a synthetic body.Also widened the credential set with
id_token,client_assertion,codeandcode_verifier: a signed assertion, and an authorization code with its verifier, are as exchangeable as a secret.Verified live
A real client-credentials flow against a Microsoft tenant with
erpl_trace_level='DEBUG':"access_token":"<jwt>"Bearer <jwt>in headersBefore the fix the same run leaked the access token twice.
Refs DataZooDE/erpl-web#100.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.