Bolt app leaked API key: how to detect, rotate, and fix it
Short Answer
To confirm a bolt app leaked API key, view your live app page source or open the compiled JavaScript file under /assets/ and search for provider prefixes such as sk-, re_, AIza, or whsec_, or run a free perimeter scan on your deployed URL. If any secret string loads in browser DevTools or the Vite client bundle, visitors and automated scrapers can extract and bill against it right away.
Why vibe-coded apps hit this
Bolt.new executes code inside an in-browser WebContainer and commonly scaffolds Vite + React or Next.js frontends where users paste keys straight into .env or component state so a chat demo works immediately. Any variable prefixed with VITE_ or NEXT_PUBLIC_, or any unprefixed string interpolated during a client helper call, is compiled directly into static dist/assets/*.js files served to every visitor.
Where Bolt puts API keys and why they leak into the browser
Bolt stores secrets in the root .env file in the left file tree and in your host environment settings (Netlify Site configuration -> Environment variables or Vercel Project Settings -> Environment Variables). At build time, Vite replaces import.meta.env.VITE_* references with literal strings inside dist/assets/index-*.js.
Prompting Bolt to call an AI or payment API straight from src/components/ or src/hooks/ also embeds secrets in client code even without VITE_.
- Inspect src/lib/ and src/components/ for client SDK calls such as new OpenAI({ apiKey: ... }).
- Check .env and Netlify/Vercel Environment Variables for any secret prefixed with VITE_ or NEXT_PUBLIC_.
How to inspect the built Bolt bundle before rotating
Deleting a secret line in the Bolt editor does NOT un-leak the key: git commits retain previous file versions permanently, and CDN caches continue serving older chunk hashes.
- Open your live Bolt URL, press Ctrl+U, click the /assets/index-*.js link, and search Ctrl+F for "sk-", "sk_live_", "re_", "whsec_", and "AKIA".
- In the Bolt terminal pane, run npm run build && grep -rn "sk-" dist/assets/ to check every output file.
Rotate first, move the call to the server, scrub Git, and rescan
Always revoke the exposed secret inside the provider dashboard BEFORE editing code. Then save a new unprefixed server secret, move SDK calls to a backend function, scrub git commits with git-filter-repo if public, deploy fresh chunks, and rescan.
- Step 1 (Rotate): Revoke the exposed key in OpenAI (platform.openai.com -> API keys), Stripe (Developers -> API keys -> Roll key), or Resend (API Keys -> Revoke).
- Step 2 (Move to server): Create a Supabase Edge Function (supabase/functions/ai-proxy/index.ts) or serverless endpoint (api/generate.ts) reading Deno.env.get(...) or process.env.SECRET_KEY.
- Step 3 (Clean Git & CDN): Scrub public commits with git-filter-repo, redeploy to clear old CDN chunks, and run a free GoVibeSafe scan.
Check it yourself for free
- Open your deployed Bolt URL in Chrome and press Ctrl+U to view the raw HTML source.
- Copy the script tag path starting with /assets/ and open it in a new browser tab.
- Search (Ctrl+F) for prefixes like "sk-", "sk_live_", "re_", or the first 5 characters of your keys.
- Open Bolt terminal and run npm run build followed by a search across dist/assets/.
- Check git commit logs with git log -S "sk-" --oneline to see if older commits still contain the secret.
curl -s https://your-bolt-app.netlify.app/assets/index.js | grep -Eo "(sk-[A-Za-z0-9_-]{12,}|re_[A-Za-z0-9_]{12,})"Searching the built dist/assets/*.js bundle and live /assets/*.js URLs returns zero secret prefixes, and only /api/ or Edge Function server calls communicate with paid providers.
A plain-text sk-proj-, sk_live_, or service_role JWT string appears inside your client JavaScript bundle or in git commit history.
Want GoVibeSafe to check your live bundles, HTTP headers, and database tables automatically?
Run a free scanTraps a simple fix still misses
- Deleting the hardcoded key line from Bolt chat without clicking Revoke in the provider dashboard - the compromised token stays valid until revoked.
- Assuming deleting the file clears the leak - public git commit logs and CDN asset caches retain copies of previously deployed JS files.
- Renaming a VITE_ prefixed secret variable in .env without checking whether an old deployment preview branch still serves the leaked chunk.
Fix it with AI prompts
After revoking your compromised key in the provider dashboard, paste this prompt into Bolt:
Security refactor: remove all client-side API key usage and dangerouslyAllowBrowser calls from src/. Move all third-party secret SDK calls into a server endpoint under api/ (or a Supabase Edge Function) reading unprefixed environment variables on the server. Update the frontend component to fetch("/api/your-endpoint") with no secret keys imported anywhere in client files, and remove any secret variables prefixed with VITE_ or NEXT_PUBLIC_.Automate this check on your live app
After redeploying your clean Bolt build, verify that zero client bundles or cached chunks still leak tokens.
Read-only scan. Zero code or repository access required. We never store database rows or secret keys.
Frequently asked questions
Practical answers, edge cases, and troubleshooting for this fix.
No. Deleting code does not revoke a credential, and previous commits in git history as well as cached CDN bundles can still expose the old key string. Always revoke the key at the provider first, then deploy a clean server-side build.
In Bolt, any variable prefixed with VITE_ or NEXT_PUBLIC_ or referenced inside src/ client components is compiled into public browser JavaScript. Secrets are safe only when stored without client prefixes in server environment variables and read exclusively by backend API routes or Supabase Edge Functions.
Vite bundles every imported module, hook, helper, and .env VITE_ variable reachable from main.tsx. Check src/lib/, src/utils/, custom hooks, and cached dist/ artifacts before building again.
Review token counts, IP activity, and spend graphs starting from the timestamp of your earliest git commit or deployment containing the key, and set hard monthly spending limits before issuing a replacement key.
Related builder guides
Official Documentation & Standards
Ready to test your live app after applying these fixes?
Paste your URL in the GoVibeSafe homepage scanner for an instant read-only check.
Author
Written by GoVibeSafe. GoVibeSafe is a read-only perimeter scanner that checks live web apps for leaked API keys, open Supabase tables, missing HTTP security headers, clickjacking exposure, HTTPS settings, broken links, and indexing issues.