Front-running: how traders profit from other people's cryptocurrency transactions
A blockchain is an open database where anyone can view and verify transaction information. Moreover, blockchains make it possible to track not only information that has already been recorded but also data about transactions that have yet to be confirmed and published.
This feature of blockchain technology creates opportunities for various attacks, including front-running.
What is front-running in cryptocurrency?
Front-running is a form of transaction manipulation in which an attacker monitors pending transactions in the blockchain's mempool and submits a similar transaction with a higher fee to have it processed before the victim's transaction.
Crypto front-running is a type of MEV attack. MEV (Maximal Extractable Value) attacks are techniques used to generate additional profit by influencing the order in which transactions are processed on a blockchain. Malicious actors or other network participants exploit the ability to change the sequence in which transactions are included in a block, delay them, or exclude them entirely to gain financial benefits at the expense of other users.
The consequences of front-running can directly affect users' financial results. In particular, when carrying out transactions, they may encounter the following problems:
- Worse trade execution prices. During a front-running attack, the attacker gets ahead of the original transaction and changes market conditions. As a result, the user's trade is executed at a less favorable exchange rate than expected, leading to financial losses.
- Additional transaction fees. To get ahead of another transaction, an attacker may set a higher fee. This affects transaction processing priority and may force the user to increase the fee on their own transaction to prevent delays in the network.
How does front-running work in cryptocurrency?
In a front-running attack, an attacker uses specialized software, such as MEV bots, to scan the public mempool and identify transactions that could be targeted. Transactions involving cryptocurrency swaps on decentralized exchanges (DEXs) are among the most common targets.
Attackers can see not only that a transaction has appeared in the mempool but also the information it contains:
- The assets involved in the swap;
- The transaction amount;
- The swap conditions and expected execution price;
- The transaction fee set by the sender.
Using this information, an MEV bot estimates the potential profit. If the transaction presents an opportunity, it initiates a front-running attack by submitting its own transaction with a higher fee to ensure that it is included in a block before the user's original transaction.
The attacker uses front-running to buy the required asset in advance at a more favorable price and then waits for the user's transaction to be executed. Since the attacker's transaction has already changed market conditions, the user is forced to purchase the asset at a less favorable rate. The attacker then sells the acquired assets and profits from the price difference.
This front-running strategy allows attackers to profit from other people's trades, effectively shifting the financial losses onto users.
For example, one common application of front-running involves launching liquidity pools for new tokens with relatively low market capitalization. Due to their limited liquidity, newly launched tokens are initially highly volatile. This means their prices can change by tens or even hundreds of percent in just a few seconds.
MEV bots using front-running can buy up all the available liquidity of a new token within milliseconds before a large transaction is executed. As a result, an unsuspecting investor ends up purchasing tokens at a significantly inflated price compared with the price available when the original transaction was submitted.
Types of front-running
There are three main types of front-running in cryptocurrency:
- Displacement — the victim's transaction loses priority and is confirmed later, at a less favorable price.
- Insertion (suppression) — the attacker uses a stream of higher-fee transactions to prevent the victim's transaction from being included in the current block. This type of front-running allows attackers to delay a trade significantly.
- Sandwich attack — a type of crypto front-running in which the victim's transaction is sandwiched between two orders placed by the attacker. The attacker first buys the asset before the target transaction and then sells it afterward at an inflated price.
Risks of front-running in cryptocurrency
According to available statistics, crypto front-running attacks most commonly target trading transactions. Losses from such attacks can reach hundreds of thousands of US dollars.
For example, in March 2025, a trader lost more than $200,000 due to front-running while swapping USDT for USDC on the decentralized exchange Uniswap. The attack was made possible because the trader had set an excessively high slippage* tolerance when exchanging the stablecoins.
* Slippage is the difference between the expected trade price and the actual execution price that a trader is willing to accept. The higher the slippage tolerance, the more the exchange rate can change before the transaction is canceled.
The MEV bot intercepted the trader's transaction and carried out a sandwich attack. As a result, the trader received only $5,200 after the swap, which was 97% less than the original transaction amount.
However, the greatest danger of front-running is that such attacks can even be carried out when specialists are attempting to rescue funds from vulnerable protocols.
For example, when white-hat hackers attempted to transfer funds from vulnerable DODO and Bancor protocols to secure wallets, attackers used MEV bots to copy their transaction code from the mempool and replace the destination addresses with their own. This allowed them to intercept several million US dollars.
Ways to protect against front-running
Using a private RPC
RPC (Remote Procedure Call) is a mechanism that allows a cryptocurrency wallet to interact with a blockchain: submit transactions to the network, retrieve balance information, and check transaction statuses. Essentially, an RPC endpoint acts as an intermediary between a user's wallet and the blockchain.
When public RPC endpoints are used, transactions may be transmitted through publicly accessible nodes, where their contents can be analyzed before they are included in a block. MEV bots can exploit this information to carry out front-running attacks.
Private RPC services can help reduce this risk. They allow users to submit transactions through dedicated channels, limiting third-party access to information about pending operations and reducing the likelihood of interception.
In addition, some cryptocurrency wallets, such as MetaMask, offer built-in protection mechanisms against front-running that help reduce the risk of such attacks.
Reducing slippage tolerance
Slippage tolerance determines the maximum deviation from the trade price a trader expects. If the actual execution price falls outside the specified slippage limit, the order will not be executed.
This approach helps protect users against front-running. If an attacker attempts to get ahead of a transaction and change market conditions, causing the execution price to exceed the specified slippage limit, the transaction will be automatically canceled. This helps prevent swaps from being executed at significantly less favorable rates and avoids the associated financial losses.
Splitting large transactions into smaller ones
To avoid attracting the attention of MEV bots, a trader can split a large transaction into several smaller orders instead of placing a single large one. Attackers who engage in front-running are generally interested in large orders that offer the potential for substantial profits.
Using limit orders
Market orders are executed at the current market price of an asset, which can change every second. While a transaction is being confirmed on the network, the asset's price may change by several percent.
Using limit orders, which are executed only when an asset reaches a specified price, can help reduce exposure to front-running and, consequently, avoid trading losses.
Trading on platforms with built-in front-running protection
Some platforms allow users to execute trades without exposing their transactions to the public mempool. For example, CoW Protocol, built on Ethereum, uses a batch auction mechanism in which transactions become publicly visible only after they have been finalized and recorded in a block.
Transactions conducted through centralized exchanges and cryptocurrency exchange services are also not susceptible to the same type of front-running attacks that target transactions in a public mempool.
