Replay attacks and the timestamp window
A signature only stops tampering, so replays need a timestamp window plus idempotent handling of the event ID.
Why replays work
Signature verification only establishes that the body was produced by someone holding the secret and was not altered. Sending the same request twice produces the same valid signature. An attacker who captures one request can send it again as often as they like.
Platforms with a timestamp
| Platform | Where the time lives | Recommended window |
|---|---|---|
| Stripe | t (header) | 300 s |
| Slack | X-Slack-Request-Timestamp | 300 s |
| Toss Payments | transmission-time | 300 s |
| GitHub | none | — |
| Shopify | none | — |
Because the time is part of the signed string, changing it breaks the signature. The receiver must still check how far that time is from now; skip that and an old request passes.
Choosing the window
Too narrow and network delay or clock drift rejects valid requests; too wide and the replay window grows. 300 seconds is the balance for most systems. Sync clocks with NTP and watch the rejection rate.
Before widening the window, ask what a replay would cost. Payments, inventory and permission changes need a short window and strong idempotency.
Idempotency
For GitHub and Shopify there is no timestamp, so the event ID is the only defence. Store it before processing; if it is already present, return 200 and stop. Keep the insert and the business change in one transaction so a crash cannot duplicate work.
if (seen(event_id)) return 200; // already handled begin transaction; insert into processed_events(event_id) values (:id); apply_business_change(:payload); commit; return 200;
Attack scenario
- An attacker captures a payment-succeeded webhook.
- They resend the same request a hundred times.
- Without a timestamp check all hundred pass verification.
- Without idempotency the order ships a hundred times.
Either defence reduces the damage; you need both. The timestamp stops replays after the window and idempotency stops duplicates inside it.
Move the request time in the replay tab to see the verdict inside and outside the window.
Open the signature verifierFrequently asked questions
Is signature verification alone not enough?
No. It stops forgery and tampering but not the repetition of a valid request.
What can I do without a timestamp?
Store the delivery or event ID, reject duplicates, and make the business operation idempotent.
Why not set the window to zero?
Network delay would reject valid requests. Some slack, even a few seconds, is required.
This guide follows the signing schemes published by GitHub, Stripe, Slack, Shopify and Toss Payments.
← Guides