Pcornel
Automation · Webhooks

Signature Verification

Cheat sheet · https://pcornel.dk/topic.php?topic=5325

Back to the Topic

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

BoundaryHealthy evidenceSuspicious evidence
Source / deliveryEvent, subscription, delivery ID and attempt metadata are attributableMissing source event, stale subscription, wrong callback or delivery history gap
Trust / acknowledgementAuth/signature and schema checks occur before safe acknowledgementUnverified payload, slow handler, 2xx before durable receipt or replay weakness
Processing / proofDurable dedupe/worker evidence matches downstream target stateDuplicate side effect, worker failure hidden by 2xx or no target reconciliation
TroubleshootingFirst failed boundary is preserved, changed minimally and retestedBlind 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

Confirmation

Confirm action

Continue?