Common question

Is My Stripe Secret Key Exposed?

Short answer: if a key that starts with sk_live_, sk_test_ or rk_ shows up in code your visitors' browsers download, treat it as leaked and replace it.

Check your live app for free

Paste your link. The free summary usually takes under a minute.

Which Stripe keys are safe to show?

  1. Publishable keys start with pk_live_ or pk_test_. These are made to sit in your web page. That's fine.
  2. Secret keys start with sk_live_ or sk_test_. These can do almost anything on your Stripe account.
  3. Restricted keys start with rk_live_ or rk_test_. These have limited powers, but they are still secret.

Stripe's own docs say: "Only publishable keys are safe to expose outside your application’s back end." (Stripe: API keys)

How does a secret key end up public?

  1. The AI put it in front-end code. You asked for "add Stripe checkout" and the code calls Stripe straight from the browser with the secret key.
  2. It has a public prefix. Vite's docs say: "Variables prefixed with VITE_ will be exposed in client-side source code after Vite bundling." They also say: "VITE_* variables should not contain sensitive information such as API keys." (Vite: Env Variables and Modes) Next.js inlines variables that start with NEXT_PUBLIC_ into the JavaScript bundle. A name like VITE_STRIPE_SECRET_KEY or NEXT_PUBLIC_STRIPE_SECRET_KEY is public, even if your .env file is safe.
  3. It's in a public repo or a public /.env file. Anyone can read it there. See Is your .env file public?.

How to check

  1. Open your live site in Chrome, right-click, and choose "View page source." Press Ctrl+F (Cmd+F on Mac) and search for sk_live, sk_test and rk_.
  2. Check the JavaScript files too. Open DevTools (F12), go to the Sources tab, and search all files (Ctrl+Shift+F) for the same words.
  3. Search your code for STRIPE_SECRET and check it is only used in server code, such as an API route, an edge function or a Supabase function, and never in a file with a VITE_ or NEXT_PUBLIC_ name.
  4. Or paste your URL in the box above. The rest of what the scan can and can't see is below.

What to do if your secret key leaked

  1. Roll (replace) the key in your Stripe Dashboard right away. Stripe explains how in its key best practices guide. Rolling makes the old key stop working.
  2. Move all secret-key code to the server. Ask your AI builder: "Move every call that uses the Stripe secret key into a server function. The browser should only use the publishable key."
  3. Put the new key in your host's secret settings, not in your code and not in a VITE_ or NEXT_PUBLIC_ variable.
  4. Look at your Stripe activity for payments, refunds or changes you didn't make.
  5. Think about a restricted key. Stripe suggests restricted keys so each key can only do what it needs. See Stripe: restricted API keys.

A copy-paste prompt for your AI builder

Check my whole project for the Stripe secret key or any restricted key (sk_live_, sk_test_, rk_live_, rk_test_). Make sure it is only used in server-side code and is read from a secret environment variable. Make sure no variable holding it starts with VITE_ or NEXT_PUBLIC_. The browser should only ever use the publishable key (pk_). List every file you changed.

What the rooGBotVC scan checks

Paste your URL in the box at the top. The scan looks through your site's public JavaScript, and a few public files like /.env, for keys that look like Stripe secret and restricted keys.

  1. A live secret or restricted key is reported as Live secret key (sk_live_ / rk_live_) exposed in public code (critical).
  2. A test secret or restricted key is reported as Test secret key (sk_test_) exposed in public code (medium).
  3. If it only finds a publishable key, it may show Stripe publishable key found (this is OK) (info), and remind you to keep the secret key on the server.
  4. Found keys are shown shortened, never in full.

What the scan can't do:

  1. It can't see your server code or your Stripe Dashboard.
  2. It doesn't run your JavaScript, so a key that only shows up after the page runs may be missed.
  3. It never uses or tests any key it finds.
  4. It does not check whether your webhooks verify signatures. See Does my app check Stripe webhook signatures?.

A clean result means no secret key showed up in public code. It is not a full security audit.

Related reading

  1. Does my app check Stripe webhook signatures?: verify events before you unlock a paid plan.
  2. Exposed API keys: what to do when any secret key leaks.
  3. Is your .env file public?: another way a secret key can leak.

rooGBotVC is an automated, read-only check of what any visitor can see. It is not a full security audit and it does not see your server code or Stripe Dashboard. Not affiliated with Stripe, Lovable, Bolt, Cursor, Replit or v0.