Repository navigation
fix(proxy): redact sensitive headers in request logs - #2161
Merged
Merged
Conversation
The dfdaemon proxy Debug-printed the full http::Request at its routing log sites (rule config match, X-Dragonfly-Use-P2P header, direct HTTP/HTTPS proxy, and non-GET bypasses), which leaked the complete authorization, cookie, proxy-authorization, and www-authenticate header values, e.g. 'authorization: Bearer eyJ...', into the logs. Add a RedactedRequest Debug wrapper to the existing redaction helpers in dragonfly-client-util. It prints the method, uri, and version, keeps the non-sensitive headers for request correlation, and replaces the sensitive header values with [REDACTED]; the body is never printed. Switch all Request-dumping log sites in proxy/mod.rs to the wrapper and cover it with unit tests. Signed-off-by: yxxhero <aiopsclub@163.com>
yxxhero
requested review from
CooooolFrog,
Zephyrcf,
anjia0532,
bergwolf,
imeoer and
mingcheng
November 11, 2026 00:23
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2161 +/- ##
==========================================
+ Coverage 65.85% 67.01% +1.15%
==========================================
Files 102 102
Lines 31479 32843 +1364
==========================================
+ Hits 20731 22010 +1279
- Misses 10748 10833 +85
🚀 New features to boost your workflow:
|
Rename `RedactedRequest` to `RedactedHTTPProxyRequest` and switch its header output from a deny-list (redacting authorization, cookie, etc.) to an allow-list that prints only `range`, `user-agent`, `host` and `x-request-id`. This keeps the per-request log line small and ensures any unexpected sensitive header never reaches the logs. Generalize `KeyRequestHeader` over any `(K, V)` iterable so the same filter serves both `HeaderMap` and `HashMap` headers, drop the now unused sensitive-header helpers, and update tests and proxy call sites accordingly. Signed-off-by: Gaius <gaius.qi@gmail.com>
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.
Description
The dfdaemon proxy Debug-printed the full
http::Requestat its routing log sites (rule config match,X-Dragonfly-Use-P2Pheader, direct HTTP/HTTPS proxy, and non-GET bypasses), which leaked the completeauthorization,cookie,proxy-authorization, andwww-authenticateheader values, e.g.authorization: Bearer eyJ..., into the logs.This PR adds a
RedactedRequestDebug wrapper to the existing redaction helpers indragonfly-client-util:method,uri, andversionas-isauthorization,cookie,proxy-authorization, andwww-authenticatewith[REDACTED](case-insensitive match; repeated headers are redacted per value)All request-dumping log sites in
dragonfly-client/src/proxy/mod.rsare switched to the wrapper, and the wrapper is covered by unit tests.Related Issue
N/A (reported directly;
mainis affected the same way)Motivation and Context
Bearer tokens (JWTs), session cookies, and proxy credentials were written verbatim to dfdaemon logs at
info!level on every proxied request, exposing credentials to anyone with log access.Screenshots (if appropriate)
N/A
Test plan:
cargo fmt --checkcargo test -p dragonfly-client-util(102 passed, including 3 new redaction tests)cargo build(full workspace)cargo clippy -p dragonfly-client-util -p dragonfly-client(clean)