Secrets Hygiene for Vibe Coders
A developer workstation holds production tokens, database passwords, and session cookies, and infostealers target exactly that. A concrete guide to .env, GitHub tokens, browser cookies, local databases, and pre-commit checks.

Table of contents
- Why developer secrets are the target right now
- The five places secrets actually leak
- .env hygiene: never commit, never trust a deleted commit
- Tokens: short-lived and least-scope beats long-lived and broad
- Pre-commit checks: stop the leak at the gate
- Browser cookies and local databases: the overlooked two
- FAQ
- Bottom line
- Sources and further reading
Vibe coding optimizes for speed: describe what you want, let the agent build it, ship. That same speed is what makes secrets hygiene the easiest thing to skip and the most expensive thing to get wrong. A developer workstation holds production database passwords, deployment tokens, and API keys — and, as security researchers keep pointing out, it is usually less monitored than the production servers those secrets unlock. When an infostealer or a poisoned dependency lands on that machine, your secrets are the prize.
This is a concrete, developer-grade guide to keeping secrets where attackers can't trivially grab them: out of your repos, off your environment, and behind pre-commit checks that stop the leak before it happens.
Why developer secrets are the target right now
The scale here isn't theoretical. According to Flashpoint, infostealer malware contributed to the theft of more than 1.8 billion credentials from roughly 5.8 million infected devices — and per stealer-log analysis cited by DeepStrike, stolen passwords and session cookies now appear in around 86% of breaches. Modern infostealers like StealC and the newer VoidStealer family go straight for browsers, cloud secrets, and developer tooling. They harvest session tokens and authentication cookies specifically because those let an attacker resume a logged-in session after MFA has already been satisfied.
Translate that into your daily setup: a single .env file with a live database URL, a GitHub token in your shell config, or your browser's cookie store is exactly the kind of artifact that ends up in a stealer log selling for as little as $5 on a dark-web market. The defense is to assume the workstation can be compromised and minimize what's lootable when it is.
The five places secrets actually leak
| Surface | What lives there | The leak | Fix |
|---|---|---|---|
.env files |
DB URLs, API keys, JWT secrets | Committed to git; left world-readable | .gitignore + secret manager + pre-commit scan |
| GitHub / cloud tokens | PATs, deploy keys, ~/.aws |
Long-lived, broadly scoped, in dotfiles | Short-lived, least-scope, in a credential helper |
| Browser cookies | Session tokens for every web login | Copied wholesale by infostealers | Keep the machine clean; sign out of stale sessions |
| Local databases | Real customer data in dev DBs | Prod data copied to an unguarded laptop DB | Use synthetic/masked data locally |
| Git history | Anything ever committed | Rotating the file doesn't remove the old blob | Rotate the secret + purge history |
The unifying mistake is treating a secret as a value you place somewhere convenient, rather than a liability you minimize, scope, and rotate.
.env hygiene: never commit, never trust a deleted commit
Start with the basics, because they catch the most common leak:
.gitignorethe file before you create it. Add.env,.env.*,*.pem, and*.keyto.gitignorefirst, then create the file. An agent scaffolding a project will happily write a.envand stage everything; the ignore rule is your backstop.- Commit a
.env.examplewith empty values so collaborators (and your agent) know what variables exist without ever seeing the real ones. - Understand that
git rmdoesn't undo a leak. If a secret was ever committed, it lives in history forever and must be treated as compromised — rotate it immediately, then purge the blob withgit filter-repo(or BFG). Deleting the file in a new commit changes nothing for an attacker who has the history. - Prefer a real secret manager for anything sensitive — a cloud secrets manager, Doppler, 1Password's CLI, or your platform's environment-variable store — so the secret is injected at runtime and never sits in a file on disk.
Tokens: short-lived and least-scope beats long-lived and broad
A leaked fine-grained, 7-day GitHub token scoped to one repo is a minor incident. A leaked classic PAT with repo + admin scope and no expiry is a breach. Make the former your default:
- Use fine-grained tokens with the minimum scopes and the shortest expiry you can tolerate; regenerate rather than extend.
- Store git credentials in a credential helper / keychain, not in
~/.netrcor a plaintext~/.gitconfig. - For cloud, prefer short-lived, role-assumed credentials over long-lived
~/.aws/credentialskeys. If you must keep static keys, scope them tightly and rotate on a schedule. - Don't hand your real tokens to an untrusted agent or repo. As we covered in our piece on sandboxing coding agents, inject a scoped, disposable token per task rather than mounting your standing credentials into the agent's environment.
Pre-commit checks: stop the leak at the gate
The best secret leak is the one git refuses to accept. Install a pre-commit secret scanner so a key never reaches a remote in the first place:
pip install pre-commit detect-secrets
detect-secrets scan > .secrets.baseline
# .pre-commit-config.yaml: add gitleaks or detect-secrets hooks
pre-commit install
Tools like gitleaks, detect-secrets, and trufflehog match high-entropy strings and known key formats (AWS keys, GitHub tokens, Stripe keys, private-key headers) and block the commit when they fire. Run the same scanner in CI as a second net — local hooks can be bypassed with --no-verify, so CI enforcement is what makes it non-optional for the team. This pairs naturally with the test gates we recommend everywhere: a commit that introduces a secret should fail just like a commit that breaks a test.
Browser cookies and local databases: the overlooked two
Two surfaces vibe coders rarely think about:
- Browser cookies are bearer tokens. An infostealer that copies your cookie store can replay your authenticated sessions without your password or your MFA. You can't "scope" a cookie — so the defense is keeping the machine clean (don't run untrusted code on the host that holds your real browser profile) and signing out of stale sessions so old tokens are invalid if stolen.
- Don't put real production data in a local dev database. A laptop DB seeded from a prod dump turns every developer machine into a copy of your customer database, with none of the production access controls. Use synthetic or masked data locally; if you must use real data, treat that machine with production-grade care.
FAQ
I already committed a secret — is deleting it enough?
No. Rotate the secret immediately (assume it's compromised), then purge it from git history with git filter-repo or BFG. The old commit is still reachable until you rewrite history.
Are pre-commit hooks enough on their own?
They're the first line, but a developer can bypass them with --no-verify. Run the same scanner in CI so the check is enforced server-side and can't be skipped.
Why do session cookies matter if I have MFA? Because a stolen session cookie represents a session that already passed MFA. Infostealers target cookies precisely to bypass it — which is why keeping the workstation clean matters as much as the password.
Is it safe to give a coding agent my .env?
Only if you trust the agent and the code. For unfamiliar repos, don't load real secrets into the agent's environment; use a scoped throwaway token and a sandbox instead.
Bottom line
Secrets hygiene is unglamorous and it is the highest-ROI security habit a vibe coder has. Keep .env files out of git and out of history, prefer short-lived least-scope tokens over long-lived broad ones, gate commits with a secret scanner backed by CI, keep real data out of local databases, and remember that browser cookies are loot too. Infostealers are industrializing the theft of exactly these artifacts — the developers who minimize, scope, and rotate their secrets are the ones whose compromised laptop is an inconvenience instead of a breach.
Sources and further reading
Sources
- Shattered.io: Infostealers Stole 1.8B Credentials in 2025 (Flashpoint data) shattered.io
- Huntress: From Cookies to Keys — the threat of session hijacking huntress.com
- CSO Online: Chrome ABE bypass — VoidStealer malware steals passwords and cookies csoonline.com
- gitleaks: Protect and discover secrets using gitleaks github.com


