Guide · November 5, 2026
Exposed .env in a vibe-coded app: find it and rotate
AI coding agents move fast. They also love dumping secrets into .env, committing it, baking NEXT_PUBLIC_ / VITE_ copies into the frontend, or leaving /.env and /.git reachable on the live host. This page is the check we run on every free scan — and the rotation order that keeps the expensive keys from turning into a bill overnight.
Shortcut: run the free live-site check on your URL. It GETs /.env and /.git, searches public JS for secret prefixes, and flags Supabase tables readable while logged out.
Where secrets actually leak
- A committed
.env. Even if you delete it later, it is in git history. Scrubbing history does not un-leak a key that was ever pushed. - A file still on the host. Visit
https://yourapp.com/.env. A 200 withKEY=valuelines is a leak. (Some SPAs answer 200 with their homepage HTML — that is not a leak.) - A public
.git.https://yourapp.com/.git/HEADreturningref: refs/heads/…means an attacker can often dump the whole repo, including every historical secret. - Keys baked into the JS bundle. Anything with a
NEXT_PUBLIC_,VITE_, orEXPO_PUBLIC_prefix ships to the browser by design. Puttingservice_role, Stripesk_live_, or OpenAIsk-behind those prefixes is a classic vibe-coding footgun. - Agent / MCP configs. Cursor, Claude Code, and Codex configs under
~/.cursor,~/.claude, or project hooks can hold tokens. A compromised dependency (see LiteLLM 1.107.0) or a desktop app that rewrites agent configs can steal them without touching your repo.
The 2-minute check
- Logged-out browser: open
/.envand/.git/HEAD. - DevTools → Sources: search for
sk_live,sk-,sk-ant-,service_role,sb_secret_,AKIA,ghp_,xoxb-. - Confirm every
NEXT_PUBLIC_/VITE_value is safe to publish. - If a key was ever in git: treat it as burned. Rotate even if the file is gone now.
Rotate in this order
Stolen LLM and cloud keys turn into invoices within hours. Rotate the expensive ones first:
- LLM provider keys (OpenAI, Anthropic, OpenRouter, Gemini…)
- Stripe
sk_live_/rk_live_(and webhook secrets) - AWS access keys
- Supabase
service_role/sb_secret_ - Database passwords
- Everything else (email, auth secrets, registry tokens, GitHub tokens)
For each key: add the new one at the provider → update the env and redeploy → revoke the old one. Containers read env at startup, so nothing changes until you redeploy. If a key is actively being abused, revoke first and accept a short outage.
More detail (including Railway-specific steps from the Oct 2026 breach): Railway breach key-rotation guide.
Stop the next leak
- Keep real secrets out of the agent’s working tree. Prefer short-lived / injected secrets over a laptop
.envfull ofsk_live_. - Add a pre-commit / agent hook that blocks reading or editing
.env, private keys, andsecrets/. Our free guardrail pack ships starter rules for Cursor and Claude Code. - Never put secret values behind
NEXT_PUBLIC_/VITE_prefixes. - Block
/.env,/.git, and backup files at the host / CDN (_headers, nginx, Cloudflare WAF).
Want us to look?
Free live-site check · Sample full report · Get a report
The VibePreflight team