Skip to content

feat(EXPOSED_SECRETS): broaden secret detection and stop leaking matched values#35

Open
dmchaledev wants to merge 1 commit into
mainfrom
claude/amazing-franklin-lwenzn
Open

feat(EXPOSED_SECRETS): broaden secret detection and stop leaking matched values#35
dmchaledev wants to merge 1 commit into
mainfrom
claude/amazing-franklin-lwenzn

Conversation

@dmchaledev

Copy link
Copy Markdown
Contributor

Summary

Hardens the EXPOSED_SECRETS rule — the scanner's CRITICAL "hardcoded secret" check — on two fronts: it caught too little, and it re-exposed what it did catch.

1. Broader detection (false-negative fix)

EXPOSED_SECRETS matched only 4 credential formats (OpenAI sk-, classic GitHub ghp_, AWS AKIA, password:). It silently missed several of the most common things people hardcode into MCP configs. Detection is now 9 high-confidence patterns, adding:

  • PEM private keys-----BEGIN … PRIVATE KEY----- (RSA/EC/OPENSSH/DSA/PGP)
  • Slack tokens — xox[baprs]-…
  • Google API keys — AIza…
  • Stripe live secret keys — [sr]k_live_…
  • Scoped GitHub tokens (gho_/ghu_/ghs_/ghr_) and fine-grained PATs (github_pat_…)
  • AWS temporary access keys — ASIA… (alongside existing long-term AKIA…)

All patterns stay prefix-/structure-anchored to keep the false-positive rate low — a JWT-shaped transport.auth.token (which the auth rules treat as valid auth) is not flagged, and the bundled examples/secure-config.json stays clean.

2. No longer leaks the matched secret (security fix)

The finding's evidence previously printed a truncated copy of the matched credential — which then flows into CI logs and uploaded SARIF, re-exposing the very secret the rule exists to catch. It now reports the secret types detected instead:

Detected 2 likely secret type(s): OpenAI API key, PEM private key

Tests

Adds the first test coverage for EXPOSED_SECRETS (it had none): a per-pattern positive case for each format, the no-leak evidence guarantee, type de-duplication, and false-positive guards (JWT token, ordinary config strings, absent input). Full suite: 135 passing (was 118). build and lint clean.

Scope

Localized to src/rules/runtime-rules.ts plus tests and a CHANGELOG entry. No public API or output-schema changes; the only behavioral change to existing findings is that evidence now names the secret type rather than echoing the value.

🤖 Generated with Claude Code


Generated by Claude Code

…hed values

Expand the EXPOSED_SECRETS rule from 4 to 9 high-confidence credential
patterns and stop echoing the matched secret into the finding.

New patterns: PEM private keys (RSA/EC/OPENSSH/DSA), Slack tokens, Google
API keys, Stripe live secret keys, scoped GitHub tokens (gho_/ghu_/ghs_/
ghr_) and fine-grained PATs (github_pat_), and AWS temporary access keys
(ASIA) alongside the existing AKIA. Patterns remain prefix-anchored to keep
the false-positive rate low — a JWT-shaped auth.token is not flagged.

The finding evidence previously truncated and printed the matched secret,
re-exposing it in CI logs and uploaded SARIF. It now names the secret
*types* detected instead (e.g. "Detected 2 likely secret type(s): OpenAI
API key, PEM private key").

Adds the first test coverage for EXPOSED_SECRETS: per-pattern positive
cases, the no-leak evidence guarantee, type de-duplication, and
false-positive guards (JWT token, ordinary config strings, absent input).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NYU6nnRkj9cM4yobBvUKwG
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.

2 participants