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

  1. 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.
  2. A file still on the host. Visit https://yourapp.com/.env. A 200 with KEY=value lines is a leak. (Some SPAs answer 200 with their homepage HTML — that is not a leak.)
  3. A public .git. https://yourapp.com/.git/HEAD returning ref: refs/heads/… means an attacker can often dump the whole repo, including every historical secret.
  4. Keys baked into the JS bundle. Anything with a NEXT_PUBLIC_, VITE_, or EXPO_PUBLIC_ prefix ships to the browser by design. Putting service_role, Stripe sk_live_, or OpenAI sk- behind those prefixes is a classic vibe-coding footgun.
  5. 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

  1. Logged-out browser: open /.env and /.git/HEAD.
  2. DevTools → Sources: search for sk_live, sk-, sk-ant-, service_role, sb_secret_, AKIA, ghp_, xoxb-.
  3. Confirm every NEXT_PUBLIC_ / VITE_ value is safe to publish.
  4. 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:

  1. LLM provider keys (OpenAI, Anthropic, OpenRouter, Gemini…)
  2. Stripe sk_live_ / rk_live_ (and webhook secrets)
  3. AWS access keys
  4. Supabase service_role / sb_secret_
  5. Database passwords
  6. 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

Want us to look?

Free live-site check · Sample full report · Get a report

The VibePreflight team