Bolt.new Exposed API Keys: How They Leak and How to Check Yours

Check your own app — free, in about a minute.

This article is about secrets leaking into public code — and the mini-scan hunts the same exposure on YOUR live app: AWS, Stripe, GitHub and Slack keys sitting in client code, an exposed .env or .git, and open backend rules. You get a score and the finding titles — no account, no card.

Run the free mini-scan →

Bolt.new Exposed API Keys: How They Leak and How to Check Yours

The most common security incident in Bolt.new apps isn't a sophisticated attack — it's an API key sitting in public, readable by anyone who opens the browser's DevTools. Stripe secret keys, OpenAI keys, Supabase service role keys, database passwords. They leak through a handful of predictable paths, and every one of them is checkable in minutes.

This article covers how API keys actually leak in Bolt-built apps, how to check each path, and how to fix what you find.

How the Leak Happens

The root cause is one rule: anything the browser needs, the browser gets — in plain text. When you or the AI reference a key from frontend code, the build tool bakes the literal value into your shipped JavaScript bundle. There is no vault in the browser. There is no "hidden" variable. If your frontend code touches it, it's published.

Bolt's workflow makes this easy to do by accident. You paste a key into the environment variable editor, ask the AI to "wire up payments" or "connect the database," and the AI takes the path of least resistance: importing the key directly into the component that needs it. It works. The demo succeeds. And the key ships to every visitor.

Here are the specific paths, in the order they show up most often.

Leak Path 1: Keys Baked Into the JS Bundle

This is the big one. In a Vite-based Bolt app, any environment variable referenced from client-side code ends up as a literal string in the production bundle. A Stripe secret key, an OpenAI API key, a Supabase service role key — if the frontend imports it, curl can read it.

Check it:

# Find your JS bundles
curl -s https://your-app.com | grep -o 'src="[^"]*\.js"' | head -5

# Download the main bundle and search for key patterns
curl -s https://your-app.com/assets/index-abc123.js \
  | grep -oiE 'sk_live_[a-z0-9]+|sk-[a-zA-Z0-9]{20,}|AIza[0-9A-Za-z_-]{35}|AKIA[0-9A-Z]{16}|xox[bap]-[a-zA-Z0-9-]+' \
  | sort -u | head

Also search for the generic markers: api_key, secret, bearer, service_role. If you see a real key — not a placeholder, not a publishable key — it is public and must be rotated.

The rule to internalize: keys that start with sk_, contain secret, or touch money or data must live in server-side code only. Frontend code may use publishable keys (pk_live_, pk_test_) — those are designed to be public. Everything else stays behind a server function.

Fix: Move the key into a server-side route handler (or a Supabase Edge Function) and have the frontend call that endpoint. The browser talks to your endpoint; your endpoint talks to the third party with the secret. The secret never crosses into the bundle.

Leak Path 2: Keys Committed to Git History

Bolt exports to GitHub when you deploy elsewhere, and .env files sometimes ride along. Worse: even if you delete the file later, git history keeps the secret forever. Automated scanners watch public GitHub commits in real time — a key committed to a public repo is typically scraped within minutes.

Check it:

git log -p --all -- .env .env.local .env.production | grep -iE 'key|secret|token|password' | head -20

Also check for keys pasted directly into source files:

git log -p --all | grep -oiE 'sk_live_[a-z0-9]+|service_role[^"]*' | head -10

Fix: If anything was ever committed, rotate it — don't just delete the file. Then add .env* to .gitignore (Bolt templates usually include this, but verify) and consider purging the history with git filter-repo if the repo is private and the key touched sensitive systems. For a public repo, assume the key is known.

Leak Path 3: The Supabase Service Role Key

Bolt apps very often use Supabase, and the service role key is the most dangerous key in the stack: it bypasses every Row Level Security policy. One grep tells you whether it's loose:

grep -ri "service_role" . --include="*.ts" --include="*.tsx" --include="*.js"

Acceptable locations: Edge Functions, server route handlers, deployment env vars. Unacceptable: any file the browser downloads. If it ever appeared in frontend code or a committed file, rotate it in Supabase → Settings → API immediately.

The public anon key is supposed to be in your frontend — that's by design. It only becomes a problem when Row Level Security is off, which turns the anon key into a master key. Verify RLS is enabled on every table and policies scope access to auth.uid().

Leak Path 4: Keys in Server Functions Without Auth

Even when a key lives server-side, the function that uses it can leak its power. If Bolt's AI built an API route like /api/send-email or /api/create-checkout with no authentication check, anyone can call it — and spend your money, spam from your account, or read whatever the key unlocks.

Check it — logged out, from the terminal:

curl -s https://your-app.com/api/send-email -X POST \
  -H "Content-Type: application/json" -d '{}' | head -c 300

A 401 is correct. Anything else means the endpoint is callable by strangers.

Leak Path 5: Exposed /.env on the Deployed Site

If the deployment ever served the project root, the .env file itself may be fetchable. This is one of the first paths automated scanners probe:

curl -s -o /dev/null -w "%{http_code}\n" https://your-app.com/.env

A 200 here with real content is an emergency: rotate every secret the file contained, remove the file from the web root, and block the path at your edge.

The 10-Minute API Key Audit

Run these in order, before every deploy:

  1. Bundle grep — download the production JS, search for key patterns (Path 1)
  2. Git history grep — check every commit for secrets (Path 2)
  3. service_role grep — confirm it's server-side only (Path 3)
  4. Logged-out curl of every API route the app uses (Path 4)
  5. /.env probe — confirm it 404s (Path 5)
  6. Rotate anything found — rotation, not deletion, is the fix

Then set the guardrails so the AI can't reintroduce the problem: keep a written rule in your project ("never reference secrets from frontend code"), review every diff the AI produces before deploying, and re-run this audit after any AI-assisted change that touches integrations.

Don't Want to Do It by Hand?

The bundle grep takes ten minutes once you know the paths — but it's easy to miss the API route you forgot existed or the key you assumed was server-side. PreShipIt probes your app the way an attacker would: from the outside, with no login and no access to your source code. Paste your URL, attest that you own the app, and for $29 (one time) you get a plain-English prioritized report of what's actually exposed — including keys and files strangers can reach.

PreShipIt runs an outside-in, unauthenticated scan of the single host you submit. It doesn't test anything behind a login, doesn't review your source code, and doesn't guarantee your app is secure — it shows you what an unauthenticated visitor can see and reach, so you can fix it first.

Get your pre-ship inspection at preshipit.com

The PreShipIt Brief — a short weekly email for people shipping vibe-coded apps: the week's important vulnerabilities and launch-safety checks, in plain English.

New and free. Double opt-in: we email you a confirmation link before anything else arrives. Unsubscribe any time.

Check your own app — free, in about a minute.

This article is about secrets leaking into public code — and the mini-scan hunts the same exposure on YOUR live app: AWS, Stripe, GitHub and Slack keys sitting in client code, an exposed .env or .git, and open backend rules. You get a score and the finding titles — no account, no card.

Run the free mini-scan →

← Back home · Run a free mini-scan · Scan my app — $29 · See a sample report