A sandwich attack is a DeFi trading exploit where an attacker front-runs and back-runs a victim’s trade on a decentralized exchange (DEX), manipulating token prices to profit from price slippage.
What Is a Sandwich Attack?
A sandwich attack is a DeFi trading exploit where a malicious actor manipulates the price of a token by placing two transactions around a target trade to profit from price slippage. This attack typically occurs on DEXs using automated market makers (AMMs), such as Uniswap and PancakeSwap.
By front-running and back-running a trade, the attacker forces the victim to buy at a higher price and sell at a lower price, profiting from the artificially created price movement.
How Does a Sandwich Attack Work?
-
Front-Running – The attacker detects a pending trade and places a buy order first, pushing the token’s price up.
-
Victim’s Trade Executes – The victim’s order is processed at a higher price than expected.
-
Back-Running – The attacker quickly sells the tokens at the inflated price, profiting from the manipulated trade.
This attack exploits MEV (Maximal Extractable Value), a practice where bots monitor mempools to detect profitable trade opportunities before they are confirmed on-chain.
Why Are Sandwich Attacks Important?
-
Increases Trading Costs – Traders end up paying higher slippage due to price manipulation.
-
Reduces Market Fairness – Creates an unfair advantage for attackers, harming retail traders.
-
Highlights DeFi Vulnerabilities – Encourages the development of anti-MEV solutions like private mempools and slippage protection.
Sandwich attacks are a growing concern in DeFi trading, prompting developers to implement MEV-resistant strategies, such as transaction ordering protections and private transaction relays, to safeguard users.