HMAC signing and secrets
HMAC signing lets a receiver verify that a webhook delivery really came from Webhooks Pro and that the body wasn't tampered with in transit. Optional, per-webhook, no fee.
If your receiver is on the public internet or fronted by a generic HTTPS endpoint, turn this on. Without it, anyone who learns or guesses your webhook URL can impersonate Webhooks Pro.
What you get
When you set a signing secret on a webhook:
Every outbound delivery includes the header:
X-Webhook-Signature: sha256=<hex>
<hex>is HMAC-SHA-256 over the exact bytes of the request body, keyed by the secret.The receiver computes the same HMAC with its copy of the secret and compares constant-time. Match → request is authentic. Mismatch → reject.
GET requests have no body; for those Webhooks Pro signs the empty string so the header is always present and the receiver can compute over a known input.
Set / rotate / remove the secret
On the webhook form, Security → HMAC signing secret.
Action | What you do | Effect |
|---|---|---|
Set initial secret | Type the value, Save | New deliveries are signed. |
Leave empty on existing webhook | Don't touch the field; the form shows a "Secret set" lozenge if one exists | Current secret stays. |
Rotate | Type a new value, Save | The previous secret stops working immediately. No grace period. |
Remove signing entirely | Click Remove secret | Subsequent deliveries have no signature header. |
You cannot retrieve a saved secret. The UI never displays the stored value — only a flag that one exists. Keep your own copy in a vault. If lost, rotate by entering a new value on both sides simultaneously.
Rotation procedure (zero-downtime)
There is no zero-downtime path with one secret slot per webhook. Two options:
Coordinated rotation. Tell the receiver to accept either the old or the new secret for a maintenance window, rotate in Webhooks Pro, then drop the old secret on the receiver.
Two webhooks during the window. Create a second webhook with the same URL and the new secret, switch the receiver to verify with the new secret, then delete the old webhook.
For most use cases option 1 is enough — receiver-side dual-acceptance for a few minutes is unnoticeable.
Algorithm reference
Property | Value |
|---|---|
Algorithm | HMAC-SHA-256 |
Header |
|
Format |
|
Signed bytes | Exact request body bytes as sent on the wire (the same string the delivery log stores under |
| Sign the empty string |
Encoding | UTF-8 for the body string before signing (no BOM, no normalisation) |
The signed bytes are byte-equivalent to what the delivery log shows. If you see a signature mismatch on the receiver side, the first thing to check is whether the receiver is reading the raw body — many web frameworks parse JSON before you see it, and re-serialise it differently (whitespace, key order, escape characters), which breaks HMAC.
Verifying the signature
Node.js
import { createHmac, timingSafeEqual } from 'node:crypto';
function verify(req, rawBody, secret) {
const header = req.headers['x-webhook-signature'];
if (!header) return false;
const expected = 'sha256=' + createHmac('sha256', secret).update(rawBody).digest('hex');
const a = Buffer.from(header);
const b = Buffer.from(expected);
return a.length === b.length && timingSafeEqual(a, b);
}Python
import hmac, hashlib
def verify(header, raw_body, secret):
if not header:
return False
expected = 'sha256=' + hmac.new(secret.encode(), raw_body, hashlib.sha256).hexdigest()
return hmac.compare_digest(header, expected)Go
import (
"crypto/hmac"
"crypto/sha256"
"encoding/hex"
)
func verify(header string, body []byte, secret string) bool {
if header == "" {
return false
}
mac := hmac.New(sha256.New, []byte(secret))
mac.Write(body)
expected := "sha256=" + hex.EncodeToString(mac.Sum(nil))
return hmac.Equal([]byte(header), []byte(expected))
}PHP
function verify($header, $rawBody, $secret) {
if (!$header) return false;
$expected = 'sha256=' . hash_hmac('sha256', $rawBody, $secret);
return hash_equals($expected, $header);
}Use a constant-time compare (
timingSafeEqual/compare_digest/hmac.Equal/hash_equals). A naive==compare is vulnerable to timing attacks.
Picking a secret
Length: at least 32 bytes of randomness. Use a CSPRNG, not a memorable phrase.
``bash openssl rand -hex 32 ``
Per webhook, not shared across webhooks — that way compromise of one receiver doesn't open the others.
Treat it like a password. Vault it. Don't put it in source control or chat history.
What signing does not protect
Replay attacks — an attacker who captures a signed delivery can re-send it. Webhooks Pro doesn't include a timestamp claim in the signature. If replay is in your threat model, have the receiver track delivered IDs (the
idfield in the payload) and reject duplicates.TLS-stripping — if your URL is
http://(nothttps://), the body and the header are both sent in clear. Use HTTPS.Confidentiality — HMAC proves authenticity and integrity, not secrecy. The body is still readable by anyone who intercepts it. For confidentiality, use HTTPS and a private network.
Authorisation — HMAC proves the message came from Webhooks Pro. It says nothing about what the receiver should do with it. Receiver-side authorisation is your responsibility.
What if the secret leaks
Rotate immediately:
Generate a new secret.
Configure the receiver to accept old or new for the rotation window.
Save the new secret in Webhooks Pro.
Drop the old from the receiver after the window.
If you suspect actual abuse during the window the old secret was valid, audit Webhook Logs for unexpected deliveries (there shouldn't be any, since signing is outbound-only — but check the receiver's own logs for inbound traffic that could have been forged).
Common mistakes
Mistake | Symptom | Fix |
|---|---|---|
Receiver reads parsed JSON, then re-serialises before HMAC | Mismatch on every delivery | Read raw bytes of the body before parsing. Most frameworks have a raw body hook. |
Using | Subtle timing leak; functionally works | Use the language's constant-time compare. |
Storing the same secret for multiple webhooks | One leak compromises all | One secret per webhook. |
Putting the secret in a payload template variable | Leaks into the delivery log | Use the dedicated secret field. |
Forgetting | Always mismatch | The header value includes the prefix; expected must too. |
Related
Create and edit webhooks — where the secret is set on the form.
HMAC signing details — Trust Center page summarising the same for security reviewers.
Webhook logs — the body you signed is the body the log shows.
Headers and authentication — alternative auth via static
Authorizationheader.HMAC signature mismatch on the receiver — diagnostic playbook for the most common failure mode.