fix(security): redact secret query params from req.url before log#76
Merged
Merged
Conversation
…dit #73 P1-C) logger.js redacts the authKey HTTP header value, but pino-http's req serializer logs req.url verbatim — so an SDK that mistakenly sends \`GET /v1/customer/1?authKey=...\` ends up with the raw token in the structured log stream. Log shippers (Loki, Datadog, etc.) then carry that token until rotated or aged out. New helper: app/middleware/redact-url.js — strips a known-sensitive parameter allowlist (authKey, apiKey, api_key, token, access_token, password, secret) from the query string, replacing each value with \`<REDACTED>\` while preserving path + ordering + non-sensitive params (so the URL is still useful for routing-level analysis). server.js's pino-http req serializer routes req.url through the redactor before logging. Tests: 11 cases — no-querystring passthrough, case-insensitive matching, every alias in the sensitive set, mixed sensitive + non-sensitive params, encoded names, defensive handling of non- string input. Closes #73 P1-C. Suite: 291 / 291 + 4 integration skipped (was 280 / 280). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.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.
Closes #73 P1-C.
Problem
logger.js redacts the
authKeyHTTP header but pino-http'sreqserializer logsreq.urlverbatim. An SDK that mistakenly sends?authKey=...in the URL leaks the raw token to the structured log stream + log shippers.Fix
New
app/middleware/redact-url.jsstrips a sensitive-param allowlist (authKey, apiKey, api_key, token, access_token, password, secret) from the query string before the URL hits the logger. Path + ordering + non-sensitive params preserved for log analytics.Test plan
AuthKey,authkey,AUTHKEY)Proudly Made in Nebraska. Go Big Red! 🌽 https://xkcd.com/2347/