A webhook URL is public. Anyone who learns it can POST to it, so a receiver that acts on whatever arrives can be fed fake orders, fake payments or fake alerts. A signature lets the receiver check that a request came from the sender and was not changed on the way.
How a webhook signature works
Almost every provider uses the same idea, an HMAC:
- The sender and receiver share a secret, set up once.
- For each request, the sender computes
HMAC-SHA256(secret, signed content)and puts the result in a header. - The receiver computes the same HMAC from the request it got and compares. A match means the request was made by someone who holds the secret, and the signed content was not changed.
What the “signed content” is, and how the result is written, is where providers differ:
| Provider | Header | Signed content | Written as |
|---|---|---|---|
| Stripe | Stripe-Signature | <timestamp>.<body> | t=…,v1=<hex> |
| GitHub | X-Hub-Signature-256 | the body | sha256=<hex> |
| Shopify | X-Shopify-Hmac-Sha256 | the body | base64 |
| Slack | X-Slack-Signature | v0:<timestamp>:<body> | v0=<hex> |
| Standard Webhooks, Svix | webhook-signature | <id>.<timestamp>.<body> | v1,<base64> |
Five rules for verifying correctly
- Use the raw body. The signature covers the exact bytes sent. If your framework parses the JSON and you re-serialise it, spacing or key order can change and a genuine request fails. Read the raw body for the check, and parse it afterwards.
- Compare in constant time. An ordinary string comparison stops at the first different character, and the time that takes can leak how much of a forged signature was right. Use your language’s constant-time comparison, such as
crypto.timingSafeEqualin Node. - Check the timestamp when there is one. A valid request captured once stays valid forever unless it is dated. When the signature covers a timestamp, refuse one too far from now. Five minutes is the common window.
- Refuse before you store. Answer 401 to a missing or wrong signature, and do nothing else with the request.
- Accept two secrets during a rotation. When a secret changes, there is a window where requests signed with the old one are still in flight. Accept either during that window, then drop the old one.
Verify an HMAC signature in Node
This checks a GitHub-style sha256=<hex> header with no dependencies:
import crypto from "node:crypto";
export function verify(rawBody, header, secret) {
const value = header?.trim();
if (!value || !value.startsWith("sha256=")) return false;
const given = value.slice("sha256=".length).toLowerCase();
const expected = crypto.createHmac("sha256", secret).update(rawBody).digest("hex");
return Buffer.byteLength(given) === expected.length &&
crypto.timingSafeEqual(Buffer.from(given), Buffer.from(expected));
}
Every integration page carries the matching check for that provider, and each one is tested against Hookie’s own verifier.
How Hookie verifies what it receives
Set an endpoint’s Signature verification to the sender’s scheme and paste its secret. Hookie supports Stripe, GitHub, Shopify, Slack, Standard Webhooks (Svix included) and a custom HMAC with your choice of header, SHA-256 or SHA-1, hex or base64, and prefix. Then:
- The check runs before anything is stored or counted against your quota. A missing, forged or stale signature gets a
401. - For schemes that sign a timestamp (Stripe, Slack and Standard Webhooks), the default window is 5 minutes. You can set it from 30 seconds to 24 hours.
- Secrets are stored encrypted and never shown again.
- Rotating a secret keeps the old one valid for an overlap you choose, from none to 30 days (a day by default), so nothing is refused while the sender switches over.
How your service verifies what Hookie sends
Every delivery Hookie makes to an HTTPS destination is signed with that destination’s own secret (whsec_…), in two forms:
Hookie-Signature: t=<timestamp>,v1=<hex HMAC-SHA256 of "<t>.<body>">, the same format as Stripe’s.- The Standard Webhooks headers
webhook-id,webhook-timestampandwebhook-signature, so any Standard Webhooks library can verify it.
During a rotation of a destination’s secret, both headers carry a signature for each secret, so a receiver holding either one accepts the request. For what to do when a delivery fails or arrives twice, see the retries guide.