Host breached: which keys to rotate, and in what order
Updated 24 October 2026
Your hosting platform announced a security incident, or you found your .env somewhere it shouldn't be. Now there are 15 secrets in your environment variables, and you don't know where to start. This guide gives you a priority order, the reason for each step, and how to rotate each key without breaking your app.
Short version: rotate the keys that can move money first, then the keys that open your database, then the secrets that let someone pretend to be your users, then paid AI keys, then cloud, repo and email keys. Then redeploy, check that the old keys fail, and read your usage and billing logs.
Check your own app for this, free.
Paste your live URL. ShipCheck looks for leaked API keys in your page and JavaScript, exposed files like /.env and /.git, missing security headers, SSL certificate problems, domain expiry (custom domains only) and what Google sees without running JavaScript. You'll see your score without signing up.
Step 0: lock the account before you rotate anything
If someone still has access to your hosting account, they can read your new keys as soon as you save them. So first:
- Change the password on your host account (and the email account that can reset it) and turn on multi-factor authentication.
- Revoke access tokens and integrations you don't recognise, and remove team members who shouldn't be there.
- Look at the activity or audit log and recent deployments for anything you didn't do.
For context: in Vercel's April 2026 incident, the attacker could decrypt environment variables that were not marked as sensitive. Vercel told affected customers to rotate those, review the activity log and recent deployments, and use sensitive environment variables from then on. Read the Vercel April 2026 security incident bulletin and sensitive environment variables. Other hosts have their own advice, but the order below works for any of them.
The rotation order (and why)
The order is about damage per minute. A key moves up the list if an attacker can turn it into money or permanent harm quickly, and if the damage is hard to undo.
| Priority | Keys | Why this position |
|---|---|---|
| 1. Money | Stripe sk_live_ and rk_live_, Stripe webhook secrets (whsec_), other payment provider secrets | Refunds, payouts and fake "payment succeeded" events cost real money right away, and you may not get it back. |
| 2. Database and admin | Supabase service_role or sb_secret_ key, DATABASE_URL or DB password, Firebase admin credentials | These skip Row Level Security. Someone can copy, change or delete every row. You can't un-leak customer data. |
| 3. Auth and sessions | Supabase JWT secret, NEXTAUTH_SECRET or AUTH_SECRET, OAuth client secrets, other signing secrets | Anyone who can sign tokens can log in as any user, including you as admin. |
| 4. Paid AI and APIs | OpenAI, Anthropic, OpenRouter, Groq, Replicate and other usage-billed keys | They run up a bill fast, but spend limits cap the damage, and the provider may help with fraud. |
| 5. Cloud, repo and email | AWS access keys, GitHub tokens and deploy keys, Resend, SendGrid or Postmark keys, Slack webhooks, analytics tokens | Serious, but usually slower to exploit or narrower in scope. Exception: a broad AWS admin key or a GitHub token with write access to your repo is as bad as priority 1, so move it up. |
If you have more than one project on the same host, rotate the money and database keys for all of them before moving on to step 3.
How to rotate each key without breaking your app
Each key follows the same loop: create a new key → put it in your host's environment variables → redeploy → revoke the old key → check that the old key fails. Normally you keep the old key working until the redeploy is done (that's what Vercel's rotating environment variables guide recommends). In a breach, keep that overlap as short as you can. If you can see the key being misused, revoke it right away and accept a few minutes of errors.
1. Stripe secret keys and webhook secrets
For which Stripe keys can go in a frontend, and what to do if sk_ or rk_ leaked there, see Stripe publishable vs secret key.
- Secret or restricted key: on the Stripe API keys page, open the key's menu and choose Rotate key. You pick when the old key expires: Now, or later, up to 7 days. In a breach, choose Now or an hour at most. Stripe also suggests using restricted keys (
rk_) with only the permissions you need instead of a full secret key. Docs: docs.stripe.com/keys. - Webhook signing secret: in Workbench → Webhooks, open each endpoint and choose Roll secret. You can expire the old secret right away or keep it for up to 24 hours. A leaked
whsec_lets someone send fake events your app trusts, like "checkout completed", which can unlock paid features for free. Docs: docs.stripe.com/webhooks. - Then check Payments, Refunds, Payouts and payout bank details for anything you didn't do. Each key has View request logs in its menu.
2. Supabase secret key, service_role and database password
- New-style secret key (
sb_secret_): create a new secret key under Settings → API Keys, swap it in everywhere, confirm nothing still uses the old one, then delete the old key. - Legacy
service_rolekey: replace it with a newsb_secret_key, then deactivate the legacy keys in the same section. Supabase notes that deactivating can be undone if you find a component you missed. Supabase is deprecating the legacyanonandservice_rolekeys by the end of 2026 anyway. Docs: Supabase API keys. - Database password: if your
DATABASE_URL(thepostgres://user:password@…string) was in the breached environment, reset the database password in your provider's database settings and update every place that uses the URL. Anyone with that string can connect straight to Postgres and skip your API and RLS completely.
3. Auth and session secrets
- Supabase JWT secret: if you're still on the legacy JWT secret, rotating it signs every user out and also changes the legacy
anonandservice_rolekeys. The newer JWT signing keys let you rotate first and revoke the old key later. Supabase says that during an active security incident you may want to revoke the legacy JWT secret straight away. Docs: Supabase JWT signing keys. - NextAuth / Auth.js secret (
NEXTAUTH_SECRETorAUTH_SECRET): set a new random value (for exampleopenssl rand -base64 32) and redeploy. Existing sessions stop working, so everyone has to sign in again. That's what you want if the old secret could be used to forge sessions. - OAuth client secrets (Google, GitHub and other "Sign in with" providers): create a new client secret in the provider's developer console, update your env var, redeploy, then delete the old secret.
- Any other signing secrets you own, like cookie, CSRF or HMAC secrets: replace them the same way.
4. Paid AI and API keys
Delete or revoke the key in the provider's dashboard, create a new one, and put a spend limit on it. OpenAI's advice for an exposed key is to delete it, check usage for unexpected activity, and contact support (OpenAI API key safety). For an OpenAI key already in a frontend bundle, see your OpenAI API key is in the frontend. For an Anthropic (Claude) key already in a frontend bundle, see your Anthropic API key is in the frontend. For the provider-by-provider steps and how to check a leak, see is it safe to put an API key in the frontend? We won't repeat them all here.
5. Cloud, repo and email keys
- AWS access keys: create a second access key, switch to it, then deactivate and delete the old one. Check CloudTrail and Billing for unexpected regions, instances or IAM users. Docs: updating IAM access keys.
- GitHub: revoke personal access tokens, deploy keys and any GitHub App private keys that were stored with your host, then check your account's security log. Docs: managing personal access tokens and token revocation. For a token already in a frontend bundle, see your GitHub token is in the frontend.
- Email (Resend, SendGrid, Postmark, Mailgun): delete the key and create a new one. A leaked email key lets someone send phishing from your verified domain, which hurts your deliverability for months.
- Everything else: Slack webhooks, analytics and error-tracker tokens, cron or deploy-hook URLs. These are low risk, but they're quick to replace while you're here.
Redeploy, or your app keeps using the old key
Changing an environment variable in your host's dashboard doesn't change the deployment that's already running. On Vercel, a new value only takes effect in a new deployment, so redeploy production (and any preview deployments that use the secret). Netlify and most other hosts work the same way. Frameworks also bake public variables (NEXT_PUBLIC_, VITE_) into the JavaScript at build time, so those need a fresh build too. Redeploy before you revoke the old key, or your app breaks in between.
Check that the old keys really fail
Don't assume a revoke worked. Try each old key once from your own terminal. You should get a 401 or an authentication error:
# Stripe: expect 401
curl -s -o /dev/null -w "%{http_code}\n" https://api.stripe.com/v1/balance -u OLD_SK_KEY:
# Supabase secret key: expect 401
curl -s -o /dev/null -w "%{http_code}\n" "https://<project-ref>.supabase.co/rest/v1/" -H "apikey: OLD_KEY"
# OpenAI: expect 401
curl -s -o /dev/null -w "%{http_code}\n" https://api.openai.com/v1/models -H "Authorization: Bearer OLD_KEY"
# GitHub token: expect 401
curl -s -o /dev/null -w "%{http_code}\n" https://api.github.com/user -H "Authorization: Bearer OLD_TOKEN"
# AWS: expect an InvalidClientTokenId error
AWS_ACCESS_KEY_ID=OLD_ID AWS_SECRET_ACCESS_KEY=OLD_SECRET aws sts get-caller-identityThen check that your app still works with the new keys: sign in, make a test payment in test mode or a small real one, and call your AI feature.
Read the usage and billing logs
Rotating stops new damage. The logs tell you whether there already was some. Look back to the start of the incident window your host published, or to the day the .env could first have leaked:
- Stripe: request logs for each key, plus refunds, payouts, new connected accounts and changes to payout bank details.
- Supabase: API and database logs for large reads or deletes, and new users in Auth you don't recognise.
- AI providers: the usage page, by day and by key. Report anything clearly fraudulent to support with dates and amounts.
- AWS: CloudTrail and the Billing dashboard. GitHub: the security log and new deploy keys or webhooks. Email: the sending activity.
- Your host: the activity log, deployments you didn't make, and new domains or env vars.
If customer personal data may have been read, check whether your local privacy law or your terms require you to tell customers.
Public keys don't need urgent rotation
Some keys were never secret, so a breach doesn't change anything for them:
- Supabase anon or publishable key: it's already in every visitor's browser by design. Supabase says it's safe to expose, because it can only reach what Row Level Security allows. If your RLS is weak, rotating this key won't help, since the new one is just as public. Fix the policies instead. See is the Supabase anon key safe? and how to test RLS. (If you rotate the legacy JWT secret, the legacy anon key changes too, so update it in your frontend then.)
- Stripe publishable key (
pk_): Stripe lists it as safe to expose. It can create tokens and PaymentMethods, but it can't create charges or read your account data. Stripe doesn't even let you expire one. - Firebase web config, Google Maps browser keys limited to your domain, public analytics IDs: same idea. Their security comes from rules and restrictions, not from being hidden.
So spend the first hour on the secret keys. If a value has a public prefix (NEXT_PUBLIC_, VITE_) and is meant to be public, it can wait. If a secret was stored under a public prefix, it was leaked long before the breach. Rotate it and move it server-side.
Checklist
- Secure the host account: password, MFA, tokens, team members, activity log.
- Make a list of every secret in the breached environment, for every project.
- Rotate Stripe secret and restricted keys, and roll every webhook secret.
- Rotate the Supabase secret or service_role key and the database password.
- Rotate the JWT secret or signing key, the NextAuth/Auth.js secret and OAuth client secrets.
- Revoke AI and API keys, and put spend limits on the new ones.
- Rotate AWS, GitHub, email and other keys.
- Save the new values as sensitive or encrypted env vars, then redeploy every affected project and preview.
- Check that each old key returns 401 and that your app still works.
- Read the Stripe, Supabase, AI, cloud and host logs back to the start of the incident.
Where ShipCheck fits (and where it doesn't)
ShipCheck can't see your host's environment variables, and it can't tell you whether a key was taken in a breach. Only your host and the providers' logs can tell you that. What it checks is the public side of your live app: whether known secret key formats (Stripe, OpenAI, Anthropic, Supabase secret and service_role keys, AWS, GitHub, email providers and more) show up in your page, its JavaScript bundles or public source maps, and whether /.env files or /.git are being served publicly. That's useful right after a rotation, when it's easy to paste a new secret into the wrong (public) variable. Paid plans re-run these checks automatically: weekly on Solo ($12/mo) or daily on Builder ($29/mo).
Related: API keys in the frontend and what to do if one leaked · Lovable security checklist.
FAQ
Which API keys should I rotate first after a breach?
Start with keys that can move money: Stripe secret and restricted keys and your Stripe webhook signing secrets. Next, database and admin keys (Supabase service_role or secret key, the database password in DATABASE_URL). Then auth and session secrets (JWT secret, NextAuth/Auth.js secret, OAuth client secrets). Then paid AI and API keys, and finally cloud, GitHub and email keys. Move a broad AWS or GitHub write token to the top if you have one.
How do I rotate keys after a Vercel security incident?
Secure your Vercel account first (password, MFA, tokens, activity log). Then, for each secret: create a new key at the provider, update the environment variable in Vercel (marking it sensitive), redeploy every project and preview that uses it, revoke the old key, and check that the old key now fails. Vercel's own rotation guide recommends updating and redeploying before invalidating the old credential. In an active breach, keep that window as short as possible.
Do I need to redeploy after changing environment variables?
Yes. On Vercel, changed environment variables only apply to new deployments, and most hosts work the same way. Public variables like NEXT_PUBLIC_ or VITE_ are also built into your JavaScript, so they need a new build. Redeploy before you revoke the old key, or your app breaks in between.
Do I need to rotate my Supabase anon key or Stripe publishable key?
Not urgently. Both are designed to be public and are already in every visitor's browser. The Supabase anon or publishable key only reaches what Row Level Security allows, and the Stripe publishable key can't create charges or read account data. Rotating them doesn't make you safer. Fixing RLS does. The exception: rotating Supabase's legacy JWT secret also changes the legacy anon key, so update it in your frontend then.
How do I know if a leaked key was actually used?
Check the provider logs back to the start of the incident: Stripe request logs, refunds and payouts; Supabase API and database logs; your AI provider's usage page; AWS CloudTrail and billing; GitHub's security log; your email provider's sending activity; and your host's activity log. Then test that each old key now returns 401.
Can ShipCheck tell me which of my keys were exposed in a host breach?
No. ShipCheck can't see your host's environment variables or breach data. It checks the public side of your live site: known secret key formats in your HTML, JavaScript bundles and public source maps, and publicly served /.env or /.git files. That makes it a good check after rotating, to confirm the new keys didn't end up in the frontend.
Run the same checks on your app.
A free scan takes under a minute. No card, and no sign-up to see your score and the list of issues.