Skip to content
All rules

SECRET-KNOWN

API key with a known prefix in the code

Severity
Critical
Confidence
High
Stack
Secrets
Runs
On by default

What the CLI looks for

Keys with well-known prefixes, such as sk-, sk_live_, sk-ant- or AKIA, in the source code.

Why it matters

Live keys in a repository are picked up by automated scanners soon after a push to a public repo, and they stay in the git history.

How to fix it

Revoke and rotate the key with the provider, then load it from a server-side environment variable.

// Server-side only
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!);