The buyOrder
function in the TokenDivider
contract is vulnerable to a reentrancy attack, which allows an attacker to repeatedly call the function within a single transaction. This issue could lead to the attacker draining the contract's funds and other malicious behavior.
The vulnerability arises because the buyOrder
function allows Ether to be transferred to the seller before updating the contract's internal state. Specifically, the contract updates the buyer's balance and processes the transaction after the Ether transfer, which can be exploited by an attacker.
An attacker could create a malicious contract that triggers the buyOrder
function repeatedly during the fallback function execution, draining Ether from the contract and causing it to behave unpredictably.
The attacker would keep draining the funds until there is nothing left.
Sellers can lose their tokens without receiving payment.
This could damage trust in the smart contract and the platform it is on.
Manually Inspection
Here is how an attacker could use this bug:
Users deploys a malicious contract that tricks the buyOrder function into calling it back.
When the malicious contract receives Ether, it keeps calling buyOrder repeatedly, before the contract updates its records.
The attacker drains the contract balance by repeating the process until it is empty.
Use a reentrancy guard to block reentrant calls by using a nonReentrant modifier. This can be added to critical functions where external calls are made
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.