Halborn Logo

// Blog

Explained: Hacks

Explained: The MEV Bots Hack (April 2023)


profile

Rob Behnke

April 12th, 2023


Normally, MEV bots are the ones who are executing frontrunning attacks to steal from other blockchain users. However, in April 2023, MEV bots were exploited by an Ethereum validator for $25 million.

Inside the Attack

MEV bots work by identifying opportunities where frontrunning a pending transaction can provide value to the bot operator. For example, if a transaction taking advantage of an arbitrage opportunity is published to the blockchain’s public mempool — a necessary step to be included in a block — an MEV bot can copy the transaction and pay for their transaction to be included in a block and processed first, providing them with guaranteed profit.

To protect against being frontrun themselves, MEV bots may use MEV relays, which implement separation of duties. Proposers bid on transactions, builders create blocks containing the most valuable transactions, and validators approve and sign the transaction. Normally, proposers can’t see the block’s contents until after they’ve signed the block header, making it difficult to frontrun the transactions in the block.

In this case, a proposer became a validator as well by staking 32 ETH, which allowed them to reorder transactions. To identify transactions to exploit, the validator sent a signed, invalid block to mev-boot-relay, which replied with the transactions that should have been included in that block. Since the block was invalid, the relay didn’t send it on to the network.

With access to the intended contents of the block, the malicious validator was able to perform a sandwich attack. This involves creating two transactions that “sandwich” a third and provide a guaranteed profit to the attacker. 

For example, an attack might look like this:

  • Attacker performs a buy for a token, pushing the price up

  • Target performs the same buy, pushing the price up further

  • Attacker performs a sell at a higher price, making a profit

In this case, the attacker was able to deconstruct the block and create a new version that allowed them to claim $25 million in liquidity that the MEV bots who were included in that block had planned to claim for themselves.

Lessons Learned From the Attack

MEV relays are designed to protect against frontrunning attacks. The reason for this is that most of their users are frontrunners, who are well aware of the potential risks.

This attacker exploited a vulnerability in how mev-boost-relay worked, causing it to reveal the contents of blocks that would never reach the network. After an update, the relay will only reveal block contents if the block is successfully sent to the network and builds in a delay for good measure.