Why your Stripe webhook must verify signatures (and how to check yours)
An unverified webhook lets anyone mark an order as paid. Here is what verification does, how to test it and what AI tools get wrong.
If your Stripe webhook does not check the Stripe-Signature header, anyone who finds the URL can tell your app that a payment succeeded. Verification takes about five lines, and it is one of the eight checks that block launch in SIGSHIP because the failure is silent: nothing looks wrong until someone gets a paid plan for free.
What does a webhook actually do?
Stripe does the charging, then sends an HTTP request to a URL you own saying what happened: checkout.session.completed, invoice.paid, customer.subscription.deleted. Your code reads the event and updates the database: mark the order paid, unlock the plan, cancel access. The request arrives over the public internet, so your endpoint is a public URL that changes who gets what.
Why isn't HTTPS enough?
HTTPS stops people reading the request on the way. It does not stop a person sending their own request to the same URL with a body they typed themselves. Stripe's answer is a signature: every event is signed with a secret that only Stripe and you know, and the signature and a timestamp travel in the Stripe-Signature header. Stripe's documentation says to verify it with the official library and to reject events whose timestamp is too old, which blocks replays as well.
What does the fix look like?
In Node, the whole check is one call. The important detail is that it needs the raw request body, not the parsed JSON, which is the step most generated code skips:
const sig = req.headers['stripe-signature'];
const event = stripe.webhooks.constructEvent(rawBody, sig, process.env.STRIPE_WEBHOOK_SECRET);
// only now trust event.type and event.data
If constructEvent throws, return 400 and do nothing else. If your framework parses JSON before your handler runs (Express with express.json(), Next.js API routes, many Supabase edge function templates), turn that off for this one route and read the bytes.
npx sigship reads your repo on your own machine and flags an unverified Stripe webhook as SEV-1, with the file and a fix you can paste into your AI tool.
Why do AI-built apps get this wrong?
- The happy path works without it. Stripe's own test events arrive fine whether or not you verify, so a demo never fails.
- The body gets parsed too early. The generated handler receives an object, calls
constructEventonJSON.stringify(body), the signature fails, and the next prompt is "make the webhook stop erroring". The usual "fix" removes the check. - The secret is missing.
STRIPE_WEBHOOK_SECRETis different from your API key and different per endpoint. When it is unset, some templates fall back to skipping verification.
How do you check your own app in a minute?
- Search the code for
constructEvent(Node),Webhook.construct_event(Python) orWebhook::constructEvent(PHP). No match means no verification. - Send a fake event with
curlto your endpoint: a made-up body, no signature. A verified endpoint answers 400. If it answers 200, stop and fix it today. - Run
npx sigshipon the repo. Thestripe-webhook-unverifiedcheck is SEV-1 and names the file.
What else should the handler do?
- Be idempotent. Stripe retries. Store the event id and ignore one you have already handled.
- Answer fast. Return 200 within a few seconds and do slow work afterwards, or Stripe treats it as failed and retries.
- Trust the event, not the client. Never mark an order paid from the browser's success page; wait for the webhook.
Webhooks are one of the places where a prototype and a product differ. Our prototype to production checklist covers the rest.
Questions
What happens if a Stripe webhook is not verified?
Anyone who finds the endpoint can send a fake event, for example a successful payment, and your app will act on it. Verification with the Stripe-Signature header stops this.
Why does Stripe signature verification keep failing?
Almost always because the handler receives a parsed body instead of the raw bytes. Disable JSON parsing for the webhook route and pass the raw body to constructEvent.
Is the webhook secret the same as my Stripe API key?
No. Each webhook endpoint has its own signing secret, shown in the Stripe dashboard when you create the endpoint and by the Stripe CLI for local testing.
How do I test a Stripe webhook locally?
Use the Stripe CLI: stripe listen forwards events to your local server and prints the signing secret to use while testing.
Does SIGSHIP check Stripe webhooks?
Yes. stripe-webhook-unverified is one of its eight SEV-1 checks. It runs on your computer and a GO is not proof the app is safe, but it catches a missing check before users do.
The Idea Lab turns a two-sentence idea into a build plan: why it could work, what to get right first, the first version worth building and its price. Two minutes, from our published rates.