A replay attack is an attack in which an adversary captures a legitimate message — such as a login response, a session token or a key fob code — and resends it later to impersonate the original sender or repeat an authorized action. The message is genuine, so encryption alone does not stop it; systems prevent replay with nonces, timestamps, sequence numbers and short-lived session keys.
Key takeaways
- A replayed message is genuine, not forged — so authenticity checks alone cannot stop replay attacks.
- The defense is freshness: nonces, timestamps, sequence numbers and session keys that make each message single-use.
- Replay attacks hit logins, APIs, payment systems, car key fobs and industrial controls alike.
Most attacks need to break something: a password, an encryption key, a firewall rule. A replay attack breaks nothing. It records a message that was already accepted once, then plays it back later — and a system that checks only whether a message is genuine will accept it again.
What is a replay attack?
A replay attack is an attack in which an adversary captures a legitimate message and retransmits it later to impersonate the original sender or repeat an authorized action. NIST defines it as replaying previously captured messages between a legitimate claimant and a verifier to masquerade as one of them, as set out in NIST SP 800-53 Rev. 5 and SP 800-63-4.
The key point is that the message is real. It was properly signed, properly encrypted, and properly authorized the first time. The attacker does not need to forge anything or know any secret. They only need a copy of the message and a receiver that cannot tell a fresh message from a used one.
That makes replay attacks a freshness problem, not an authenticity problem. A signature proves a message came from the right sender. It says nothing about whether the message should still be accepted now, in this session, for this action. NIST calls the missing property "replay resistance": protection against the capture of transmitted authentication information and its later retransmission to gain unauthorized access.
How does a replay attack work?
A replay attack follows three steps: capture a valid message, store it, and resend it later at a moment of the attacker's choosing. If the receiver checks only validity and not freshness, the replay succeeds.
Capture can happen in many places. On a network, an attacker records traffic. In software, a token can be copied from logs, browser storage or a leaked database. In the physical world, a radio receiver records a key fob signal. The common thread is that a valid authorization artifact ends up somewhere the attacker can read it.
The delay is part of the danger. A replayed login may arrive weeks after the original, when nobody connects it to the first use. A replayed payment may arrive after the original was already processed, so the duplicate looks like a second, legitimate transaction.
Replay also works across contexts. A signed message meant for one network, one session or one recipient can be replayed on another if the message does not name its intended context. Blockchain systems learned this the hard way: a transaction signed for one chain can be valid on a forked chain unless a chain identifier is included.
What are the main types of replay attacks?
Replay attacks show up wherever a valid message is treated as reusable. The shape changes with the target, but the flaw is always the same: no check that the message is fresh.
Authentication replay
An attacker captures a login response, a session token or a SAML assertion and presents it again to sign in as the victim. This is the classic case NIST describes: a captured message between claimant and verifier, replayed to masquerade as the claimant.
API and payment replay
An attacker replays a captured API request to repeat a transfer, a purchase or a state change. Financial systems defend this with idempotency keys: the server records the key of each processed request and drops any duplicate.
Wireless and key fob replay
An attacker records the radio code a key fob sends to a car or a garage door, then transmits it later. Fixed codes are trivially replayable, which is why rolling codes were introduced — each press sends a new code, and old codes should be rejected.
Industrial and OT replay
In operational technology, an attacker replays a captured control command, such as an instruction to open a valve or change a setpoint. Many industrial protocols were designed without authentication at all, so a replayed command is indistinguishable from a real one.
Blockchain transaction replay
After a chain splits, a transaction signed on one chain can be replayed on the other, moving funds twice. Modern chains include a chain identifier in the signed data so a transaction is only valid on its intended chain.
Replay attack vs man-in-the-middle vs spoofing
These attacks are often confused because they all involve someone else's traffic. The difference is what the attacker does with it.
| Replay attack | Man-in-the-middle | Spoofing | |
|---|---|---|---|
| What the attacker does | Records a real message, resends it later | Sits between two parties, reads or alters live traffic | Fakes the sender's identity |
| Message | Genuine, unchanged | May be altered in transit | Forged from scratch |
| Timing | Delayed, after the original | Real time | Any time |
| Needs to know secrets? | No | Often no, if traffic is unencrypted | No, but needs a convincing fake |
| Main defense | Freshness: nonces, timestamps, sequence numbers | Encryption and mutual authentication | Authentication, DMARC, SPF and DKIM for email |
A replay attack can be part of a man-in-the-middle attack, but it does not need one. The attacker only needs one copy of one valid message, captured once, at any point in the past.
What are real examples of replay attacks?
The clearest public example is Rolling-PWN, a replay attack against Honda keyless entry disclosed in 2022. It shows how a mechanism designed to stop replay can still fail.
Rolling-PWN: Honda key fobs, 2022
Security researchers Kevin2600 and Wesley Li of Star-V Lab found that Honda's rolling-code system, which is supposed to reject old key fob codes, could be resynchronized. By sending lock and unlock commands in a consecutive sequence, they made the car accept codes from a previous cycle that should have been invalid.
With a software-defined radio, an attacker could capture the owner's codes, then replay them later to unlock the car and start the engine. The researchers tested the attack on ten popular Honda models from 2012 to 2022, including the Civic 2012, Accord 2020 and Fit 2022, and said it could affect all Honda vehicles using the system. The flaw was tracked as CVE-2021-46145.
The attack could not drive the car away, because the key fob needs to be nearby for that, but unlocking and starting a car is damaging enough. Honda initially questioned whether the report was credible. The lesson for manufacturers is that a rolling code only works if the counter can never be rolled back.
Bluetooth replay against Tesla, 2022
The same year, researchers demonstrated a Bluetooth replay attack against some Tesla vehicles, capturing the phone-key signal and replaying it to unlock the car. TechCrunch's coverage of Rolling-PWN noted the parallel: in both cases, a valid signal recorded once was accepted again because the system did not bind it to a single use.
Older fixed-code garage door openers and car alarms had the same flaw by design: every press sent the same code, so anyone with a radio recorder owned the door. Rolling codes fixed the design — when implemented correctly.
How do you prevent replay attacks?
Prevention always needs two things at once: the message must be genuine, and it must be fresh. A signature proves the first; only freshness mechanisms prove the second. A signed old message is still a signed old message.
| Defense | How it works | Where you see it |
|---|---|---|
| Nonce | Random value used once, bound to the reply | Login challenges, OAuth, SAML |
| Timestamp | Message valid only inside a short window | Kerberos, API request signing |
| Sequence number | Monotonically increasing counter, duplicates rejected | TLS records, IPsec, TCP |
| Session keys | New keys per connection make old messages unusable | TLS, SSH, VPNs |
| Idempotency key | Server records processed IDs, drops repeats | Payment APIs, order processing |
For developers, the rules are concrete. Never accept an authentication assertion twice: store assertion IDs in a short-lived cache and reject duplicates. Bind every signed message to its context — the session, the recipient, the chain, the purpose — so it cannot be replayed somewhere else. Keep token lifetimes short, and use refresh tokens that rotate on every use.
For everyone else, the defenses are mostly built in: TLS, modern authentication protocols and up-to-date apps already include sequence numbers and session keys. Your job is to keep them enabled and updated.
Our guide to TCP explains how sequence numbers work at the transport layer.
Our small business cybersecurity checklist covers the wider basics.
How do you detect a replay attack?
Replay attacks are hard to spot because the message is valid. Detection relies on looking for duplicates and for actions that do not match any real user behavior.
- Duplicate message IDs. Log every authentication assertion ID, token ID and request ID. A second appearance of the same ID is a replay attempt, not a coincidence.
- Impossible timing. The same session token used from two locations at once, or a login seconds after the original from a different device, is a strong signal.
- Repeated commands without cause. A control command that fires twice with no matching operator action, or a payment that appears twice with identical details, deserves investigation.
- Sequence gaps. In protocols with sequence numbers, a sudden jump backward or a repeated number is evidence of replay.
- Anomaly detection. An intrusion detection system that understands the protocol can flag repeated payloads that a generic log review would miss.
Keep logs long enough to compare. A replay may arrive days after the original, so a log retention window of a few hours will miss it entirely.
What should you do if you suspect a replay attack?
Act as if the credential or token is compromised, because for practical purposes it is: the attacker holds a working copy of it.
- Revoke the affected tokens and sessions. Force re-authentication for the affected accounts and invalidate session tokens.
- Rotate the secrets. Change passwords, API keys and shared secrets that the replayed message relied on.
- Check for duplicate effects. Look for double charges, repeated commands and actions that happened twice.
- Preserve the evidence. Keep the original and the replayed messages, with timestamps, before you rotate anything. They show which freshness check failed.
- Fix the freshness gap. Add the missing nonce, timestamp, sequence check or idempotency key, and test that a replay is now rejected.
If money moved, contact your bank immediately and report the fraud. In the US, losses can also be reported to the FBI's Internet Crime Complaint Center. The spear phishing playbook in our spear phishing guide covers the same first-response steps for stolen credentials.
The bottom line
A replay attack is a reminder that a valid message is not the same as a fresh message. Encryption and signatures prove who sent something; they never prove it should be accepted again.
Whether you build software or just use it, the question to ask is the same: what stops this message from being used twice? If the answer is nothing, a replay attack is only a matter of someone recording it. Check your own session tokens safely with our free JWT decoder to see what expiry and claims your tokens actually carry.
Frequently asked questions
What is a replay attack in simple terms?
A replay attack is when an attacker records a real, valid message — like a login or an unlock command — and sends the same message again later. The receiving system cannot tell the copy from the original, so it carries out the action a second time.
Does encryption prevent replay attacks?
No, not on its own. Encryption stops an attacker reading or changing a message, but a captured encrypted message can still be replayed. The system also needs freshness checks such as nonces, timestamps or sequence numbers.
What is the difference between a replay attack and a man-in-the-middle attack?
A man-in-the-middle attack intercepts live traffic and can read or alter it in real time. A replay attack captures a message and resends it later, often without ever altering it. Replay is simpler and needs no ongoing position in the middle.
What is a nonce and how does it stop replay attacks?
A nonce is a number used once. The receiver generates a fresh random challenge for each session and the sender must include it in its signed reply. A replayed reply carries an old nonce, so the receiver rejects it.
Can replay attacks steal money?
Yes. Replaying a payment request can cause a double charge, and replaying a signed transaction on another network can move funds a second time. Payment systems use idempotency keys and unique transaction IDs to reject duplicates.
What is the Rolling-PWN attack on Honda cars?
Rolling-PWN is a replay attack on Honda keyless entry, disclosed in 2022. Researchers found the car's rolling-code counter could be resynchronized, so old key fob codes were accepted again. It was tracked as CVE-2021-46145.
How do you detect a replay attack?
Look for duplicate messages, identical payloads arriving twice, logins from the same token at odd times, and commands repeated without a matching user action. Logging message IDs and sequence numbers makes duplicates visible.
Sources
The engineers and analysts who build Cysoro's domain scanner, email-authentication checks and free security tools. We test what we write about every day — SPF, DKIM, DMARC, certificates, look-alike domains and phishing — and check each guide against the relevant standards, government guidance and vendor documentation.
Checked against the NIST CSRC glossary definitions of replay attack and replay resistance, and the published Rolling-PWN research.
How we write and fact-check →