# My Stripe key leaked. What do I do?

**Short answer:** Roll the key in the Stripe Dashboard's API keys page and set the old key to expire now (not in 7 days). Update `STRIPE_SECRET_KEY` on your server, then review request logs for activity you didn't make. A live secret key can create charges and refunds and read customer data. Publishable `pk_` keys are meant to be public and don't need rotating.

*Last updated 2026-11-25 · Reviewed by ProofForge*

## Is it this key?

**Format:** Secret `sk_live_` / `sk_test_`, restricted `rk_live_`, publishable `pk_live_` (public by design)

**Blast radius:** A live secret key has full API access: charges, refunds, customer and payment data, and account settings the API exposes. A restricted key is limited to its permissions.

## The first 10 minutes

| When | Do | How |
|---|---|---|
| 0–2 min | Roll | Dashboard → Developers → API keys → roll the secret key with immediate expiry. |
| 2–4 min | Replace | Set the new key on your server only. Redeploy. Prefer a restricted `rk_` key with minimum permissions. |
| 4–7 min | Check activity | Review request logs for unknown IPs, and check recent refunds, payouts, and new connected accounts or webhooks. |
| 7–10 min | Close the hole | Remove the key from code, history and frontend bundles. Contact Stripe support if you see misuse. |

## Stop the next leak

- Keep the key in a server-side env var. Never use a `VITE_`, `NEXT_PUBLIC_` or `EXPO_PUBLIC_` variable or hard-code it in frontend code.
- Call the provider from your backend or an edge function, and add `.env*` to `.gitignore`.
- Re-scan the live site after every deploy. Keys also leak through JS bundles, source maps and exposed `.env` or `.git` paths.

> **Scan box (use the site's ScanBox component):** Check whether your live app has this problem. Paste your URL for a free outside-in scan covering exposed keys, open database rules, CORS and security headers. [Scan my app free →](https://proofforge.live/#scan)

## FAQ

### Is my publishable key a leak?
No. `pk_` keys are designed for the browser.

### Why not a 7-day expiry?
The expiry window is for planned rotation. For a leak, expire the old key immediately.

### What do old deployments return?
An expired-key authentication error. See /errors/stripe-invalid-api-key.

## Sources

- [Stripe: API keys](https://docs.stripe.com/keys)
- [Stripe: Best practices for managing secret API keys](https://docs.stripe.com/keys-best-practices)

## Related

- [Fix: Stripe secret key exposed](/fix/stripe-secret-key-exposed)
- [Fix Stripe 'Invalid API Key provided' / api_key_expired](/errors/stripe-invalid-api-key)
- [Exposed API key checker](/tools/exposed-api-key-checker)
- [Fix: source maps exposed](/fix/source-maps-exposed)
- [All leaked-key guides](/leaked-keys)
