Skip to content
BENIBIX Learn

Webhook Signature

Development🔌 APIsAPI Design Practices

Also known as Webhook Verification, HMAC Signature, Signed Webhook, X-Hub-Signature-256

A code sent with a webhook that proves who sent it and that nothing changed.

Think of it like

Think of it like a wax seal on a letter. If the seal matches, you know who sent it and nobody opened it.

Example

GitHub puts its signature in a header called X-Hub-Signature-256. It starts with sha256=. Lucy's server checks it before it trusts the event.

Why it matters

A webhook URL is public. Without a check, anyone could send your server fake events.

Definition

A webhook signature proves a webhook really came from the service you expect. The sender and you share a secret key. The sender mixes the message with the secret to make a signature, usually with HMAC SHA-256. You make your own signature the same way and compare. If they match, the message is real and unchanged.
Both sides make the signature. If they match, the message is real.

Common mistake

Checking the match with a plain string compare. Use a compare that takes the same time each try, so time gives no clues.

Key takeaways

  1. 1
    Shared secret. Only you and the sender know it.
  2. 2
    Make your own. Compute it and compare.
  3. 3
    Drop bad ones. No match means not trusted.