← All advisories

VV-004highSecret exposure2026-08

Secrets leaked via NEXT_PUBLIC_ (or VITE_) environment variables

Prefixing a variable with NEXT_PUBLIC_ inlines it into the JavaScript every visitor downloads. AI tools often “fix” a missing-env error this way.

01.

What it is

Any NEXT_PUBLIC_ variable is inlined at build time by design. A common quick fix, renaming a secret with the prefix so a client component can read it, publishes the secret.

In the 30,998-app scan, 1,332 apps had something key-shaped in their JavaScript; 52 were dangerous keys such as OpenAI, AWS, Anthropic, a Stripe secret key or a Supabase service_role. Escape’s report also cites a write-up showing API keys routinely leaked in Lovable deployments.

02.

How to check

  1. grep your env files and code for NEXT_PUBLIC_ / VITE_ variables holding words like SECRET, KEY, TOKEN.
  2. Search the deployed bundle for prefixes like sk_live_, sk-, AKIA.
03.

How to fix

  1. Rotate any exposed key at the provider first.
  2. Call the third-party API from a server route / Edge Function and keep the key server-side.
# Find suspicious public env vars in your repo
grep -rnE "(NEXT_PUBLIC|VITE)_[A-Z_]*(SECRET|KEY|TOKEN)" --include=*.{js,ts,tsx,env} .

# Search a downloaded production bundle for common secret prefixes
grep -oE "(sk_live_[A-Za-z0-9]+|sk-[A-Za-z0-9-]{20,}|AKIA[0-9A-Z]{16})" dist/**/*.js
04.

Sources

More advisories for this tool
The weekly email

One email a week. Only what changed.

Every new security hole in AI coding tools, MCP servers, app builders and the stacks they generate (Next.js, Supabase, Node, PHP), each with how to check your app and the fix. No roundups of things you already read.

Free, one email a week. Read the latest issue first if you like. One-click unsubscribe in every email. We never sell or share addresses.