Home Blockchain Replay Attack in Blockchain Networks and Nodes

Replay Attack in Blockchain Networks and Nodes

by ImmuneBytes


A replay attack is a type of malicious activity where an attacker intercepts and retransmits a valid transaction or message from one blockchain network onto another, causing unwanted or unauthorized actions to occur.

This type of attack can have serious consequences, particularly in blockchain systems that don’t have proper countermeasures in place.

How does the attack work?

Blockchain Fork: Suppose there’s a blockchain network that undergoes a hard fork or network upgrade, resulting in two separate but related chains. These two chains share the same transaction history up to a certain point.

Attacker’s Strategy: The attacker takes advantage of this situation by capturing a legitimate transaction on one of the chains, such as the original chain before the fork, and retransmits it to the other chain, which might not recognize the replayed transaction as invalid. This means the transaction is duplicated on both chains.

Unintended Consequences: This duplicated transaction could lead to unintended consequences depending on the specific blockchain and its rules. For example, the recipient of funds could receive the same amount on both chains or, in more serious cases, the attacker could cause the recipient to lose assets or privileges they didn’t intend to use.

To protect against replay attacks, blockchain developers and users implement various measures, such as using replay protection mechanisms, which are designed to prevent transactions from being valid on both chains after a hard fork.

These mechanisms often involve introducing unique identifiers or timestamps into transactions or making other changes to the protocol that ensure transactions are only valid on the intended chain.

The Attack

An example of a replay attack in the context of a simple blockchain-based voting system:

Suppose there’s a blockchain-based voting system where eligible voters send their votes as transactions to a smart contract on the blockchain. Each vote is a transaction that includes the voter’s address and the chosen candidate’s name. The contract records these votes on the blockchain.

Example Flow of a Replay Attack

Legitimate Vote: Voter A casts their vote by sending a transaction to the smart contract with their address and candidate choice, let’s say “Candidate X.”

Replay Attack: An attacker intercepts Voter A’s transaction on the blockchain, which is publicly visible.

The attacker saves a copy of Voter A’s transaction details, including the sender’s address and the chosen candidate.

Replay: At a later time, after Voter A’s vote has been successfully recorded, the attacker resends the same transaction (with the same details) to the smart contract.

Result: The smart contract receives the replayed transaction and, without proper protection mechanisms, accepts it as a valid vote.

This results in an additional vote for “Candidate X,” even though Voter A already voted for that candidate.

In this scenario, the attacker was able to replay the original vote, causing an unfair duplication of votes for “Candidate X.” This is a basic example, and in a real-world blockchain system, there would be measures in place to prevent or detect replay attacks, as mentioned in the previous response.


To remediate replay attacks in blockchain networks, several strategies and mechanisms can be employed:

  1. Nonce and Sequence Numbers: Many blockchains use nonces or sequence numbers to ensure that each transaction is unique. Nonces are incremented with each transaction, making it impossible to replay the same transaction. Ethereum, for example, uses nonces to prevent replay attacks.
  2. Time-Stamping: Timestamps can be included in transactions to ensure that they are only valid for a limited period. This prevents attackers from broadcasting the same transaction at a later time.
  3. Use of Unique Identifiers: Including unique identifiers or random values in each transaction can prevent replay attacks. These values can be checked by the network to ensure that a transaction is not a replay.
  4. Smart Contracts: Smart contracts can be used to prevent replay attacks by including conditions that make the transaction valid only under certain circumstances or within a specific time frame.
  5. Tokenization: Some blockchain networks implement tokenization, where a specific token is required for each transaction. This token can only be used once, preventing replay attacks.
  6. Multi-Signature Transactions: Requiring multiple signatures from different parties for a transaction can also mitigate replay attacks. This makes it more difficult for an attacker to replicate a transaction.
  7. Off-Chain Solutions: Some off-chain solutions, such as the Lightning Network for Bitcoin, use a different protocol to facilitate fast and inexpensive transactions off the blockchain. These solutions are designed with replay attack prevention in mind.
  8. Private Keys and Encryption: Ensuring the security of private keys and using encryption can prevent attackers from gaining access to transaction data that they could replay.
  9. Fork Choice Rules: In some blockchain networks, replay protection may be provided by fork choice rules during hard forks. These rules help differentiate between the old and new chain after a fork, making it harder for attackers to replay transactions on both chains.
  10. Educating Users: It’s important to educate users about the risks of replay attacks and best practices for avoiding them, such as using wallets and applications that implement replay protection measures.

Case Study: Real-world Examples of Replay Attacks

Here are some cases of Replay Attacks. Most of the attacks happen during the early days of cryptocurrencies.

Ethereum Classic hard fork

In the year 2016, Ethereum was hacked, and the community decided to vote for a hard fork.

The new chain kept the original name Ethereum (ETH) and focused on improving efficiency and scalability with the Proof of Stake mechanism, while the old chain was named Ethereum Classic (ETC) and still had the Proof of Work mechanism. The structure of both chains are the same, therefore, a valid transaction on Ethereum was also valid on Ethereum Classic and vice versa.

At the time, most people thought Ethereum Classic would no longer be active, and did not pay attention to the possibility of replay attacks on both chains. Then miners who were keeping the ETC network running started to notice that transactions on Ethereum could be replayed on Ethereum Classic.

Exchanges did not find out at the time the Ethereum hard fork took place, that when a user withdraws ETH from the platform, they may receive the same amount of ETC. Many people took advantage of this error to repeatedly deposit and withdraw ETH on exchanges to get extra ETC. Finally, some exchanges such as Yunbi and BTC-e announced the emergence of replay attacks on their platforms, causing almost all ETC to be lost.

Bitcoin Cash hard fork

The case of Bitcoin Cash (BCH) and Bitcoin (BTC) was the same. After the hard fork took place in August, 2017, with just 1 BTC, a user would have 1 BTC and an additional 1 BCH. Moreover, the transaction history also showed some cases where replay attacks caused users who made transactions with BTC also lost their BCH.

This was due to transactions being valid on both chains. Hackers followed transactions on one chain, then duplicated them on the other chain. Therefore, making transactions on Bitcoin would cause assets on Bitcoin Cash to be lost.

You may also like