Pikkola Webhook, tool No. 87

The header a webhook arrives with, and how it is checked.

GitHub signs the body, Stripe signs a timestamp and the body, Slack signs a version, a timestamp and the body. Pick one, paste the secret and the payload, and see the exact string that gets signed, the hex it produces and the comparison a handler should make.

3
provider schemes
3
hashes available
0
secrets stored

The bench

Sign it, then check a header against it

The secret stays in this tab. The signature is computed with WebCrypto, the string that was signed is shown above the result, and the verifier compares in constant time and rejects a timestamp outside the window.

A real signing secret is a credential.

Algorithm
-
Signed bytes
-
Header age
-
State
waiting

Three things a signature defends

A webhook arrives from the network with no session and no cookie. The signature is the only reason to believe it came from the service it names.

01

The body, byte for byte

The digest is over the raw bytes, not over the parsed JSON. A framework that re-serialises the body before hashing will produce a different signature for the same event, which is the most common cause of a check that fails intermittently.

02

A timestamp stops the replay

Without one, a captured request is valid forever. Stripe and Slack put the timestamp inside the signed string and expect the receiver to reject anything older than a few minutes, which is why the window here is adjustable and can be zero.

03

Comparison has to be constant time

A comparison that stops at the first wrong character leaks how much of a guess was right, one byte at a time. The verifier here compares every character and ORs the difference, which is what crypto libraries have done for decades.

What is signed, and what is compared

Each provider signs a slightly different string. Getting that string wrong is the whole failure mode, so the page prints it rather than describing it.

Part What this page does What it will not do
GitHub HMAC-SHA256 of the body, sent as sha256=hex in X-Hub-Signature-256 Verify the sha1 header: it is deprecated and offered for old integrations
Stripe HMAC-SHA256 of {timestamp}.{body}, sent as t=,v1= with more than one v1 while a secret rotates Accept a v0 signature: Stripe sends v1 now
Slack HMAC-SHA256 of v0:{timestamp}:{body}, sent as v0=hex Sign the JSON Slack sends after its own parsing: the body is form-encoded
The generic case HMAC-SHA256 or SHA-512 over the body, or over {timestamp}.{body}, hex or base64 Match a scheme you cannot describe: every service invents one
The timestamp Compared with now, and the signature rejected outside the window Trust the clock: a receiver whose clock is off rejects everything
The secret Read into memory for the HMAC and never stored Confirm that a secret is the one the provider holds. Only a signature can

A valid signature says the sender knew the secret. It does not say the event is one you want: a service that signs everything it sends will happily sign a duplicate delivery, so an idempotency key is still the receiver's job.

Field guide

Payload, timestamp, comparison

A webhook has no session and no cookie. Its signature is the only reason to believe it came from the service it names, and the three ways that check goes wrong are the bytes hashed, the time ignored and the comparison leaked.

Every provider signs a slightly different string

GitHub's X-Hub-Signature-256 is an HMAC-SHA256 over the raw request body, written as sha256= and 64 hex characters. Stripe's Stripe-Signature is an HMAC over the timestamp, a dot, and the body, sent as t=,v1= pairs. Slack's X-Slack-Signature signs v0:{timestamp}:{body} and sends only v0=. The differences look arbitrary and are not: each one was chosen to bind a different set of facts.

ProviderString signedHeader
GitHubbodyX-Hub-Signature-256: sha256=…
Stripe{t}.{body}Stripe-Signature: t=…,v1=…
Slackv0:{t}:{body}X-Slack-Signature: v0=…

The bytes, not the object

The single most common failure is a body that was parsed and re-encoded before it was hashed. JSON has many spellings of the same value: key order, whitespace, whether a slash is escaped, how a non-ASCII character is written. A framework that turns the body into an object and back produces different bytes, and the digest changes with them. The fix is to read the body as a byte string once, verify against that, and only then parse it.

This is also why the string that gets signed is printed above the result. When a server disagrees with this page, the two strings are the thing to compare, not the two digests.

Why a timestamp is in the signature

A signature over the body alone is valid as long as the body is. Anyone who can read one request, from a proxy log, a misconfigured queue or an error tracker, can send it again and the receiver will accept it. Putting a timestamp inside the signed string makes each request valid only near its own time, and the receiver enforces that by rejecting anything outside a window. Five minutes is the common value: long enough for clock drift and a slow retry, short enough that a leak is stale before it is useful.

Comparison, and the reason it is written oddly

A normal string comparison returns as soon as two characters differ. Timing that tells an attacker how many characters of a guess were right, one byte at a time, which is enough to forge a signature a byte per request. A constant-time comparison reads both values completely and combines the differences without branching, so the time does not depend on where the first difference is. Every HMAC library has one, and writing === in its place is the bug that looks like nothing.

What a valid signature still does not say

It says the sender knew the secret. It does not say the event is new, correct, or one you want. Providers retry, so the same event will arrive twice; a compromised integration signs its own bad events; and an event you handled a month ago can be delivered again by a provider repairing a queue. Verify first, then deduplicate on the event id, and treat the payload as untrusted input even after the signature passes.

When the signed thing is a token that a browser carries rather than a request body, Pikkola JWT reads it. When the signature algorithm itself is what you need, Pikkola Hash covers the digests underneath.

Questions

Is the secret sent anywhere?

No. It is imported as a WebCrypto key in this tab and the HMAC runs here; nothing is stored and nothing is logged. The only request after the page loads is the cookieless page-view count. Even so, a production signing secret is a credential and a demo page is not where it belongs.

Why does my server compute a different signature?

Almost always because the bytes differ. A framework that parses the JSON and re-encodes it changes key order, spacing and unicode escapes, and the digest changes with them. Read the raw body, keep it as bytes, and hash those. The string that gets signed is printed above the result so the two can be compared directly.

What is the timestamp for, exactly?

Replay. A signature over the body alone stays valid as long as the body does, so anyone who captures one request can send it again. Stripe and Slack put a timestamp in the signed string, and the receiver refuses anything outside a window of a few minutes. Five minutes is the usual choice.

Why show more than one v1 for Stripe?

Because Stripe rotates secrets and signs with both the old and the new for a while, sending two v1 values in one header. A receiver that checks only the first one fails the moment rotation starts. The verifier here accepts a match against any v1 in the header.

Does a valid signature mean the event is trustworthy?

It means the sender knew the secret, which is a strong statement about origin and nothing at all about content or intent. A compromised integration will sign its own bad events, and deliveries repeat. Verify the signature, then check the event id against what you have already processed.