Skip to content

fix: redact credentials in the wire logger and widen the field set - #5

Merged
jrosskopf merged 1 commit into
mainfrom
fix/wire-logger-redaction
Sep 10, 2026
Merged

jrosskopf merged 1 commit into
mainfrom
fix/wire-logger-redaction

Conversation

@jrosskopf

@jrosskopf jrosskopf commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Three credential-leak paths in DEBUG tracing, found by a final review and verified against a live Microsoft OAuth2 token exchange.

The leaks

  1. The httplib completion logger printed the request body verbatim — and that is exactly the path an OAuth2 token POST takes, so client_secret went straight into the trace, bypassing RedactBody entirely.
  2. The response preview had the same problem in the other direction: a token endpoint's response carries access_token and refresh_token.
  3. RedactBody 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 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, code and code_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':

checked for occurrences
the client secret's literal value 0
"access_token":"<jwt>" 0
Bearer <jwt> in headers 0
query still returned its row yes

Before the fix the same run leaked the access token twice.

Refs DataZooDE/erpl-web#100.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

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.
@jrosskopf
jrosskopf merged commit 1259a15 into main Sep 10, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant