Case studies / Payment security
highNext.js · Stripe · Postgres · Railway

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

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.

The fix

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.

  1. Read the raw body, not the parsed JSON.
  2. Call stripe.webhooks.constructEvent with the endpoint secret and return 400 when it throws.
  3. Keep the default tolerance; do not widen it.
  4. 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 result
  • 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.