Skip to content
ShipSafeStack

Checklist

Leaked Stripe secret key? What to do right now

Short answer. A secret key (sk_live_ or sk_test_) and a restricted key (rk_live_ or rk_test_) are credentials. Roll the leaked one in the Dashboard and choose Now so the old key is deleted. A publishable key (pk_) is meant to be in the browser. A webhook signing secret (whsec_) is a different value, rolled on the webhook endpoint. Rewriting git history does not retire a key that already left the repo.

Updated 28 Nov 2026

This is a practical checklist, not a guarantee. It is not a penetration test, a compliance audit, or proof that an app is safe to launch.

A Stripe secret key is a credential for the account. Stripe's key best practices say that if someone else obtains it, they can make charges, read customer data, or disrupt the integration. Deleting the line from a file does not roll the key. This page is the first sitting after a leak. It is a checklist, not a statement that the account is fine.

The same shape for a GitHub token is Leaked a GitHub token?. An OpenAI key is Leaked OpenAI API key?. An AWS access key is Leaked AWS access key?.

What leaked

Stripe's API keys page separates the prefixes. Live keys use live_. Sandbox keys use test_. Objects in one mode are not visible to the other.

PrefixWhat it isIn the browser?
pk_live_ / pk_test_Publishable key for Stripe.js, Elements, and mobile SDKs. It can identify the account and create tokens or PaymentMethods. It cannot create charges or read account data.Yes. Stripe says you can include it in front-end code. You cannot expire a publishable key.
rk_live_ / rk_test_Restricted key. You choose Read, Write, or None per resource.No. Treat it like a secret.
sk_live_ / sk_test_Secret key with unrestricted permissions on all Stripe APIs. Stripe does not recommend these for new work, and says to move existing uses onto restricted keys.No.
sk_org_Organization key. It acts across the Stripe accounts in the organization.No.
whsec_Webhook signing secret. Not an API key. One per webhook endpoint, and a different secret for test and live if the endpoint is used in both.No. Roll it on the endpoint, not on the API keys page.

A publishable key in the client is the design. A secret key, a restricted key, an organization key, or a whsec_ value in the client, a commit, or a chat is the leak.

Roll it, and expire the old one now

Stripe's best-practices page says to rotate a restricted or secret key immediately if it was exposed, even when you are not sure anyone saw it. Exposure includes a public repository, a log file, or an email. If Stripe detects an exposed secret or restricted key, they notify you and ask you to rotate it. In some cases they deactivate the key and tell you what they did. They also say that detection does not catch every exposed key. Do not wait for an email.

On the API keys page in the Dashboard (Developers, then API keys), open the overflow menu for the key:

1. Choose Rotate key. 2. In Expiration, choose Now. Stripe's keys page says Now deletes the old key. A future time keeps the old key working until that time, for up to 7 days, so you can move servers without downtime. 3. Copy the new key. In live mode you cannot reveal a key you created yourself a second time. Save it in the host's secret store. 4. If the menu offers Expire key instead, that also stops the key. Stripe says code using an expired secret or restricted key can no longer make API calls.

Use the grace period only for a planned rotation, when the old key is not already public. A confirmed leak is the Now case. The keys page says rotating a compromised key is how you block API requests that might still use it.

The replacement secret key is named Secret key. The replacement restricted key keeps the old name. You can rename either afterward.

Then put the new value on the host. On Vercel, edit the environment variable and redeploy. Vercel's environment variables page says a change applies only to new deployments. The running deployment keeps the value it was built with. Other hosts are the same: the new value is unused until the next deploy that reads it. Search the repo for the old key and for NEXT_PUBLIC_STRIPE_SECRET, VITE_STRIPE_SECRET, and any sk_ or rk_ string. Remove those. The commit is the cleanup. It is not the roll.

If the platform issues a managed Stripe key, Stripe's best-practices page says the Dashboard lists it but does not show the full value, and that rotating it in the Dashboard synchronizes with the platform. You still redeploy the server app unless the platform does that for you.

Look for misuse

Stripe's keys page says to open View request logs from the key's overflow menu. That opens Workbench. Filter by date, endpoint, method, and IP. Look for calls you did not make: charges, refunds, customers, payouts, and webhook endpoints. A secret key can call all of those. A restricted key can call only what its permissions allow, which is still enough to matter if Write was on for payments or customers.

Workbench does not refresh the log by itself. Use Refresh logs.

Stripe's Identity docs, in the section on rolling a compromised key, say any webhook endpoints created with that key stay active after the roll, and they say to review the security history for events related to the key. Open Workbench, then Webhooks, and disable or delete an endpoint you did not add. Rolling the API key does not roll the whsec_ secret. If that secret leaked, roll it on the endpoint: Workbench, Webhooks, the endpoint's overflow menu, Roll secret. Stripe's webhook docs say you can expire the current signing secret immediately or keep it for up to 7 days while you update the server. For a confirmed leak, expire it immediately, then update the verifier. How to check the signature is Stripe webhook verification.

If the logs show charges, refunds, customers, or endpoints you did not create, contact Stripe. The best-practices page points at Protecting against compromised API keys for the support steps. Do not paste the key into that message.

Git history does not un-leak it

Rewriting history or deleting the repository removes the key from the copy GitHub shows afterward. It does not remove clones, caches, or scans that already copied it. GitHub's leaked-secret tutorial says removing a secret from the codebase, pushing a new commit, or deleting and recreating the repository does not stop exploitation. Roll first.

GitHub's supported secret scanning patterns include Stripe API keys, a legacy API key pattern, live and test restricted keys, the test secret key, and the webhook signing secret. The older introduction URL redirects there. Secret scanning runs on public repositories. A private repository may not alert you. The token side of a GitHub leak is Leaked a GitHub token?.

Keep the next key on the server

Stripe says only publishable keys are safe outside the backend. A name the framework inlines for the browser is public. On Next.js that prefix is NEXT_PUBLIC_. On Vite it is VITE_. The wider pass is API keys in the frontend. How generated code keeps writing secrets into source is how to keep API keys out of AI-generated code.

  • Call Stripe from a server route or an edge function. The browser gets a Checkout URL or a client secret for a PaymentIntent, not sk_ or rk_.
  • Prefer a restricted key. Stripe says these are the recommended keys for an AI agent, and that you set Read, Write, or None per resource. An unrestricted sk_live_ key is the one that can do everything. A restricted key is still a secret.
  • Verify webhooks with the endpoint's whsec_ value. A missing check lets someone post a fake "paid" event. That checklist is Stripe webhook verification.
  • Do not send the secret key in email or chat. Stripe says they never ask you for it.

Then run a free passive check on the public URL. It can see a key that shipped in a public script. It does not read your Stripe account. The worksheets are the checklist pack and the pre-launch checklist. Stripe is the directory entry. How it compares with another processor is Stripe vs Lemon Squeezy vs Paddle and the shorter Stripe vs Paddle note.

Lovable, Bolt, v0, and Cursor

These builders do not change the prefix. They change where the secret gets pasted.

A generated client that talks to Stripe still needs the secret on the server. If the chat wrote sk_live_ or rk_live_ into a component, a NEXT_PUBLIC_ name, or a VITE_ name, that is the leak above, whatever the builder was. Lovable and Bolt both have a server secret store for keys the browser must not see. Cursor and v0 edit the repo you deploy. The host's environment is where STRIPE_SECRET_KEY belongs, and the next deployment is what picks it up.

FAQ

Is a pk_ key a leak?

No. Stripe's keys page says a publishable key is safe to include in front-end code. It can identify the account and create tokens or PaymentMethods. It cannot create charges or read account data. You also cannot expire it. An sk_, rk_, sk_org_, or whsec_ value in that same file is the leak.

I deleted the key from GitHub. Is the Stripe key dead?

No. Stripe's keys page says you roll or expire a secret or restricted key on the API keys page. Choosing Now on Rotate key deletes the old key. A copy in git history, a fork, or the host's current deployment keeps working until then. Removing the line is the cleanup after the roll.

Should I keep the old key alive for a few days?

Only if it is not already public and you need a window to move servers. Stripe says a scheduled expiration keeps the old key working for up to 7 days. For a key in a repo, a bundle, a log, or a chat, choose Now. The best-practices page says to rotate immediately even when you are not sure anyone saw it.

Does rolling the API key change the webhook signing secret?

No. They are different values. Stripe's Identity docs say webhook endpoints created with a rolled key stay active. Roll whsec_ on the webhook endpoint itself, expire it immediately if it leaked, and update the server that checks Stripe-Signature. The steps are Stripe webhook verification.

Sources

Checked 23 Nov 2026.

Informational only. This page describes checks and vendor documentation. It is not a security audit, a penetration test, or a certification, and it is not a guarantee.

Newsletter

A short weekly note on new tools and security checklists. No spam, unsubscribe anytime.