Skip to content

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

WhenDoHow
0–2 minRollDashboard → Developers → API keys → roll the secret key with immediate expiry.
2–4 minReplaceSet the new key on your server only. Redeploy. Prefer a restricted rk_ key with minimum permissions.
4–7 minCheck activityReview request logs for unknown IPs, and check recent refunds, payouts, and new connected accounts or webhooks.
7–10 minClose the holeRemove 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.

Check your live app

A free, read-only public-surface scan. It cannot diagnose private sessions or every cause described above.

Read-only. No writes or row contents.

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

Related

Read as Markdown · Scan methodology