A Stripe publishable key is designed to be public. It goes into web pages and mobile apps so that card details can be sent straight to Stripe without crossing your server, and it can only create tokens and payment methods, not charge a card, read customers or move money. Finding one in a repository is therefore low risk by itself, which is why it is rated low. The real question is what was committed with it: a secret key next to a publishable key is the usual accident, and that one is serious. Check for secret keys first, then decide whether you want to replace the publishable key at all.
Check your GitHub account for leaked secrets — free
- Provider
- Stripe
- Severity
- Low
- Impact
- Limited impact
- Checked live by LeakWatch
- Yes
What a Stripe publishable key looks like
A publishable key starts with pk_, then the mode, then an underscore and a body of letters and digits:
pk_live_XXXX…XXXX Stripe publishable key, live mode (masked)
pk_test_XXXX…XXXX Stripe publishable key, test mode (masked)
The pk_ prefix is what separates it from the secret key, which starts with sk_, and from the restricted key, which starts with rk_. Mixing them up is the main source of panic and of real leaks. A pk_ key appears in front-end code on purpose: in the call that initializes Stripe.js, in a mobile app configuration, or in variables such as STRIPE_PUBLISHABLE_KEY, NEXT_PUBLIC_STRIPE_KEY or VITE_STRIPE_PK. Seeing it in a public bundle is normal. Seeing it in a file together with a sk_ value is not.
How Stripe publishable keys get leaked
Strictly speaking they are not meant to stay secret, so this is about how they end up in a repository next to something that is.
- Front-end source. A checkout page or mobile app that includes the key in its code, which is expected and harmless on its own.
- Environment files. A
.envwhereSTRIPE_PUBLISHABLE_KEYandSTRIPE_SECRET_KEYsit on adjacent lines and the whole file is committed. - Sample projects. A tutorial repository with both keys of a real account in the configuration.
- Documentation and READMEs. Setup instructions that show a real pair of keys instead of placeholders.
- Build logs. A CI step that prints all variables, including the secret one.
What to do in the first hour
- Look at what is around the key. Search the same file, the commit and the history for
sk_live_,sk_test_,rk_live_andrk_test_. A secret key found there is the real incident, and you should follow the guide for it: Stripe secret key. - Confirm the key type. Check that the string really begins with
pk_and notsk_. If it begins withsk_, stop and roll it at once. - Decide whether to replace it. A publishable key can be replaced from the Stripe Dashboard, but it is already visible in every page that uses it, so replacing it protects very little. Do it if you want clean hygiene or if the account was targeted, and expect to redeploy every front end and mobile build that uses it.
- Check the logs. In the Stripe Dashboard, look at the request logs and the list of recent payments for activity you did not expect, such as many failed card attempts, which is the typical misuse of a publishable key (card testing).
- Add protection against card testing. Consider Stripe’s fraud tools, rate limiting on your checkout endpoint, and a captcha on forms that create payment methods.
- Check restricted and secret keys in the Dashboard for any you do not recognize.
- Clean up the code so that only the publishable key is in front-end code, and secrets stay on the server. See I accidentally pushed an API key to GitHub.
Not sure what else leaked from the same repository? Run a free scan.
Revoke it at Stripe
Stripe keys are managed from the API keys page of the Stripe Dashboard, after you sign in with a user allowed to manage them. The page lists the publishable and secret keys of each mode, test and live, separately. If you decide to replace the publishable key, look for the option to roll it there, and note that a new publishable key must be deployed to every front end that uses the old one. The Stripe documentation on API keys describes the key types and how they should be handled. A person has not confirmed the exact menu wording for this guide, and the interface can change, so if what you see differs, look for the page where keys are listed and follow Stripe’s documentation.
How LeakWatch detects it
This guide covers two rules. The rule called Stripe Publishable Key (live) matches pk_live_ followed by exactly 24 letters or digits. The rule called Stripe Publishable Key (test) matches pk_test_ followed by exactly 24 letters or digits. Neither requires a word boundary, so a longer body is cut at 24 characters and still reported, and a shorter one is refused. Both are case-sensitive and need no variable name nearby. The severity of both is low, because a publishable key is not a secret.
LeakWatch can check whether a detected key is still active with a read-only request to Stripe. It never reads your data or spends your credits.
This type is checked live. LeakWatch applies the same check to every Stripe key type: one read-only request to the balance endpoint of the Stripe API, with the string as a Bearer token. A publishable key is not a secret key and is not meant to authenticate that endpoint, so a rejection is the normal outcome and says nothing about the safety of what sits next to it. The result is recorded as valid on a 200 or a 403, invalid on a 401, and rate limited on a 429.
FAQ
Is it a problem that my publishable key is in my public repository?
Not by itself. Stripe designed it to be visible in front-end code. The danger is a secret key committed in the same file or history, so search for one.
Should I roll a publishable key after it leaked?
Usually you do not need to, because it is exposed in your own web pages anyway. Roll it if you want, or if you see card-testing traffic, and redeploy all clients.
How do I tell a publishable key from a secret key quickly?
Read the first three characters. pk_ is publishable and public by design. sk_ and rk_ are secret and restricted keys that must stay on your server.