Toutes les vulnérabilités
CRITICALSecretsexploited in the wild

SECRET-HARDCODED-SOURCE

Secrets · Source code · Hardcoded secrets in source code

Résumé

Hardcoded secrets are API keys, database passwords, OAuth tokens, and private keys written directly as string literals into application source and committed to version control. Because they are plaintext constants, automated scanners (Trufflehog, Gitleaks, GitHub secret scanning) trivially recover them by pattern-matching commit contents against known token formats and high-entropy strings, so a single push to a public host exposes the credential to anyone watching the commit stream within seconds. GitGuardian's State of Secrets Sprawl reported 12.8 million new secrets leaked on public GitHub in 2023, rising about 25% to 23.8 million in 2024, with generic secrets making up 58% of detections. The problem is not limited to public code: GitGuardian found 35% of scanned private repositories also contained plaintext secrets, and AWS IAM keys appeared several times more often in private than public repos. Once committed, a leaked credential can grant direct access to production databases, cloud accounts, and third-party services.

Comment l’éviter dans votre code

  • Load all secrets from environment variables or a secrets manager (Vault, AWS Secrets Manager); never write them as code literals.
  • Enable GitHub push protection and pre-commit scanning (Gitleaks, Trufflehog) to block secrets before they reach the remote.
  • Treat any committed secret as compromised and rotate it immediately, regardless of repo visibility.
  • Add config and key files to .gitignore and review diffs for credentials before every push.
  • Centralize secret issuance so credentials are short-lived and auditable rather than static constants.

Références

Vulnérabilités liées

Tout Secrets →