Skip to content

fix(logging): redact sensitive query params and gate WS payload logs#133

Merged
andreasjansson merged 10 commits intomainfrom
fix-secret-exposure
Feb 2, 2026
Merged

fix(logging): redact sensitive query params and gate WS payload logs#133
andreasjansson merged 10 commits intomainfrom
fix-secret-exposure

Conversation

@andreasjansson
Copy link
Copy Markdown
Member

Summary

Fixes #85 - CDP_SECRET and other sensitive query params were being logged in plain text
Fixes #117 - WebSocket message payloads (which can contain sensitive user content) were being logged in production

Changes

Security fixes:

  • Redact sensitive query params from request logs - Any query param containing secret, token, key, password, auth, or credential (case-insensitive) is now redacted to [REDACTED] in logs
  • Gate WebSocket payload logging behind DEBUG_ROUTES - Verbose WS message logging (which could contain user content, auth data, or tokens) is now only enabled when DEBUG_ROUTES=true

New files:

  • src/utils/logging.ts - Contains redactSensitiveParams() function
  • src/logging.test.ts - Unit tests for redaction logic (13 tests)
  • test/e2e/log_redaction.txt - E2E cctr tests verifying logs don't contain secrets

Testing

  • All 82 unit tests pass
  • E2E tests verify:
    • Secret values do NOT appear in logs
    • [REDACTED] placeholder appears instead
    • Gateway token is not logged in [REQ] lines

Fixes #85 - CDP_SECRET and other sensitive params like tokens were being
logged in plain text. Now any query param containing secret, token, key,
password, auth, or credential (case-insensitive) is redacted.
Fixes #117 - WebSocket message payloads (which can contain sensitive user
content, authentication data, or tokens) were being logged in production.
Now verbose payload logging is only enabled when DEBUG_ROUTES=true.
Regression tests for #85 - ensures sensitive query params like secret,
token, key, password, auth, credential are properly redacted from logs.
Move the function to a separate module to make it testable without
pulling in heavy sandbox dependencies.
These tests verify:
- Secret query params are redacted from request logs
- Token query params are redacted from request logs
- The [REDACTED] placeholder appears in logs instead of actual values
The CDP endpoint returns 503 when CDP_SECRET isn't configured. Instead,
use simple curl requests and just verify logs are correct.
The redacted value appears as %5BREDACTED%5D in logs due to URL encoding.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 2, 2026

E2E Test Recording (base)

✅ Tests passed

E2E Test Video

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 2, 2026

E2E Test Recording (telegram)

✅ Tests passed

E2E Test Video

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 2, 2026

E2E Test Recording (discord)

✅ Tests passed

E2E Test Video

@andreasjansson andreasjansson merged commit a6687ff into main Feb 2, 2026
7 checks passed
@andreasjansson andreasjansson deleted the fix-secret-exposure branch February 2, 2026 15:54
CarlosCASAWiki pushed a commit to CarlosCASAWiki/moltworker that referenced this pull request Mar 11, 2026
fix(logging): redact sensitive query params and gate WS payload logs
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.

Sensitive WebSocket payloads are logged in production [SECURITY] CDP_SECRET exposed in request logs

1 participant