A buyer calls the buyOrder
function to fill a sell order, expecting to receive a specific amount of a designated token for a set USDC price.
There is insufficient buyer-side protections for slippage, deadline and output token validation in the buy order in contrast to the sell order. This exposes the buyer to several distinct risks, including price manipulation (slippage), unfavorable execution timing, and irrecoverable losses from user error.
Likelihood:
Malicious Seller Action (Slippage Attack): A malicious seller observes a pending buyOrder
transaction in the mempool and creates amendSellOrder
transaction with a higher gas price.
Delayed Transaction: The buyer's transaction can be delayed due to network congestion and be executed without any deadline check.
Buyer Mistakes: An honest buyer can simply send a transaction for the wrong orderId
. The contract treats it as a normal transaction due to the lack of slippage protection and output token validation.
Impact:
Price/Amount Risk (Slippage): The malicious seller can drain the buyer's USDC for a negligible amount of the sell tokens(e.g., 1 wei).
Timing Risk (Stale Orders): A legitimate order can become unfavorable due to market changes if the buyer's transaction is delayed.
Mistake Risk: The buyers are forced into a trade they never intended.
Below scenarios show the risks.
Case 1: Alice amends the amount of WBTC from 2e8 to 1 wei in the same USDC price.
Case 2: Dan's transaction is delayed and it is matched with the unfavorable price.
Case 3: Dan makes a mistake and the order is matched with the unintended selling order of Bob.
Apply followings in the buyOrder
function.
Slippage Protection: Add _minOutputAmount
and _maxInputAmount
parameter to prevent malicious amending sell orders and buyer mistakes.
Transaction Deadline: Add buyer-defined _deadline
parameter to prevent later matching.
Expected Asset Verification: Add _exepctedToken
to prevent buyer mistakes.
A malicious seller can front-run a buy order for their order, and decrease the amount of assets to be sold. If the price is unchanged, the buy transaction fulfills, but the buyer gets lesser amount than expected.
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.