Use it when designing, operating or troubleshooting the webhook boundary around Signature Verification. Keep producer event, delivery identity, source verification, acknowledgement, durable processing and downstream state separate.
Signature Verification
Cryptographic validation that webhook bytes were signed by a trusted producer, commonly with HMAC or asymmetric signatures and replay controls.
1. Verify HMAC signatures over the raw body.
2. Compare in constant time.
3. Check timestamp to prevent replay.
4. Use the exact raw bytes (no re-serialisation).
5. Reject mismatches.
raw body + secret → HMAC → compare with header
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
openssl dgst -sha256 -verify <public-key.pem> -signature <signature.bin> <payload.bin>Primary Commands
Configuration and operational commands for this Topic.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Operational evidence path Verify boundary
raw request bytes + signed metadata → key/secret selection → signature computation/verification → freshness/replay check → payload parse → processing
Healthy evidence: raw-byte verification, freshness checks and key rotation are deterministic and invalid signatures are rejected before side effects.
Step 2 Command read-back and what it shows Verify boundary
openssl dgst -sha256 -verify <public-key.pem> -signature <signature.bin> <payload.bin> is the bounded verification surface selected for Webhooks → Signature Verification. A known-good result is the signature over the exact received bytes validates with the expected active key/algorithm, freshness/replay checks pass and only then is the event routed to the intended handler. Treat missing/invalid signature, wrong key/algorithm/canonicalization, stale timestamp/replayed nonce or processing that occurs before authenticity/freshness is established as broken/suspicious. The OpenSSL signature check shows cryptographic validity for the supplied bytes/key/signature, but it does not show sender authorization beyond key possession, freshness or semantic safety of the event.
Step 3 Failure modes and next checks Narrow the fault
Suspicious evidence: verification after parsing/re-serialization, no replay window, timing-unsafe compare, secret mismatch during rotation or invalid event processed anyway.
Step 4 Observation-driven branch and next-check logic Narrow the fault
For a failing Webhooks → Signature Verification case, freeze scope first: target/object, desired revision or request, and failure time. Inspect openssl dgst -sha256 -verify <public-key.pem> -signature <signature.bin> <payload.bin>. Branch on evidence rather than labels: if signature is missing/malformed, reject before handler execution; if signature mismatch, compare raw bytes, algorithm, key version and canonicalization; if signature verifies but timestamp/nonce is stale/replayed, reject on freshness before processing event semantics.
Step 5 Common mistakes Narrow the fault
- Comparing signatures with normal string equality (timing attacks).
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- Signature matches ≠ event fresh; captured valid requests can be replayed without timestamp/nonce controls.
- Parsed payload reserialized ≠ original signed bytes; whitespace/order changes can invalidate verification.
- Shared HMAC secret ≠ public attribution; both holder and verifier can compute the same MAC.
- Valid signature ≠ event authorized for every downstream action; consumer policy still applies.
python3 -c "import hmac,hashlib;print(hmac.new(b'secret',open('body','rb').read(),hashlib.sha256).hexdigest())"— compute HMAC- Constant-time comparison — timing safety
- Timestamp tolerance (replay window) — replay protection
ReferenceHow it works1 section · depth on demand
How it works
In Webhooks → Signature Verification, effective state is split across the raw request bytes, sender identity/key, signature algorithm/header format, freshness/replay fields and secret/public-key version used to authenticate an inbound webhook. Signature verification reconstructs the exact signed payload according to provider rules and compares the received signature using a shared secret or public key before the event is trusted or dispatched. TLS transport, secret rotation, clock skew, proxy body transformations, encoding and replay storage are separate things to check. This matters because valid TLS does not authenticate the webhook payload itself, and recomputing a signature over parsed/re-serialized JSON can fail even when the original raw-body signature was valid.
ReferenceImportant terms & boundaries2 sections · depth on demand
What this shows and what it does not
A valid signature shows integrity/authenticity under the configured key material, but it does not show freshness, authorization or downstream success.
In depth
Signature verification checks an HMAC of the webhook body, computed with a shared secret, against the signature header the producer sent. A match proves the payload came from someone who knows the secret and was not changed in transit.
import hmac, hashlib
def valid(raw_body: bytes, header: str, secret: bytes) -> bool:
expected = "sha256=" + hmac.new(secret, raw_body, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, header)
# GitHub sends the header X-Hub-Signature-256
| Pitfall | Effect |
|---|---|
| Verifying parsed/re-serialised JSON | Signature never matches |
Using == instead of constant-time compare | Timing attack risk |
| Ignoring timestamp header | Replay possible |
| Wrong secret per environment | All deliveries rejected |
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Webhooks > Signature Verification. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://docs.github.com/en/webhooks/using-webhooks/validating-webhook-deliveries · confidence 94%Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.
Quick lookup tables
Signature Verification webhook boundary map
Fast request/delivery, trust, processing and verification boundaries for Signature Verification.
| Boundary | Healthy evidence | Suspicious evidence |
|---|---|---|
| Source / delivery | Event, subscription, delivery ID and attempt metadata are attributable | Missing source event, stale subscription, wrong callback or delivery history gap |
| Trust / acknowledgement | Auth/signature and schema checks occur before safe acknowledgement | Unverified payload, slow handler, 2xx before durable receipt or replay weakness |
| Processing / proof | Durable dedupe/worker evidence matches downstream target state | Duplicate side effect, worker failure hidden by 2xx or no target reconciliation |
| Troubleshooting | First failed boundary is preserved, changed minimally and retested | Blind retries, credential rotation, replay or payload edits before evidence is captured |