Description:
When an order is purchased, the remaining orders are shifted,
causing the same orderIndex to reference a different order.
This behavior is vulnerable to MEV(front running) attacks.
Impact:
If a seller places multiple sell orders first and detects a buyer sending a
transaction to purchase their order,
the seller can frontrun by buying their own order. This shifts the other orders,
causing the buyer to purchase the wrong one.
Proof of Concept:
add the following in test/unit/TokenDividerTest.t.sol
then run forge test --mt testMEVAttack
, the final fraction token USER2 got is only 1 instead of half of the total amount.
Recommended Mitigation:
Utilize a mapping with the nonce as the key to store orders, ensuring the nonce only increments.
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.