The protocol's core functions for interacting with orders (buyOrder
, cancelSellOrder
, amendSellOrder
) are susceptible to front-running attacks. Due to the public and transparent nature of the blockchain mempool, a malicious actor (e.g., a MEV bot) can observe these pending transactions and execute their own transactions first. This allows attackers to steal profitable opportunities from both buyers and sellers, forcing them into unwanted trades or causing their intended actions to fail.
Likelihood:
Blocking the amendOrder
or cancelOrder
: attacker adds buyOrder
in front of the sellers' transactions.
Preempting the buyOrder
: attacker preoccupies the good chance for buying tokens by duplicating the transaction.
Impact:
Sellers' Profit Stolen: Sellers might unwilling to sell the tokens at previous lower price expecting more profit later, but tokens are forced to sell at previous price.
Buyers' Profit Stolen: Previous buyer's order is replaced with the attacker's order, the profit is transferred to the attacker.
Below code shows both problems.
Seller's Profit Stolen: Alice is willing to sell 1e8 WBTC with 100_000e6 USDC, after she want to cancel due to the rise. Dan sees the tx in mempool and buy with the previous price blocking the cancel.
Buyers' Profit Stolen: Bob created order that selling 1e18 WETH in 2_000e6 USDC, which is flavorable to Alice. Alice sends buyOrder
tx and is intercepted by Dan who steals the profit.
Use the commit-reveal scheme for hiding the intention of users. Below is the sample code for replacing the buyOrder
without making the orderId
public.
When a seller wants to amend or cancel their sell orders, a malicious entity can front-run their transactions and buy out the orders. This can be especially harmful when real-world prices of listed assets fluctuate and sellers want to adjust the prices listed in their orders.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.