high · M3 · MASVS-AUTH-2 · PTKD-VC-WEBHOOK-UNVERIFIED

    Payment webhook handler without signature verification

    A server or edge function handles Stripe, RevenueCat, Lemon Squeezy or Paddle webhooks but never verifies the signature. Anyone who finds the URL can post a fake 'payment succeeded' event and unlock paid features or credit accounts.

    How it is exploited

    An attacker posts a hand-written checkout.session.completed event to https://<ref>.supabase.co/functions/v1/stripe-webhook. The handler never checks the signature, so it marks the attacker's account as paid.

    Why it matters

    Free access to paid features, credits added to any account, and wrong revenue numbers.

    How to fix it

    1. Read the raw request body (not parsed JSON) and verify the signature before doing anything.
    2. Stripe: stripe.webhooks.constructEvent (constructEventAsync in Deno) with the endpoint's signing secret. RevenueCat, Paddle, Lemon Squeezy: compare their HMAC or auth header in constant time.
    3. Reject unsigned or stale events with 400, and make the handler idempotent (store the event id).

    TypeScript (Deno edge function)

    const body = await req.text();
    const sig = req.headers.get("stripe-signature")!;
    const event = await stripe.webhooks.constructEventAsync(body, sig, Deno.env.get("STRIPE_WEBHOOK_SECRET")!);

    Does your app have this?

    PTKD checks your build or your source project for PTKD-VC-WEBHOOK-UNVERIFIED and every other check in this knowledge base.

    Scan your app

    References

    Related checks (M3)