Skip to main content
HighContentOWASP A07:2021CWE-798

How to fix: Stripe Secret Key Exposed

A Stripe secret key (sk_live_ or sk_test_) was found in the response body. Publishable keys (pk_live_/pk_test_) are deliberately not reported here: Stripe's own integration docs require embedding those in client-side code, so they are public by design.

Why it matters

A secret key grants full API access to the Stripe account: reading customer and payment records, creating charges and refunds, and changing account settings. Anyone who can view the page source has it.

sk_live_ and sk_test_ keys are server-only credentials and must never reach the browser. The publishable key (pk_live_/pk_test_) is the one Stripe.js, Checkout, and Elements are meant to use in client-side code, and it is not reported by this check.

How to fix it

  1. 1Roll the exposed secret key in the Stripe dashboard immediately, then review the account's recent API activity for anything you did not initiate.
  2. 2Keep the secret key in a server-side environment variable and use only the publishable key in browser code.

Code examples

Rotate exposed Stripe keys

bash
# Rotate at: https://dashboard.stripe.com/apikeys
# 1. Create a new secret key
# 2. Update all environments with the new key
# 3. Roll the old key (revoke it)

# Only sk_live_* (secret keys) need rotation
# pk_live_* (publishable keys) are intentionally public and safe in browsers

# Store the secret key in environment variables only:
# STRIPE_SECRET_KEY=sk_live_...

References

Detected automatically by VulnRadar. The check id is stripe-key-exposed, stable across every scan so you can filter or diff on it.

See every content check

Questions

How severe is Stripe Secret Key Exposed?
VulnRadar rates this high severity in the content category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
Does VulnRadar check for this automatically?
Yes. It runs as part of every scan under the check id stripe-key-exposed, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does Stripe Secret Key Exposed map to?
It maps to CWE-798. In the OWASP Top 10 it falls under A07:2021.

Missing a check?

The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.

Propose a checkHow a check is built

Scan your own site for stripe secret key exposed

VulnRadar runs this check and hundreds more against a URL in seconds. No agent to install, just paste a URL.

Or scan this site as a demoRead the docs

How to fix: Stripe Secret Key Exposed | VulnRadar