opyeb hmaclab

hmaclab · Stripe

Stripe webhook t=/v1= signatures and the replay tolerance

The t=/v1= format, 300-second tolerance, secret rotation

Stripe sends payments, subscriptions and refunds as webhooks. The Stripe-Signature header carries a timestamp and one or more signatures.

Stripe-Signature: t=1764500000,v1=3f2a9c...

The signed message

Stripe concatenates the timestamp, a period and the raw body, then computes HMAC-SHA256. The result is placed in v1 as hexadecimal. Because the timestamp is signed, a valid signature still needs a freshness check.

signed_payload = t + "." + raw_body

Reading the header

During rotation, deliveries signed with the old secret and the new secret arrive together. That produces multiple v1 values, and any one match is enough. Stripe's official libraries implement this in constructEvent.

Replay tolerance

The official libraries default to a 300-second tolerance. If the difference between now and t is larger, the request is rejected even when the signature matches. Check NTP synchronisation, or valid requests will fail when the server clock drifts.

DifferenceVerdictAction
0–300 sWithin toleranceProcess when the signature matches
Over 300 sPossible replayReject with 400 and log
Future timestampCheck clock skewReject when outside tolerance

Common mistakes

Stripe can deliver the same event more than once. Even after signature verification, deduplicate by event.id.

Questions

What do I do with several v1 values?

Compare each in constant time and pass when any matches. Old and new secrets coexist during rotation.

Where does 300 seconds come from?

It is the default tolerance in Stripe's official libraries. With an accurate server clock it is a safe default.

Are test-mode webhooks signed?

Yes, with that mode's secret. When forwarding with the Stripe CLI, use the secret the CLI prints.

Paste a Stripe header and check the tolerance too.

Open the tool

This guide follows the HMAC definition in RFC 2104 and the public webhook documentation of GitHub, Slack and Stripe. Every example value is synthetic.