fix(log): redact OAuth code and state query params in the access log#3972
Conversation
OAuth callbacks (GET /api/auth/:strategy/callback?code=...&state=...) wrote the one-time authorization code and state into the morgan access log in cleartext. Same single-use-secret-in-URL leak class already closed for inviteToken/reset/verify-email (#3955/#3961). Add 'code' and 'state' to DEFAULT_SENSITIVE_QUERY_KEYS in lib/helpers/redactUrl.js so they are redacted by default everywhere, without requiring per-project config. Update the JSDoc and the development.config.js comment that documents the built-in defaults, and add unit tests covering the OAuth callback shape. Closes #3967 Claude-Session: https://claude.ai/code/session_01WfNC8bt1TgL4AsiYgCEGup
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
WalkthroughThe URL redaction defaults now include OAuth ChangesOAuth URL redaction
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3972 +/- ##
=======================================
Coverage 93.06% 93.06%
=======================================
Files 170 170
Lines 5595 5595
Branches 1802 1803 +1
=======================================
Hits 5207 5207
Misses 313 313
Partials 75 75
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
Summary
codeandstatetoDEFAULT_SENSITIVE_QUERY_KEYSinlib/helpers/redactUrl.js, unioned withconfig.log.sensitiveQueryKeysextensions per refactor(log): source sensitive redaction lists from config as pure extensions #3961. Updated thedevelopment.config.jscomment listing the built-in defaults to match.GET /api/auth/:strategy/callback?code=...&state=...) were logging the one-time authorization code and state cleartext in the morgan access log. Same single-use-secret-in-URL leak class already closed forinviteToken/reset/verify-email tokens (fix(log): redact single-use path tokens in the morgan access log #3955/refactor(log): source sensitive redaction lists from config as pure extensions #3961) — access logs persist and reach log shippers far longer than the code's short TTL.Scope
lib/helpers/redactUrl.js(shared log redaction helper),config/defaults/development.config.js(comment only)Validation
npm run lintnpm testGuardrails check
.env*,secrets/**, keys, tokens)Notes for reviewers
code/statein the access log. Fix is additive-only (built-in defaults list), consistent with the config-sourcing contract landed in refactor(log): source sensitive redaction lists from config as pure extensions #3961 (union of defaults + config extensions, never a replace).code/stateparams, mixed with other query params, and an explicitSENSITIVE_QUERY_KEYSassertion), plus updated the 4 existing config-sourcing tests that assert the exact default array. Full suite: 2187 tests green, 100% coverage onlib/helpers/redactUrl.js.https://claude.ai/code/session_01WfNC8bt1TgL4AsiYgCEGup
Summary by CodeRabbit
codeandstate) are now automatically redacted from logged URLs.