Hardcoded Secrets
Hardcoded API keys, tokens, private keys and database URLs with credentials (Stripe, AWS, OpenAI, Anthropic, GitHub, Supabase and more)
criticalSecurity
secretsWhy this matters
Hardcoded secrets end up in git history, build logs, and client bundles. Once pushed, rotating the key is the only fix — and attackers scan public repos continuously.
Example
lib/stripe.tsconst stripe = new Stripe(
"sk_live_51abc123def456ghi789jkl"
);lib/stripe.tsconst stripe = new Stripe(
process.env.STRIPE_SECRET_KEY!
);How to fix
Move all secrets to environment variables. Use a .env file locally (added to .gitignore) and your hosting provider's secret manager in production.
Reference
- In the output
- Findings carry
"ruleId": "secrets"in--jsonand the same id in SARIF and in the terminal. - Silence one line
// prodlint-disable-next-line secrets- Silence a whole file
// prodlint-disable secretsat the top of the file- How it works
- Matches text patterns. Source on GitHub