Anyone can tell your app they paid.
Updated 2026-10-13 · Plain English, written for founders who built with Lovable, Bolt, Cursor or similar.
When someone pays, Stripe sends your app a webhook such as checkout.session.completed, and your app unlocks what they bought. Stripe signs every webhook. If your handler does not check that signature, it believes any request shaped like one. Anyone can send your webhook URL a made-up "payment succeeded" event with their own user id in it and get your paid plan for free.
It is an easy mistake because the unsafe version works perfectly in testing. Real payments arrive, access is granted, nothing looks wrong.
Check if you're affected
Find your webhook handler (often api/webhooks/stripe, api/stripe/webhook or a Supabase Edge Function called something like stripe-webhook). The unsafe version reads the body as JSON and trusts it:
// UNSAFE: anyone can send this
export async function POST(req: Request) {
const event = await req.json();
if (event.type === "checkout.session.completed") {
await grantAccess(event.data.object.client_reference_id);
}
return new Response("ok");
}
If your handler never calls stripe.webhooks.constructEvent (or constructEventAsync), it is not verifying anything.
Fix it: Next.js
// app/api/webhooks/stripe/route.ts
import Stripe from "stripe";
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!);
export async function POST(req: Request) {
const body = await req.text(); // raw body, not req.json()
const signature = req.headers.get("stripe-signature") ?? "";
let event: Stripe.Event;
try {
event = stripe.webhooks.constructEvent(body, signature, process.env.STRIPE_WEBHOOK_SECRET!);
} catch {
return new Response("Invalid signature", { status: 400 });
}
if (event.type === "checkout.session.completed") {
const session = event.data.object;
await grantAccess(session.client_reference_id, event.id);
}
return new Response("ok");
}
Fix it: Express
The webhook route needs the raw body, so register it before app.use(express.json()):
app.post("/api/webhooks/stripe", express.raw({ type: "application/json" }), (req, res) => {
let event;
try {
event = stripe.webhooks.constructEvent(
req.body, req.headers["stripe-signature"], process.env.STRIPE_WEBHOOK_SECRET);
} catch {
return res.status(400).send("Invalid signature");
}
// handle event.type ...
res.send("ok");
});
app.use(express.json()); // everything else
Fix it: Supabase Edge Function
Stripe does not send a Supabase login token, so this function is usually deployed with --no-verify-jwt. That makes the signature check the only thing protecting it. Deno needs the async version:
import Stripe from "npm:stripe";
const stripe = new Stripe(Deno.env.get("STRIPE_SECRET_KEY")!);
const crypto = Stripe.createSubtleCryptoProvider();
Deno.serve(async (req) => {
const body = await req.text();
try {
const event = await stripe.webhooks.constructEventAsync(
body, req.headers.get("stripe-signature") ?? "",
Deno.env.get("STRIPE_WEBHOOK_SECRET")!, undefined, crypto);
// handle event.type ...
return new Response("ok");
} catch {
return new Response("Invalid signature", { status: 400 });
}
});
Get the details right
- The webhook secret starts with
whsec_. It is shown on the endpoint's page in the Stripe dashboard. When testing locally,stripe listenprints a different one. Live and test mode have different secrets too. - "No signatures found matching the expected signature" almost always means the body was parsed and re-serialised before verification. Pass the exact raw text.
- Handle repeats. Stripe can deliver the same event more than once. Store
event.idand skip ones you have already processed. - Never take the price from the browser. When you create the Checkout Session, pick the Stripe Price ID on the server from your own list of plans. If the browser sends an amount, someone will send 1 cent.
After the fix
- Send your webhook URL a plain POST with a fake event body. It should get a 400.
- Run a real test-mode checkout. Access should still be granted.
- Look through your customers for accounts with paid access but no matching Stripe payment.
Check your app
SecureIndie looks for this mistake. The free quick check covers the basics from outside (exposed files, keys in your site's code, headers) in about a minute. Database rules, payment webhooks and AI endpoints need the full audit, which also reads your code and proves what a visitor can actually reach.
Questions
How would an attacker know my webhook URL?
Common paths like /api/webhooks/stripe are easy to guess, and frontend code or a public repo often names it. Security that depends on nobody finding the URL is not security.
Why does constructEvent fail with "No signatures found"?
Almost always because the body was parsed as JSON before verification. Stripe signs the raw bytes, so you have to pass the raw body, not a re-serialised object.
Do I still need to check the price?
Yes. Verifying the signature proves Stripe sent the event. Your checkout still has to set the price on the server from a Price ID, never from an amount the browser sent.
Related guides
Checks covered: PAY-001, PAY-002 · If you think data already leaked