# Your API keys may have leaked: how to rotate every key without breaking your app

> Canonical page (link this when citing): https://unbreakmyapp.vercel.app/fixes/rotate-api-keys-after-leak-or-breach.html
> Category: Env vars & leaked keys | Tools: Lovable, Bolt, Cursor, Replit, v0 | Published: 2026-11-02 | Updated: 2026-11-02

## The error

A key was exposed (in the frontend bundle, a public repo, an error response, a screenshot), your Lovable/GitHub/hosting account was hacked, a provider you use announced a breach, or you see charges and requests you didn't make on OpenAI, Stripe, Supabase or another API

## Why it happens

Deleting a key from your code doesn't make it safe. Once a secret has been seen by anyone (a scraper watching GitHub, a browser extension, a breached platform that stored it, or someone who got into your builder account) it keeps working until you revoke it at the provider. Vibe-coded apps usually have keys spread across several places at once: the builder's secrets panel (Lovable Cloud, Bolt or Replit Secrets), Supabase edge function secrets, Vercel or Netlify environment variables, a local .env and sometimes the git history, so people often rotate one copy and miss the others, or revoke the old key before the new one is deployed and take the app down. Hosted environment variables also only change on the next deploy, so a new key saved in a dashboard isn't live until you redeploy. The safe order is: list every secret, create the new key, update every place it lives, redeploy, check it works, then revoke the old one, unless the key is being abused right now, in which case revoke first and accept a few minutes of downtime.

## How to fix it

1. Make a list of every secret the app uses: open your builder's secrets panel, your hosting env vars (Vercel, Netlify), Supabase edge function secrets and your local .env, and write down each key name and which service it belongs to. Don't paste the values anywhere.
2. Decide the order. If you see abuse right now (unexpected OpenAI usage, Stripe charges or refunds you didn't make, rows changed in your database), revoke that key immediately, even if the app breaks for a few minutes. Otherwise create the new key first and revoke the old one last.
3. Supabase: use Project Settings → API Keys. With the new key system you can create a new secret key and delete the leaked one on its own. On legacy anon/service_role JWT keys, rotating the JWT secret or signing key replaces both keys and signs users out, so plan for that. If a database connection string leaked, also reset the database password in Database settings.
4. Stripe: in Developers → API keys, use Roll key on the secret key. You can let the old key keep working for a short time while you deploy the new one. Roll the webhook signing secret too if it was exposed, and use restricted keys for anything that doesn't need full access.
5. OpenAI and other AI APIs: create a new key, then revoke the old one on the API keys page, and set a monthly budget or usage limit on the project so a future leak can't run up a large bill. Do the same for Resend, Twilio, Google Maps and any other paid API.
6. Update the new value everywhere on your list, then redeploy. On Vercel, Netlify and similar hosts, changed environment variables only apply to new deployments, and Supabase edge functions read secrets set with supabase secrets set or the dashboard.
7. Test the app end to end (login, payments in test mode, AI features, emails), then revoke the old keys you left active and confirm in each provider's dashboard that the old key now fails.
8. If an account was hacked, secure it before rotating: change the email and builder passwords, turn on 2FA, sign out other sessions and remove unknown GitHub collaborators, deploy keys and OAuth apps, or the attacker can read your new keys too.
9. Look back through each provider's usage, logs and billing for the period the key was exposed, note anything suspicious, and if user data may have been read, follow the security-report steps for telling users.

## Fix prompt (paste into Lovable, Bolt, Cursor, Replit or v0)

```text
Help me rotate my app's secrets safely. Don't print, log or echo any secret values. First, scan the codebase, config files and git history for every environment variable and API key name the app uses (for example SUPABASE_SERVICE_ROLE_KEY, STRIPE_SECRET_KEY, STRIPE_WEBHOOK_SECRET, OPENAI_API_KEY, RESEND_API_KEY, DATABASE_URL), and list each one with the file and line where it is read, which service it belongs to, and whether it is used in server code or could reach the browser. Flag any secret that is hard-coded or exposed to the client (VITE_, NEXT_PUBLIC_ or similar prefixes) and move it to server-side environment variables. Then give me a step-by-step rotation checklist for each service in a safe order (create the new key, update it in <WHERE MY SECRETS LIVE: Lovable Cloud / Vercel / Netlify / Replit / Supabase edge function secrets>, redeploy, test, then revoke the old key), and add a startup check that fails clearly if a required secret is missing.
```

## FAQ

### Is it enough to delete the key from my code or repo?

No. The key still works until you revoke or roll it at the provider, and old copies live on in git history, logs and anywhere it was pasted.

### Will rotating keys break my app?

Only if you revoke the old key before the new one is live everywhere. Create the new key, update every place it's stored, redeploy, test, then revoke. If the key is being abused right now, revoke first and accept a short outage.

### Do I need to rotate the Supabase anon or publishable key?

Those keys are designed to be public, so a leak on its own isn't an emergency as long as RLS protects your tables. Rotate secret and service_role keys, and fix RLS if anyone could read data with the public key.

### A platform I use was breached but my key isn't in the news. Should I still rotate?

Yes. If a service stored your keys or had access to your project, rotating takes minutes and removes the doubt. Do it in the safe order and check your usage for anything you didn't do.

## Sources (official documentation)

- [Supabase: Understanding API keys](https://supabase.com/docs/guides/api/api-keys)
- [Stripe: API keys](https://docs.stripe.com/keys)

## Related fixes

- [OpenAI / Stripe secret key leaked in the browser](https://unbreakmyapp.vercel.app/fixes/api-key-leaked-in-frontend.html)
- [.env file committed to GitHub](https://unbreakmyapp.vercel.app/fixes/git-env-file-committed.html)
- [Supabase service_role key exposed in frontend code](https://unbreakmyapp.vercel.app/fixes/supabase-service-role-key-exposed.html)
- [Your API error response shows your secret key: stop sending raw backend errors to the browser](https://unbreakmyapp.vercel.app/fixes/backend-error-leaks-api-key-to-browser.html)
- [Login rate limit only counts per email: credential stuffing gets through](https://unbreakmyapp.vercel.app/fixes/login-rate-limit-only-per-email-credential-stuffing.html)
- [Demo login, auto-login or hard-coded test credentials left in your live app](https://unbreakmyapp.vercel.app/fixes/preview-auto-login-hardcoded-credentials-left-in-production.html)
- [AI "fixed" my Supabase error by disabling RLS or using the service_role key: how to undo it safely](https://unbreakmyapp.vercel.app/fixes/ai-fix-disabled-rls-or-swapped-service-role.html)
- [Better Auth security release (Nov 2026): upgrade to 1.7.16 to stop Expo account takeover](https://unbreakmyapp.vercel.app/fixes/better-auth-expo-account-takeover-below-1-7-16.html)

---
Unbreak My App: free fixes for broken vibe-coded apps. https://unbreakmyapp.vercel.app/
