No hardcoded secrets in frontend code
Why it matters
A hardcoded secret in source code is immediately compromised the moment the repository is cloned, forked, or accidentally made public — and Git history preserves it even after deletion. NIST 800-53 rev5 IA-5 (Authenticator Management) prohibits embedding authenticators in code, and SC-28 requires protection of information at rest including stored credentials. CWE-798 covers this exact failure; OWASP A07 (Identification and Authentication Failures) lists hardcoded credentials as a primary cause of large-scale breaches. A single leaked Stripe live key or database password is sufficient to exfiltrate all user data or drain financial accounts.
Severity rationale
Critical because a hardcoded secret in any committed file immediately grants adversaries full access to whatever service the credential controls, requiring no further exploitation.
Remediation
Remove every literal secret from source files and replace with process.env references. Add .env.local to .gitignore before the first commit; use .env.example with placeholder values as the only committed env template.
// lib/db.ts — BEFORE (wrong)
const client = new Client({ password: 'hunter2' })
// lib/db.ts — AFTER (correct)
const client = new Client({ password: process.env.DB_PASSWORD })
For secrets already in Git history, rotate the credentials immediately — removing the commit does not protect any clone taken before the rewrite. Store live secrets in Vercel Environment Variables, AWS Secrets Manager, or HashiCorp Vault. Run npx secretlint or git-secrets in CI to block future commits.
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the FISMA/FedRAMP Readiness Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- nist:rev5 · IA-5 — Authenticator Management
- nist:rev5 · SC-28 — Protection of Information at Rest
- fedramp:rev5 · IA-5 — FedRAMP IA-5 — no hardcoded credentials
- cwe · CWE-798 — Use of Hard-coded Credentials
- owasp:2021 · A07 — Identification and Authentication Failures
Taxons
History
- 2026-04-18·v1.0.0·Initial import from gov-fisma-fedramp·automated