Dusserha::withdraw
changes the state after executing the call to send the money to the winner. This functionality allows a winner who has been selected to drain the protocol of its funds.
(Proof of Code)
An example of an attacking contract can look like this:
the attacking contract enters the protocol.
the attacker waits for the protocol to select a ram
the attacker is chosen as the ram
the attacker calls attack and sets off the reentrancy attack
add the following test to the Dussehra.t.sol
contract aswell as the above attacking contract.
An attacker may enter the protocol many times and if selected as the ram will drain all the funds within the Dussehra
contract.
Slither,
ChatGpt,
Manual Review,
Foundry,
Update the state of the totalAmountGiven before paying out the winner.
The `withdraw` function sends the given amount to Ram. If the attacker calls the `withdraw` function again before the state variable is changed, the function will revert because there are no more funds in the contract. This reentrancy has no impact for the protocol. It is recommended to follow the CEI pattern, but this is informational.
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.