Signature Verification
Cheat sheet · https://pcornel.dk/topic.php?topic=5325
Answer
Cryptographic validation that webhook bytes were signed by a trusted producer, commonly with HMAC or asymmetric signatures and replay controls.
Remember
- 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.
First checks
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
Commands
openssl dgst -sha256 -verify <public-key.pem> -signature <signature.bin> <payload.bin>- Read-only/validation observation for cryptographic signature validity for the exact payload/signature/public-key tuple.
Verify in this order
raw body + secret → HMAC → compare with header
Where it usually breaks
A valid signature proves integrity/authenticity under the configured key material; it does not prove freshness, authorization or downstream success.
Client payload/auth → HTTP transport → endpoint validation/policy → request accepted → queued/job execution → target mutation → effective state → consumer workload.
Signature Verification webhook boundary map
| 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 |
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=5325