Verify the webhook signature before you read the body
A webhook endpoint that trusts the JSON it receives is an endpoint anyone can call. Every serious provider signs the payload with a shared secret.
const sig = req.headers.get("stripe-signature");
const event = stripe.webhooks.constructEvent(rawBody, sig, secret); // throws if wrongVerify against the raw body bytes, not a re-serialised object, and reject anything with a timestamp older than a few minutes to stop replays.
securityhttp