Webhook signature verification
| Class | Access control |
|---|---|
| Protects against | Forged and replayed webhook deliveries |
| CWE | CWE-345: Insufficient Verification of Data Authenticity |
| OWASP Top 10 | A08:2025 Software or Data Integrity Failures |
| Severity when missing | High |
| Common schemes | HMAC-SHA256 with a shared secret (Stripe, GitHub, Slack, Standard Webhooks v1); Ed25519 public-key signatures (Standard Webhooks v2a) |
A webhook endpoint is an address such as /api/webhooks/stripe that accepts POST requests from anyone on the internet. The provider calls it to report an event, for example a paid invoice, and the application acts on the body, for example by marking the order paid. Nothing in HTTP says who sent the request, so unless the application adds its own check, the endpoint is a public handler with no authentication.1 Webhook signature verification is that check. The provider signs every delivery with a key, and the receiver recomputes the signature and rejects any request whose signature does not match.2
Without it, anyone who learns the address can post a made-up event and have an order fulfilled, account access granted or a record changed.3
How the signature is built
Most providers use an HMAC with SHA-256. Provider and receiver share a random signing secret, and the provider computes the HMAC over the exact bytes it sends, then puts the result in a header.2 The details differ by provider:
| Scheme | Header | Signed text |
|---|---|---|
| GitHub | X-Hub-Signature-256: sha256=<hex> | The request body |
| Stripe | Stripe-Signature: t=<time>,v1=<hex> | Timestamp, a full stop, the body |
| Slack | X-Slack-Signature: v0=<hex> with X-Slack-Request-Timestamp | v0:, timestamp, colon, body |
| Standard Webhooks | webhook-signature: v1,<base64> with webhook-id and webhook-timestamp | Message ID, timestamp and body, joined by full stops |
GitHub signs the body alone.4 Stripe and Slack put a timestamp inside the signed text,35 and Standard Webhooks adds a message ID as well.2
A shared secret means both sides can produce valid signatures. The Standard Webhooks specification therefore also defines a public-key variant: the provider signs with an Ed25519 private key and the receiver checks with the matching public key, which is not secret. Because one key pair may serve many endpoints, the signed text then starts with an endpoint ID, so a delivery signed for one endpoint fails at another. The receiver keeps its own list of trusted public keys and never takes one from a header of the request.2
Where verification fails
The body changed before the check
An HMAC changes completely when one byte of the input changes, and even a stray space in the body makes a valid signature fail. A common cause is code that parses the JSON body and turns it back into text before checking. The new text can differ from the original in spacing or key order, so the recomputed signature no longer matches.2 Stripe's libraries require the raw body for this reason.3
An ordinary string comparison
A plain == between the computed and the received signature can take measurably different times depending on the input, and that difference is a timing leak. An attacker who measures it can use the endpoint to test guesses at a valid signature, which makes it a signing oracle.2 A constant-time comparison closes the leak: crypto.timingSafeEqual in Node, hmac.compare_digest in Python.41
Failing open when the secret is missing
Some handlers run the check only if a secret is configured. In PraisonAI's WhatsApp and Linear bot adapters, the secret came from an environment variable that is empty on a fresh install; with it unset, the code parsed the body and handled it as a real event, and the start-up routine only logged a warning. The HMAC function itself was correct; the bypass was the condition around it.6 A safer handler refuses to start, or rejects every delivery, when it has no secret.
A downgraded or unsigned field
A Stripe header can carry signatures under more than one scheme name. The receiver should accept only the scheme it expects, v1, and ignore the rest, so an attacker cannot pick a weaker one.1 Stripe also warns that a payload entry an SDK error may show is unsigned debugging data; only a valid v1 HMAC proves anything.3
Replays and duplicates
A correct signature proves the provider produced a delivery once. Someone who captures that delivery can send it again unchanged, a replay attack. Schemes that sign a timestamp let the receiver reject old messages, and because the time is inside the signed text it cannot be edited without breaking the signature. Stripe's libraries allow 5 minutes by default, and a tolerance of 0 turns the check off.3 Slack's example code uses the same five-minute window.5
Providers also send the same event more than once on purpose, after a failed delivery. Each retry carries a new timestamp, while the event or message ID stays the same, so the receiver stores the IDs it has processed and skips repeats.2
OneUptime, 2026
CVE-2026-33143, published on 20 March 2026, covers OneUptime, a tool for monitoring online services. Before version 10.0.34, its WhatsApp webhook at /notification/whatsapp/webhook handled status updates without checking Meta's X-Hub-Signature-256 header, although the same codebase already verified Slack webhooks. Forged requests could change delivery records, hide alerts and corrupt the audit trail.7
Verifying in code
The provider's own library is the first choice: stripe.webhooks.constructEvent for Stripe, as shown in Securing Stripe payments, and @octokit/webhooks for GitHub.4 Without a library, an Express route for GitHub reads the raw body and compares in constant time:
import crypto from 'node:crypto';
import express from 'express';
const app = express();
const secret = process.env.GITHUB_WEBHOOK_SECRET;
if (!secret) throw new Error('GITHUB_WEBHOOK_SECRET is not set');
// raw body (a Buffer) for this route
app.post('/webhooks/github', express.raw({ type: 'application/json' }), (req, res) => {
const expected = 'sha256=' + crypto.createHmac('sha256', secret).update(req.body).digest('hex');
const got = req.get('X-Hub-Signature-256') || '';
const a = Buffer.from(expected);
const b = Buffer.from(got);
if (a.length !== b.length || !crypto.timingSafeEqual(a, b)) {
return res.sendStatus(401);
}
const event = JSON.parse(req.body.toString('utf8'));
// handle event, skipping delivery IDs already seen
res.sendStatus(200);
});GitHub publishes a test pair for checking such code: the secret It's a Secret to Everybody and the body Hello, World! give a signature beginning 757107ea.4 A failed check returns 401 with no reason.1
The signing secret is a credential. Each endpoint gets its own random secret, kept out of the repository and out of logs. After a leak, the old secret is revoked at once, because any overlap period lets forged deliveries through.41 For planned rotation, Stripe can keep the old secret valid for up to 7 days and signs with every active secret meanwhile.3 Allowing only the provider's published IP addresses can sit on top of the signature; ranges change, and a shared address does not prove who sent the request.1
Prompt for a coding agent
Find every route in this project that receives webhooks (payment providers, GitHub, Slack, messaging and form services). For each one: verify the provider signature on the raw request body before parsing it, preferably with the provider's official library; compare signatures with a constant-time function; reject deliveries whose signed timestamp is older than five minutes; store processed event IDs and skip repeats; and make the route refuse every request, or the app refuse to start, when the signing secret is not set. Return 401 on any failure. List each route, what it checked before and what you changed.
In SecFlash
SecFlash reports a route that takes payment events and never checks their signature as SF-SEC-726 on the Security page.
See also
- Securing Stripe payments
- Server-side request forgery
- JSON Web Token
- Secrets management
- Card testing
- Category: Access control
References
- a b c d e f OWASP (n.d.). "Webhook Security Cheat Sheet". OWASP Cheat Sheet Series.
- a b c d e f g Standard Webhooks (n.d.). "Standard Webhooks" specification. GitHub.
- a b c d e f Stripe (n.d.). "Receive Stripe events in your webhook endpoint". Stripe Docs.
- a b c d e GitHub (n.d.). "Validating webhook deliveries". GitHub Docs.
- a b Slack (n.d.). "Verifying requests from Slack". Slack Developer Docs.
- back PraisonAI (18 June 2026). "Webhook signature verification skipped (fail-open) when secret unset" (GHSA-x92v-rpx6-p6cw). OSV.
- back OneUptime (20 March 2026). "WhatsApp Webhook Missing Signature Verification" (CVE-2026-33143). GitHub Security Advisories.
External links
- Webhook Security Cheat Sheet, OWASP Cheat Sheet Series
- Standard Webhooks, standardwebhooks.com