What a webhook signature is and what it proves
A webhook signature is an HMAC computed from a shared secret and the request body; the receiver recomputes it and compares the result with the header.
What a signature stops, and what it does not
A webhook endpoint is open to the internet. Anyone can POST to that URL, so the server has to establish that the request really came from the payment, repository or messaging service. The signature is that check.
It proves two things: the sender knew the shared secret, and the body did not change in transit by a single byte.
It does not prove that the request is new. If an attacker captures a request and sends it again, the signature is still valid. Nor does it prove the body is business-correct: a validly signed amount can still be wrong for your order, so confirm amounts and status with the provider API.
How HMAC is computed
HMAC mixes a secret into a hash function in a standard way. It is not the same as concatenating the secret and body before hashing.
signature = HMAC-SHA256(key = secret, message = raw body)
HMAC pads and hashes the key twice internally, which makes it resistant to length-extension attacks. A plain SHA256(secret + body) concatenation leaves room for an attacker to append data and produce a valid digest without knowing the secret. Always use HMAC for webhook signatures.
Compare in constant time. Comparing the computed and received signatures with == can leak how many leading bytes matched through response timing. Use timingSafeEqual, compare_digest or hmac.Equal.
Hex or base64?
The same 32-byte HMAC can be rendered differently. Miss this and the computation is right while the comparison keeps failing.
| Platform | Header | Encoding |
|---|---|---|
| GitHub | X-Hub-Signature-256 | sha256= + hex |
| Stripe | Stripe-Signature | t=, v1= + hex |
| Slack | X-Slack-Signature | v0= + hex |
| Shopify | X-Shopify-Hmac-Sha256 | base64 |
| Toss Payments | tosspayments-webhook-signature | v1: + base64 |
Each platform signs a different string
The HMAC message is not always the body alone. Stripe and Slack bind a timestamp into the signature to make replay harder; Toss Payments appends the send time after the body.
| Platform | HMAC message |
|---|---|
| GitHub, Shopify, generic | raw body |
| Stripe | t + "." + raw body |
| Slack | "v0:" + timestamp + ":" + raw body |
| Toss Payments | raw body + ":" + transmission-time |
Copying example code from another platform therefore changes the computation itself. Do not decide from the header name alone; check the vendor documentation for what is signed.
Verification order
- Keep the raw body before any parsing.
- Recompute the signature with the secret and the platform rule.
- Extract the signature from the header and compare it in constant time.
- Check the timestamp window where the platform provides one.
- On failure return 401 and do not process the body.
Skip any of these and you are imitating verification rather than doing it. The most common failure by far is a framework that parsed the body before the check ran.
Computing one yourself makes the relationship between header and body obvious.
Open the signature verifierFrequently asked questions
Can I just log a signature failure and process the request anyway?
No. A request with a wrong signature is forged or altered. Reject it with 401. Processing it lets an attacker inject fake payment completions.
Where should the secret live?
In server environment variables or a secrets manager, never in source, repositories or clients. Even when computing in a browser as this tool does, the value should stay in memory only.
Is HMAC-SHA1 still acceptable?
GitHub's legacy X-Hub-Signature uses SHA-1, but new integrations should use SHA-256. SHA-1 collision resistance is no longer adequate for security use.
This guide follows the signing schemes published by GitHub, Stripe, Slack, Shopify and Toss Payments.
← Guides