Skip to content

fix(security): redact secret query params from req.url before log#76

Merged
CryptoJones merged 1 commit into
masterfrom
fix/security-redact-url-query-secrets
May 18, 2026
Merged

fix(security): redact secret query params from req.url before log#76
CryptoJones merged 1 commit into
masterfrom
fix/security-redact-url-query-secrets

Conversation

@CryptoJones
Copy link
Copy Markdown
Owner

Closes #73 P1-C.

Problem

logger.js redacts the authKey HTTP header but pino-http's req serializer logs req.url verbatim. 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.js strips 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

  • vitest: 291 + 4 integration skipped (was 280 + 4 skipped); 11 new redact-url cases
  • Case-insensitive match (AuthKey, authkey, AUTHKEY)
  • Every alias in the sensitive set
  • Mixed sensitive + non-sensitive params keep order

Proudly Made in Nebraska. Go Big Red! 🌽 https://xkcd.com/2347/

…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>
@CryptoJones CryptoJones merged commit 9a49fbc into master May 18, 2026
@CryptoJones CryptoJones deleted the fix/security-redact-url-query-secrets branch May 18, 2026 02:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Architecture audit: prioritized list of security + functionality follow-ups

1 participant