The subscription app whose billing webhook did not check who was calling
A solo-founder SaaS on Next.js and Stripe. The Deep scan reported that the billing webhook accepted events without a valid signature, so plan changes depended on trust rather than proof. One function call fixed it.
Composite case study: built from real Scanwright findings, with names, hosts and figures changed.
- Team
- One founder
- Built with
- Cursor
- Scan
- Deep, with the webhook path and test signing secret in Setup
- Time to fix
- Twenty minutes
- Result
- Re-scan confirmed the check, Watch on
The app
A scheduling tool sold by subscription. Stripe Checkout takes the payment and a webhook tells the app which workspace to upgrade. The handler parsed the event body and updated the plan.
What the report said
- High: the webhook endpoint accepted test events that carried no signature, and events signed with the wrong secret. In practice the plan field could be changed by anyone who knew the URL.
- Low: the endpoint also accepted correctly signed events that were more than five minutes old, which the Stripe library would reject by default.
- Info: the Stripe publishable key was in the client bundle, which is expected; no secret keys were found.
Why it had not been caught
Stripe's own test events had always arrived signed, so the handler had never seen an unsigned one. The generated code read the body and skipped the verification step, and nothing in normal use would ever reveal that.
Verify every event with the Stripe library against the raw request body before reading it, and let the library's default five-minute window stand.
- Read the raw body, not the parsed JSON.
- Call stripe.webhooks.constructEvent with the endpoint secret and return 400 when it throws.
- Keep the default tolerance; do not widen it.
- Re-run the Deep scan's included re-scan.
const sig = req.headers['stripe-signature'];
let event;
try {
event = stripe.webhooks.constructEvent(rawBody, sig, process.env.STRIPE_WEBHOOK_SECRET);
} catch (err) {
return res.status(400).send(`Webhook error: ${err.message}`);
}
// only now act on event.type
- The re-scan showed the unsigned and wrongly signed events rejected and a correctly signed one accepted. The finding closed with a "fixed" badge in the report.
- The founder kept the webhook path and test secret in Setup so every future Deep scan repeats the check.