Security
Sandwich Attack
A front-running variant where an attacker places transactions before and after a victim's to manipulate price and profit.
Last Updated
2026-03-19
Related Concepts
What is Sandwich Attack?
A sandwich attack is a front-running exploit where an attacker inserts their own transactions directly before and after a victim's trade. The attacker profits by manipulating the price at the victim's expense.
How does Sandwich Attack work?
- A user broadcasts a large token swap to the mempool.
- The attacker buys the same token first with a higher gas fee, pushing the price up.
- The victim's trade executes at the inflated price.
- The attacker immediately sells at the now-higher price, capturing the spread.
Why does Sandwich Attack matter?
It costs users millions in worse execution prices annually. Every large DEX trade is a potential target, creating an invisible tax on retail traders.
Key features of Sandwich Attack
- Exploits the public mempool and predictable AMM pricing
- More profitable than simple front-running
- Disproportionately affects large trades in low-liquidity pools
- Mitigated by tight slippage limits and private mempools like Flashbots Protect
Examples of Sandwich Attack
A user swapping 1000 ETH on Uniswap could lose several percent of value to a sandwich bot. Setting slippage tolerance to 0.1 percent makes the attack unprofitable and causes the bot to skip the transaction.
