For Lovable, Bolt, Cursor and v0 apps
Leaked your Stripe secret key? Do this, in order
Direct answer
If a Stripe key starting with sk_live_, sk_test_ or rk_ is in your frontend JavaScript, anyone who opens your site can copy it. Stripe treats secret keys like a username and password: someone holding one can make charges, read customer data, or disrupt your integration. Rotate it in the Stripe Dashboard now, check your request logs, and move every Stripe call into a server function. Only the publishable pk_ key belongs in the browser.
LeakLatch is a free, read-only scan of a live URL you own. It reports leaked secret keys in your JS bundles, Supabase tables that answer with your public anon key, and missing security headers. You get a risk score, redacted findings, and a fix prompt for Lovable, Cursor, or Claude.
What to do
Five steps for your own project
Use these on a project you own. The commands only read your own files; nothing here changes your app. Sources for Stripe's guidance: Stripe Docs, Best practices for managing secret API keys and Stripe Docs, API keys.
Step 1
Rotate the leaked key now
On the API keys page of the Stripe Dashboard, open the key's menu and choose Rotate key. Rotating revokes the old key and creates a replacement. Stripe says to rotate an exposed secret or restricted key immediately, even if you aren't sure anyone saw it. If the key shipped in public JavaScript, choose an expiration of Now rather than the up-to-7-day grace period.
Step 2
Check your request logs and account activity
Stripe recommends auditing API request logs to spot misused keys. Look in Workbench request logs for calls you didn't make, and check payments, refunds, payouts and customers for anything unexpected. Stripe's support page on compromised keys covers what to do next if you find misuse.
Step 3
Move every Stripe call to a server function
Stripe says secret keys must stay in your server environment and never be embedded in applications. In a vibe-coded app, create Checkout Sessions, PaymentIntents and refunds in a Supabase Edge Function, a Vercel or Netlify function, or a Next.js route handler. The browser only ever needs the publishable pk_ key.
Step 4
Store the new key as a server-only secret, ideally restricted
Anything with a VITE_ or NEXT_PUBLIC_ prefix is copied into the JavaScript every visitor downloads. Put the new key in your hosting or Supabase secrets with no such prefix. Stripe recommends restricted keys (rk_) with only the permissions each part of your app needs instead of an unrestricted secret key.
Step 5
Rebuild and check the live site
Old bundles can stay cached, and your hosting dashboard can hold different values than your local .env. After redeploying, search the build output with the commands below, then check the live URL to confirm no sk_ or rk_ key ships to visitors.
# Run in your own project folder after a production build.
# Vite (Lovable, Bolt): output in dist/ Next.js (Cursor, v0): output in .next/static/
# 1. Stripe secret and restricted keys. Prints only the first characters.
grep -rEoh "(sk|rk)_(live|test)_[A-Za-z0-9]{4}" dist .next/static 2>/dev/null | sort -u
# 2. Stripe secret keys in source, env files and config:
grep -rnE "(sk|rk)_(live|test)_" src app supabase . --include=*.ts --include=*.tsx --include=*.js --include=*.env* 2>/dev/null
# 3. Public env variables that hold a Stripe secret (these are built into the bundle):
grep -rnE "(VITE_|NEXT_PUBLIC_)[A-Z_]*STRIPE[A-Z_]*(SECRET|SK)" . --include=*.env* --include=*.ts --include=*.tsx 2>/dev/nullCopy-paste fix
Move Stripe calls server-side with one prompt
Paste this into Lovable, Cursor, or Claude and point it at your own project. Review each change before you apply it, and rotate the old key if it already shipped.
You are helping me remove the Stripe secret key from the client side of my own app. Keep existing payment features working. 1. Find every place the app calls the Stripe API with a secret or restricted key (sk_live_, sk_test_, rk_live_, rk_test_), including VITE_ and NEXT_PUBLIC_ variables, hard-coded strings and committed .env files. 2. Move each of those calls (Checkout Sessions, PaymentIntents, customers, refunds, subscriptions) into a server function (Supabase Edge Function, Vercel/Netlify function, or Next.js route handler) that reads the key from a server-only env var named STRIPE_SECRET_KEY with no VITE_ or NEXT_PUBLIC_ prefix. 3. In that function, check the caller is signed in or otherwise allowed, take amounts and prices from the server or Stripe Price IDs (never trust an amount from the browser), and validate input. 4. Keep only the publishable pk_ key in the frontend, and change the frontend to call my server function. 5. Remove the secret key from the frontend and committed files, rebuild, confirm no sk_ or rk_ string is in the build output, and remind me to rotate the old key in the Stripe Dashboard and consider a restricted key.
FAQ
Straight answers about a leaked Stripe key
Is my Stripe publishable key (pk_) safe to expose?
Yes. Stripe's API keys page lists the publishable key as safe to expose: it is meant for Stripe.js, Elements and mobile SDKs, and it can't create charges or read account data. Secret keys (sk_), restricted keys (rk_) and organization keys (sk_org_) are not safe to expose.
What can someone do with my leaked Stripe secret key?
Stripe says an unauthorized party with your secret key can make unauthorized charges, access customer data, or disrupt your integration. A standard secret key has unrestricted permissions on all Stripe APIs, which is why Stripe recommends restricted keys for new use cases.
It was only a test key (sk_test_). Do I still need to rotate it?
Yes. A sandbox key can't move real money, but it is still a secret that should only live on the server, and Stripe's guidance is to treat any exposure as a potential compromise. Rotate it and fix the code path that put it in the frontend, because the same path will leak your live key when you switch.
Is deleting the key from my code enough?
No. Copies of the old bundle, git history and forks still contain the key, and it keeps working until you rotate or expire it in the Stripe Dashboard. Rotate first, then clean up the code. Code that uses an expired key can no longer make API calls.
Will Stripe catch the leak for me?
Sometimes. Stripe says that if it detects an exposed secret or restricted key it notifies you and asks you to rotate it, and in some cases deactivates the key. It also says it doesn't guarantee detection of all exposed or compromised keys, so don't rely on it.
What does LeakLatch check here?
LeakLatch loads the live URL you give it and its JavaScript bundles, read-only, and looks for known secret key patterns, including Stripe sk_live_ and sk_test_ keys, plus OpenAI, Anthropic, AWS, Resend, GitHub and Supabase service_role keys. Stripe pk_ keys are reported as informational. It also checks whether Supabase tables answer with your public anon key. Secret values are redacted in the report. You must confirm you own the site or have permission to scan it. It is not a substitute for a full security audit.
Want this check done for you, read-only?
Paste a URL you own. LeakLatch returns a score, redacted findings, and a fix prompt.
Scan my site free