fix: redact secret query values from the uvicorn access log - #232
Merged
Conversation
The documented `?token=` script auth was written verbatim by uvicorn's access logger (observed in journald on the 2026-08-02 systemd deploy; token rotated). A mutating logger-level filter — reusing the transport URL scrubber via the new public `redact_url` alias — is installed at all three uvicorn launch sites and survives uvicorn's own dictConfig.
ArthurBernard
force-pushed
the
fix/access-log-token-redaction
branch
from
August 2, 2026 15:51
fb1b6a9 to
fe00b66
Compare
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.
Summary
?token=script auth leaked the live dashboard token into journald (observed on the 2026-08-02 systemd deploy; token rotated immediately).logging.Filter(AccessLogRedactionFilter) now scrubsuvicorn.access+uvicorn.errorrecords at all three serving commands (serve,start --serve,dashboard), reusing the transport scrubber via a publicredact_urlalias — same key set (token/signature/api_key/nonce), same<redacted>marker.Why
dictConfigreplaces handlers but keeps logger filters; locked by a test). Rejected: forking uvicorn's log-config dict per site; duplicating the key set at the interface layer. Full ADR indoc/dev/03-decisions.md.Changes
transport/http.py— publicredact_urlalias (no behaviour change) + a stale comment fixed (the marker percent-encodes to%3Credacted%3Eon the wire).application/log_setup.py—AccessLogRedactionFilter+ idempotentinstall_access_log_redaction()(uvicorn.access+uvicorn.error).interfaces/cli/main.py— install called before all three uvicorn launches.Changelog
Fixed under [Unreleased]:
Test plan
python -m pytest— 1522 passed, 96.34% coverageruff check trading_bot/+ruff format --check .passmypy trading_bot/— no issues in 60 files?token=LEAKCANARY123→ access-log line showstoken=%3Credacted%3E, canary absent from the whole log; clean/benign queries byte-identical; clean SIGTERM exit