Skip to content

Comments

security: sanitize tokens from error messages#3

Open
domid wants to merge 1 commit intonovincode:mainfrom
domid:security/sanitize-tokens-in-errors
Open

security: sanitize tokens from error messages#3
domid wants to merge 1 commit intonovincode:mainfrom
domid:security/sanitize-tokens-in-errors

Conversation

@domid
Copy link

@domid domid commented Feb 4, 2026

Summary

Adds token sanitization to prevent credential leaks in error output.

Problem

When Wrangler fails, its stderr output could potentially contain the API token (e.g., in debug messages or certain error conditions). This token would then be displayed to the user in the console.

Solution

Added a sanitizeTokens() helper function that redacts sensitive tokens before any error message is logged or returned:

  • Cloudflare API tokens: cf_XXX...[REDACTED]
  • Environment variable assignments: CLOUDFLARE_API_TOKEN=xxxCLOUDFLARE_API_TOKEN=[REDACTED]
  • Bearer tokens: Bearer xxxBearer [REDACTED]

Changes

  • src/utils/shell.ts: Added sanitizeTokens() function and applied it to error message handling in runWranglerCommand()

Testing

  • Build passes successfully
  • No breaking changes to existing functionality

Add sanitizeTokens() helper to prevent credential leaks in error output.
Redacts:
- Cloudflare API tokens (cf_XXX pattern)
- CLOUDFLARE_API_TOKEN env var assignments
- Bearer tokens in auth headers
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.

1 participant