---

The mistakes that recur

Most secret leaks are not exotic attacks; they are repeatable habits. The same four mistakes show up team after team, and a scanner like EnvLens surfaces all of them in one pass.

Mistake 1 — committing .env to git

The classic. A .env with live keys gets committed "just once," then lives in history forever. The fix is environmental: .gitignore the file, inject at runtime, and never let the key touch the repo. Rotate anything that was committed.

Mistake 2 — pasting secrets into chat or tickets

"Here's the key so you can debug" lands credentials in searchable, exportable logs. Use a secret manager share link or a short-lived value instead. Assume anything pasted is archived and scanned.

Mistake 3 — shipping real-looking demo and seed files

Seed scripts and .env.sample files often contain keys that look live. Reviewers skip them as "just examples," but scanners treat them as real. Keep samples obviously fake (e.g., sk_test_xxxx), never credential-shaped.

Mistake 4 — long-lived keys with no rotation

A key created once and never rotated is a permanent exposure window. Short-lived, automatically rotated credentials shrink the blast radius so a leak matters less. Pair rotation with detection so leaks are caught fast.

Closing the loop

Scan, rotate, move to a manager, and add pre-commit scanning. The goal is not a single clean scan but a habit where secrets never reach source in the first place.

Authoritative references

  • OWASP Secrets Management Cheat Sheet: https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html
  • CWE-798 (Hard-coded credentials): https://cwe.mitre.org/data/definitions/798.html
  • CWE-259 (Use of hard-coded password): https://cwe.mitre.org/data/definitions/259.html