Is your webhook endpoint open to fake events? Signature checks in AI-built apps (and a 3-minute test)
A webhook is a URL on your server that another service calls: Stripe when a payment succeeds, a form tool when someone submits, an auth provider when a user signs up. If your handler trusts every request it receives, any
A webhook is a URL on your server that another service calls: Stripe when a payment succeeds, a form tool when someone submits, an auth provider when a user signs up. If your handler trusts every request it receives, anyone who finds the URL can send a fake "payment succeeded" event and your app will believe it. AI-generated handlers often skip the signature check because the code works without it.
1. What an unsafe handler looks like
app.post("/api/webhooks/payments", express.json(), async (req, res) => {
if (req.body.type === "payment_succeeded") {
await db.user.update({ where: { id: req.body.userId }, data: { plan: "pro" } });
}
res.sendStatus(200);
});
Nothing here proves the request came from your payment provider.
2. What a safe handler does
- Reads the raw request body, before any JSON parsing changes it
- Reads the signature header the provider sends
- Recomputes the signature with the signing secret stored on your server
- Compares the two with a constant-time comparison
- Rejects the request with a 400 if they do not match
- Checks the timestamp, if the provider sends one, and rejects old requests to block replays
- Handles each event ID once, so a repeated event does nothing
Most providers ship a library function for this step. Use it instead of writing your own.
3. A 3-minute test on your own app
- Find your webhook URL in the provider's dashboard.
- Send a request to it yourself with a made-up body and no signature header.
- A safe handler returns 400 or 401. If it returns 200 and does the work, it is open.
- Check your database to see whether the fake event changed anything.
Only send test requests to your own endpoint, and use a test or staging environment, not live customer data.
4. Other mistakes to look for
- The signing secret is in the repo, in frontend code, or in a public
.env - The handler trusts a user ID or amount from the body without checking it against your own records
- The endpoint has no rate limit
- Error messages return internal details to the caller
What an outside scan can and cannot tell you
An outside scan cannot know where your webhook URLs are unless they are linked publicly, and it should not send fake events. It can flag a leaked secret in public files. Test each webhook by hand, as above.
Check your own app from the outside, free. Run the free ProofForge scan on your live URL. No account needed for the first scan. It looks at your public site the way a stranger would and says pass, fail or inconclusive, so you know what is confirmed and what it could not see. One-time reports start at $9: see pricing. Building with an AI agent? There is an MCP server so it can check before it deploys.
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.