fix(log): redact single-use path tokens in the morgan access log - #3955
Conversation
redactUrl() now applies redactPathSecrets() on both branches (with and without a query string) so reset/verify-email/invitation tokens embedded in the URL path never reach the access log. Closes #3951 Claude-Session: https://claude.ai/code/session_01WfNC8bt1TgL4AsiYgCEGup
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3955 +/- ##
=======================================
Coverage 92.70% 92.70%
=======================================
Files 169 169
Lines 5563 5563
Branches 1791 1790 -1
=======================================
Hits 5157 5157
Misses 326 326
Partials 80 80
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:
|
|
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)
Walkthrough
ChangesURL secret redaction
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install timed out. The project may have too many dependencies for the sandbox. 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 |
…3972) 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
Summary
redactPathSecrets()now runs on both branches ofredactUrl()(with and without a query string), so single-use tokens carried as PATH parameters — password-reset, email-verify and invitation links — are redacted before reaching the morgan access log.redactUrl()only scrubbed the query string. A URL with no?(e.g.GET /api/auth/reset/:token) was returned verbatim, so a legitimate click on a reset/verify-email/invitation link wrote the still-valid, replayable token straight into the server access log. fix(analytics): redact single-use path tokens before auto-capture (#3932) #3935 already redacted the analytics sink but missed this access-log path.Scope
lib/helpers/redactUrl.js,lib/services/express.js(morgan:urltoken wiring, comment only)nonelowValidation
npm run lintnpm testGuardrails check
.env*,secrets/**, keys, tokens)Notes for reviewers
redactUrl()before the fix, now pass) covering reset/verify-email/invitation path tokens, with and without a trailing query string, and a combined path+query redaction case.https://claude.ai/code/session_01WfNC8bt1TgL4AsiYgCEGup
Summary by CodeRabbit