Skip to content
Pwnversity
AUD-STRIPEintermediate · 10 min · upd. 2026-11

Auditing a Stripe integration

Stripepagoswebhooks

Stripe processes payments for a huge number of shops and SaaS products. Card data is captured by Stripe (Elements, Checkout) and the application only handles identifiers, so vulnerabilities are rarely in Stripe and almost always in the integration:

  • secret keys in the frontend, in repositories or in CI;
  • webhooks that don’t verify the signature;
  • amounts decided by the browser;
  • third-party code on the payment page that captures the card before it reaches Stripe.

Stripe runs the API, card tokenization and event signing. The customer decides:

  • which keys exist, with which permissions and where they are stored;
  • how webhooks are verified and what happens on receipt;
  • who computes the amount and product of each payment;
  • which JavaScript is loaded on the payment page;
  • who gets into the Dashboard and with which method.
flowchart LR
    N["Browser<br/>pk_live_ + Stripe.js"] -->|"card data"| S["Stripe"]
    B["Backend<br/>rk_live_ / sk_live_"] -->|"creates the payment<br/>server-side amount"| S
    S -->|"signed webhook<br/>Stripe-Signature"| W["Webhook endpoint"]
    W -->|"verifies signature and time"| F["Order fulfillment"]
    T["Third-party scripts<br/>GTM, analytics"] -.->|"skimmer"| N
Prefix Type Can it go to the client?
pk_live_ / pk_test_ Publishable Yes: it only tokenizes and confirms from the browser
rk_live_ / rk_test_ Restricted (RAK) No; permissions chosen per resource
sk_live_ / sk_test_ Secret No; full permissions on the account
sk_org_ Organization No; acts across several accounts
whsec_ A webhook’s signing secret No; it’s per endpoint

Stripe’s documentation no longer recommends secret keys for new use cases and advises migrating existing ones to restricted keys. Other points from its best-practices guide:

  • store keys in the platform’s secrets manager and scan repositories and CI with Stripe patterns;
  • share them only through those tools, never by email or chat (Stripe never asks for them);
  • rotate them periodically; when rotating, the old key’s expiration can be delayed by up to 7 days;
  • review API request logs to spot unusual use.

IP restrictions have been replaced by access policies on keys.

From the outside, the search is straightforward. On the Netlify lab bundle:

Ventana de terminal
grep -rEo '(sk|rk)_(live|test)_[0-9A-Za-z]{10,}' dist
dist/app.js:sk_live_510W1X…

(The output is trimmed here; it’s a lab key.) An sk_live_ key in the browser lets anyone charge, refund and read customer data. Report it; don’t use it.

Stripe signs each event with the endpoint’s secret. The Stripe-Signature header contains t=<timestamp>,v1=<HMAC-SHA256>, computed over "<t>.<body>". To verify:

  • use the raw body exactly as received: any middleware that parses and re-serializes the JSON breaks the signature;
  • compare the timestamp against a tolerance; the official libraries default to 5 minutes;
  • deduplicate by event id: Stripe can resend the same event;
  • if possible, limit the endpoint to the IPs published by Stripe, as an extra layer.

With the official stripe 17.1.0 library for Python and a made-up secret. The script signs an event the way Stripe would and then tries variants:

import hmac, hashlib, json, time
import stripe
SECRET = "whsec_lab_not_real"
def sign(payload: str, ts: int, secret: str = SECRET) -> str:
sig = hmac.new(secret.encode(), f"{ts}.{payload}".encode(), hashlib.sha256).hexdigest()
return f"t={ts},v1={sig}"
def check(name, payload, header, secret=SECRET):
try:
ev = stripe.Webhook.construct_event(payload, header, secret)
print(f"{name:34} ACCEPTED {ev['type']} amount={ev['data']['object']['amount']}")
except stripe.SignatureVerificationError as e:
print(f"{name:34} REJECTED {e.user_message}")
event = {"id": "evt_lab", "object": "event", "type": "payment_intent.succeeded",
"data": {"object": {"id": "pi_lab", "object": "payment_intent", "amount": 4999}}}
payload = json.dumps(event, separators=(",", ":"))
now = int(time.time())
check("1. valid signature", payload, sign(payload, now))
check("2. amount changed after signing", payload.replace("4999", "1"), sign(payload, now))
check("3. signature from 10 minutes ago", payload, sign(payload, now - 600))
check("4. another endpoint's secret", payload, sign(payload, now, "whsec_other"))
check("5. no v1 scheme", payload, f"t={now}")
reserialized = json.dumps(json.loads(payload), indent=2)
check("6. re-serialized body", reserialized, sign(payload, now))

Real output:

1. valid signature ACCEPTED payment_intent.succeeded amount=4999
2. amount changed after signing REJECTED No signatures found matching the expected signature for payload
3. signature from 10 minutes ago REJECTED Timestamp outside the tolerance zone (1795345536)
4. another endpoint's secret REJECTED No signatures found matching the expected signature for payload
5. no v1 scheme REJECTED No signatures found with expected scheme v1
6. re-serialized body REJECTED No signatures found matching the expected signature for payload

Case 6 is the most common integration bug: the event is legitimate, but the framework has already parsed the body and the signature doesn’t match. The “fix” sometimes applied is to remove verification, and then anyone can send a fake payment_intent.succeeded to the endpoint.

The most frequent logic flaws in Stripe integrations:

  • Amount from the client. The browser sends amount or price to the backend and it creates the PaymentIntent with that value. The amount must be computed on the server from the cart, or use Prices defined in Stripe.
  • Fulfilling without confirmation. The order is marked as paid when the user returns to the success URL (success_url), which anyone can visit, instead of waiting for the webhook or checking the payment status.
  • Trusted metadata. metadata.user_id or a client_reference_id sent by the client decides who gets the goods, without checking they match the session.
  • Races. Two webhooks or two simultaneous requests fulfill twice (see race conditions); use idempotency keys and per-event deduplication.

Stripe Elements isolates card fields in Stripe iframes, but a malicious script on the page can cover that form with a fake one. That’s why PCI DSS v4 requires inventorying and authorizing payment page scripts (requirement 6.4.3) and detecting unauthorized changes to the page (11.6.1).

A CSP that allows api.stripe.com doesn’t stop an attacker who also uses Stripe: in the campaign described by Sansec, the skimmer only talked to trusted domains.

  • Legacy API to validate cards (Jscrambler, April 2025). A skimmer injected into at least 49 shops overlaid a fake form and validated each stolen card against the legacy api.stripe.com/v1/sources endpoint before sending it to the attacker. Jscrambler later clarified that it had found no flaw in Stripe’s API or infrastructure.
  • Stripe as a command server (Sansec, June 4, 2026). A Magecart family loaded from Google Tag Manager containers on Magento and Adobe Commerce shops read its code from the metadata of a Stripe customer in the attacker’s account and stored stolen cards in new customers in that same account. Useful indicators: GTM containers nobody on the team added, and any sk_ key in client-side JavaScript.
  • No sk_ or rk_ key in the client, the repository or CI logs
  • Restricted keys with minimal permissions per service; secret keys only where there’s no alternative
  • Access policies on keys; rotation tested; notes on where each key is used
  • Webhooks verified with the raw body, time tolerance and per-event deduplication
  • Amount and product computed on the server; fulfillment only after the webhook or a payment status check
  • Payment page scripts inventoried and authorized (PCI DSS 6.4.3) and change detection (11.6.1)
  • Google Tag Manager containers reviewed; GTM access with MFA
  • Dashboard with strong MFA (security keys or passkeys) and minimal roles