In the buyOrder
function, Ether is sent to the seller via a low-level call:
Without a re-entrancy guard (e.g., nonReentrant
), a malicious seller could craft a fallback function to re-enter buyOrder
or other state-changing functions in TokenDivider
before state changes are fully finalized.
Double Purchase or Double Withdraw: A malicious seller could re-enter in the middle of the Ether transfer to alter order data or cause unexpected results (e.g., re-purchasing tokens they just sold).
Draining Funds: If combined with other state inconsistencies, the attacker could cause the contract to make multiple payments or incorrectly update balances.
Malicious seller publishes a sell order with a specially crafted fallback function.
msg.sender
calls buyOrder
, triggers the Ether call{value: ...}
, which in turn calls the fallback function of the seller’s contract.
In the fallback, the malicious code calls back into buyOrder
(or another function) to modify state or create new orders, leading to inconsistent state or multiple Ether transfers.
Use OpenZeppelin’s ReentrancyGuard
or a custom nonReentrant
modifier to prevent re-entrancy in external-facing, state-changing functions:
Re-organize code to follow the Checks-Effects-Interactions pattern:
Validate inputs
Update state
Interact with external contracts (Ether transfer, ERC20 transfers, etc.) last
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.