Table of Contents
A replay attack occurs when a system accepts a previously valid message a second time. Imagine a service that accepts an approved order request. If receiving that same request again creates a second order, the service needs a way to recognize duplicate requests. Encryption and signatures each help protect a message, but the receiver also needs to check whether it is fresh and has already been processed.

Why replay protection matters

Authentication messages, payment requests, device commands, and webhook events can have side effects when accepted more than once. An unchanged copy can still carry a valid signature. Routine network retries can also deliver the same operation more than once, so duplicate handling protects against both mistakes and malicious reuse.
How to prevent replay attacks

- Use a one-time challenge for authentication. Issue an unpredictable nonce, bind the response to that challenge and the intended operation, and expire or mark the challenge used after acceptance.
- Authenticate timestamps. Include the timestamp in the signed data, check it against a short acceptance window, and keep clocks synchronized. A timestamp alone still allows duplicates during that window.
- Track processed IDs. For webhooks, record authenticated event IDs so repeat deliveries cannot trigger a second action. For APIs, use idempotency keys scoped to the client and operation. Store the outcome atomically so simultaneous requests cannot both apply a change.
- Use current transport security. Protect traffic with HTTPS. Check your infrastructure’s TLS 1.3 early-data policy and keep state-changing operations out of 0-RTT unless the application is designed to handle replay safely.
Verify the behavior from the receiver’s side
In automated tests for your own application, check that a repeat delivery has no second effect, an expired request is rejected, and two concurrent deliveries result in one state change. Check legitimate retries too. For example, a webhook receiver may acknowledge a delivery it already handled so the publisher can stop retrying.
For signed events, see the OWASP webhook security guidance. For the web address and transport context, see the guide to URLs and HTTPS.
Reader Comments 0
Sign in with email or Google to join the discussion.