Dussehra::withdraw
May Lead to Fund TheftDescription:
The withdraw
function in the Dussehra
contract sends rewards to the winner (Ram) using a low-level call
function. However, the state variable totalAmountGivenToRam
is modified after the transfer is initiated, creating a reentrancy risk. An attacker could potentially exploit this vulnerability to drain funds from the contract.
Impact:
While the typical flow of the protocol might not immediately expose this vulnerability, especially since the organizer's fee is transferred upon invoking the killRavana
function, it's crucial to address this issue to safeguard against potential exploits. Ensuring the integrity of fund transfers is paramount, particularly in scenarios where unexpected funds accumulate in the contract at the time of withdrawal.
Tools Used:
Manual Review
Recommended Mitigation:
To eliminate the reentrancy risk, it is advised to adjust the order of operations within the withdraw
function to follow CEI (Checks, Effects, Interactions). Specifically, the state variable totalAmountGivenToRam
should be reset before initiating the fund transfer. This change prevents potential reentrant calls from interfering with the contract's state during the withdrawal process.
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.