Hardcoded Secrets

Hardcoded API keys, tokens, private keys and database URLs with credentials (Stripe, AWS, OpenAI, Anthropic, GitHub, Supabase and more)

criticalSecuritysecrets

Why 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

Flaggedlib/stripe.ts
const stripe = new Stripe(
  "sk_live_51abc123def456ghi789jkl"
);
Fixedlib/stripe.ts
const 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 --json and the same id in SARIF and in the terminal.
Silence one line
// prodlint-disable-next-line secrets
Silence a whole file
// prodlint-disable secrets at the top of the file
How it works
Matches text patterns. Source on GitHub