My Stripe key leaked. What do I do?
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_orEXPO_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
.envor.gitpaths.
Check your live app
A free, read-only public-surface scan. It cannot diagnose private sessions or every cause described above.
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.