Unsigned Stripe webhook: what to do before you trust a payment event
Short answer: Do not unlock access, fulfill an order, or mark a subscription paid until your webhook handler has verified the request with Stripe's signature. Read the raw body, the Stripe-Signature header, and your endpoint signing secret that starts with whsec_, not your Stripe secret API key, through Stripe's official library. If verification fails, reject the request (for example with 400) and do nothing with the payload. Only after verification succeeds, return a quick 2xx, handle the event asynchronously, and ignore duplicates by event id. A free SniffPup scan of a site you own can help find a remaining exposed sk_ or whsec_ string in public files. It cannot prove your webhook verifies signatures, it cannot confirm a key is absent everywhere, and it never sends events. Run a free SniffPup scan of your own site after you have fixed the handler.
Want one 2-minute check like this every morning? Sign up below.
Passive checks only, for a live URL you own or are authorized to test. A score of 100 means no issues were found in our checks, not proof of security.
Home › Guides › Unsigned Stripe webhook · Last updated · By Ember, SniffPup
Which secrets are which
- Endpoint signing secret (
whsec_): unique per webhook endpoint. Used only to verify that a delivery came from Stripe. Reveal it in Workbench under Webhooks for that endpoint, or copy it fromstripe listenwhen you test locally. Those two secrets are different. Don't mix them. - Stripe secret API key (
sk_live_/sk_test_): calls the Stripe API. It is not the webhook signing secret. Do not pass it to signature verification. - Publishable key (
pk_): for Stripe.js and mobile SDKs. Not a webhook credential.
What to do in the next 10 minutes
Times are a rough guide. Stop trusting unverified events first.
1. Find the handler (Minutes 0-2)
Locate the route Stripe POSTs to. Common paths are /api/webhook, /webhooks/stripe, or a Supabase Edge Function. Confirm the live endpoint is HTTPS. Note which event types the handler acts on, such as checkout.session.completed, payment_intent.succeeded, and invoice.paid.
2. Verify before you parse or act (Minutes 2-5)
Keep the raw body as Stripe sent it. Any framework that re-parses or rewrites the body breaks verification, including for real Stripe events. Pass the raw body, the Stripe-Signature header, and the whsec_ endpoint secret into Stripe's official constructEvent for snapshot events or parseEventNotification for thin events. If verification fails, return 400 and do nothing with the payload. Do not return 2xx for an invalid signature. Libraries also check the signed timestamp. The default tolerance is about 5 minutes. Do not set tolerance to 0, which turns that check off.
3. Wire the secret correctly (Minutes 5-7)
Store whsec_ in a server-only secret, such as an environment variable or a secret store. Never put it in client JavaScript or in a VITE_ or NEXT_PUBLIC_ variable. If you roll the signing secret in Workbench, you can delay expiration for up to 24 hours so both secrets work while you update the server. After the new secret is live, expire the old one.
4. Supabase Edge Function note (Minutes 7-8)
Stripe does not send a Supabase user JWT. Supabase's docs say external webhooks (Stripe, GitHub, and similar) should turn the gateway JWT check off (verify_jwt = false or auth: 'none') and verify the provider's signature on the raw body inside the handler. JWT off makes the URL reachable. The Stripe signature check is the gate. On Deno, Supabase's example uses constructEventAsync with Stripe's SubtleCryptoProvider, because the synchronous constructEvent() throws there. See Supabase Edge Function with verify_jwt = false.
5. Harden delivery habits (Minutes 8-10)
Only after the signature checks out, return 2xx quickly, then do fulfillment work asynchronously. If verification failed, you already rejected the request and did nothing with the payload. Do not answer 2xx for an invalid signature. Track processed event ids so retries and duplicates don't double-fulfill. Prefer listening only to the event types you need. If a whsec_ or sk_ ever appeared in a public repo, chat, or client bundle, rotate it and follow Leaked Stripe secret key: what to do.
What SniffPup checks, and what it doesn't
SniffPup's free scan is passive and read-only on a live URL you own or are authorized to test. It looks for leaked secrets in HTML and same-origin JavaScript (masked in the report), public .env and .git files and similar paths, source maps, headers, cookies, and HTTPS. It may surface an exposed sk_ or whsec_ string if that string shipped to the browser. A passive scan can help find a remaining exposed key. It cannot confirm the key is absent everywhere. It does not call your webhook, send Stripe events, read your server code, or prove that signature verification is implemented. A score of 100 means no issues were found in our checks, not proof of security.
Next: Leaked Stripe secret key: what to do, Stripe MCP in Cursor still has sk_live in the config, Supabase Edge Function verify_jwt = false, and Find exposed API keys on your website.
FAQ
Can someone fake a checkout.session.completed if my URL is public?
Stripe's docs say that without verification, an attacker who can reach the endpoint could send fake webhook events to trigger actions like fulfilling orders. Signature verification with the endpoint whsec_ secret is how you confirm the delivery came from Stripe. If verification fails, return an error such as 400 and do not act on the payload. Do not return 2xx for a request that fails the signature check.
I already JSON.parse'd the body. Why does verification fail?
Stripe signs the exact raw body bytes. Parsing or otherwise changing the body before verification changes those bytes, so even genuine Stripe deliveries fail. Verify first, then use the event object the library returns.
Is my Stripe secret key (sk_) the webhook secret?
No. Use the endpoint signing secret that starts with whsec_. The secret from stripe listen and the secret in Workbench are different. Mixing them is a common reason verification fails.
Does SniffPup test whether my webhook verifies signatures?
No. The site scan only sees what your published URL serves. It does not call your webhook or send events. A passive scan can help find a remaining exposed key in public pages, but it cannot confirm a key is absent everywhere or prove the handler checks signatures. Fixing verification is a change you make in your handler.
Should I turn Supabase verify_jwt back on for a Stripe webhook function?
Stripe cannot present a Supabase user JWT. Keep the gateway JWT check off for that webhook function (verify_jwt = false, or auth: 'none' in Supabase's wrapper) and verify Stripe's signature on the raw body instead. Supabase's Edge Function example on Deno uses constructEventAsync with Stripe's SubtleCryptoProvider, because the synchronous constructEvent() throws on that runtime.
Sources: Stripe Docs: Receive Stripe events in your webhook endpoint (raw body, Stripe-Signature, whsec_, HTTPS in live mode, duplicate event ids, 2xx only after you accept the event), Stripe Docs: webhook signatures (replay tolerance, including why tolerance 0 turns the check off), Stripe Docs: Manage webhook endpoints (constructEvent, parseEventNotification, Reveal secret, roll a secret for up to 24 hours), and Supabase Docs: Securing Edge Functions (external webhooks, auth: 'none', and provider signature verification), checked November 9, 2026.