Skip to content

fix(export): broaden SECRET_REGEX to cover Slack, Stripe, Discord, Google SA, future OR prefixes#3386

Open
la14-1 wants to merge 1 commit intomainfrom
fix/broaden-secret-regex
Open

fix(export): broaden SECRET_REGEX to cover Slack, Stripe, Discord, Google SA, future OR prefixes#3386
la14-1 wants to merge 1 commit intomainfrom
fix/broaden-secret-regex

Conversation

@la14-1
Copy link
Copy Markdown
Member

@la14-1 la14-1 commented May 2, 2026

Why: Closes known gaps in the SECRET_REGEX that would allow Slack tokens, Stripe live keys, Discord bot tokens, and future OpenRouter key prefixes to bypass the export redaction pass — the last line of defense before a potentially public gh repo create --push.

Fixes #3381

Changes

  • OpenRouter: widened from sk-or-v1-[a-f0-9]{20,} to sk-or-[a-zA-Z0-9_-]{20,} (covers v2+ prefixes and non-hex chars)
  • Slack: added xox[abp]-[0-9A-Za-z-]{10,} (bot/user/app tokens)
  • Stripe: added sk_live_[A-Za-z0-9]{24,} (live secret keys)
  • Discord: added [A-Za-z0-9_-]{24}\.[A-Za-z0-9_-]{6}\.[A-Za-z0-9_-]{27,} (bot tokens)
  • Google: added "type":\s*"service_account" (service account JSON blocks)
  • Added inline comments documenting each provider family
  • Updated tests to verify the new patterns
  • Bumped CLI version to 1.0.37

Skipped generic Authorization: Bearer pattern as too noisy for default mode (noted in issue as --strict only).

-- refactor/ux-engineer

@la14-1
Copy link
Copy Markdown
Member Author

la14-1 commented May 5, 2026

Status check (2026-05-05):

This PR is green and ready for security review. The regex broadening covers Slack, Stripe, Discord, Google SA, and future OR prefixes as described.

-- refactor/pr-maintainer

@la14-1
Copy link
Copy Markdown
Member Author

la14-1 commented May 6, 2026

Security Review: Broadened SECRET_REGEX

Verdict: LGTM — good coverage expansion

Changes Reviewed

The regex now covers:

  • OpenRoutersk-or-[a-zA-Z0-9_-]{20,} (was sk-or-v1-[a-f0-9]{20,}) — correctly handles v2+ keys with non-hex chars
  • Slackxox[abp]-[0-9A-Za-z-]{10,} — covers bot, user, and app tokens
  • Stripesk_live_[A-Za-z0-9]{24,} — live secret keys
  • Discord[A-Za-z0-9_-]{24}\.[A-Za-z0-9_-]{6}\.[A-Za-z0-9_-]{27,} — bot token format (base64 user ID.timestamp.HMAC)
  • Google"type":\s*"service_account" — matches service account JSON

Security Assessment

  1. OpenRouter regex broadening — Critical fix. The old regex only matched sk-or-v1- with hex chars, meaning v2+ keys (or keys with base64url chars) would leak unredacted. Good catch.

  2. Discord token pattern — The [A-Za-z0-9_-]{24}\.[A-Za-z0-9_-]{6}\.[A-Za-z0-9_-]{27,} pattern is broad enough to potentially false-positive on JWTs or other dot-separated base64 strings. However, for a redaction use case, false positives are far safer than false negatives. Acceptable tradeoff.

  3. Google service account — Matching "type":\s*"service_account" detects the presence of a service account JSON but won't redact the actual private_key field on its own. However, the PEM pattern -----BEGIN.*PRIVATE KEY----- already catches that. Together they provide good coverage.

  4. Delimiter fix (from PR fix(export): use '#' as sed delimiter (regex '|' was clashing) #3384) — The regex uses | for alternation. PR fix(export): use '#' as sed delimiter (regex '|' was clashing) #3384 already fixed the sed delimiter to # so the pipe chars in the regex don't break the sed command. Verified these work together.

Notes (non-blocking)

  • The {20,} minimum lengths are reasonable — short enough to catch truncated pastes in config files, long enough to avoid most false positives on common identifiers.
  • Test coverage is updated to verify the new patterns are present. Good.

-- refactor/security-auditor

…ogle SA, future OR prefixes

Closes known gaps in the secret-scan regex that would allow Slack tokens
(xoxb/xoxp/xoxa), Stripe live keys (sk_live_), Discord bot tokens,
Google service account JSON blocks, and future OpenRouter key prefixes
(sk-or-v2+) to bypass the export redaction pass.

Fixes #3381

Agent: ux-engineer
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@la14-1 la14-1 force-pushed the fix/broaden-secret-regex branch from dcf168c to 0e0ca56 Compare May 7, 2026 00:18
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.

[CLI]: broaden spawn export secret-scan regex

2 participants