Category: Forms and APIs

Webhook: HMAC signature does not match, although the secret is correct

Read this guide in Polish

Endpoint rejects the real webhooks from the invalid signature, and the test JSON in the console works. The signature is counted with a raw body that may differ from JSON re-seriesed by parser.

How to determine the source of the error

Check the exact input bytes of requests and signature documentation of a particular supplier.

Verify the signature header, timestamp and whether the system does not modify the content before verification.

What to do step by step

1. Verify HMAC on raw body before JSON.parse, comparing signatures in a constant time.

2 . Add protection against replay by limiting the age of timestamp and the idempotent event identifier.

How to check the score

A real event with a valid signature is accepted, and the changed body and old timestamp are rejected.

What to do

Do not disable webhook's signature on the production just to pass the events.