Documentation Menu

Webhook signature mismatch: systematic diagnosis

A signature mismatch means the received signature and locally computed signature differ. Diagnose the signing inputs before rotating secrets or disabling verification.

The signing contract

InputMismatch examples
SecretWrong environment, endpoint, installation, or incomplete rotation.
MessageParsed JSON, changed whitespace, timestamp prefix, or wrong field order.
AlgorithmSHA-1 vs SHA-256 or a provider-specific construction.
EncodingHex vs Base64, text vs bytes, or missing prefix.
ComparisonDifferent lengths, unsafe normalization, or non-constant-time comparison.
TimestampExpired delivery or unsynchronized server clock.

Diagnosis procedure

  1. Identify the provider contract, signature header, algorithm, encoding, and timestamp rules.
  2. Confirm the header is present in the request that reached the verifier.
  3. Capture the exact raw body before any parser, decompression change, or re-serialization.
  4. Confirm the secret belongs to the same endpoint and environment.
  5. Recompute the signature using the documented construction and compare safely.
  6. Inspect the first divergent reconstruction step rather than comparing secret values in logs.
  7. Send a new provider event after correcting the input.

Do not reconstruct JSON

javascript
// Incorrect: the original byte sequence has already been lost.
const message = JSON.stringify(req.body);

// Correct: retain the raw request bytes before parsing.
const message = req.rawBody;

Secret rotation

Coordinate rotation so the sender and receiver overlap only when the provider supports multiple active secrets. Record the rotation time and test a new event. Never print full secrets or expected signatures to application logs.

Verify the fix

  • A new delivery passes verification with the intended endpoint secret.
  • The verifier uses the raw body and correct encoding.
  • Old or tampered requests fail without exposing credential material.

Was this page helpful?

Your feedback helps us improve the docs.