The withdraw
function in the Dussehra contract violates the checks-effects-interactions pattern, which can lead to reentrancy vulnerabilities. This pattern is a crucial best practice in Solidity development to prevent attackers from exploiting reentrancy issues, potentially leading to loss of funds.
In the current implementation of the withdraw
function, the contract makes an external call to transfer Ether before updating the state, which can be exploited in a reentrancy attack:
Reentrancy Attack: An attacker can re-enter the withdraw function before the state variable totalAmountGivenToRam is set to zero, allowing them to drain the contract’s funds.
Loss of Funds: The contract’s Ether balance can be significantly depleted if exploited, causing financial damage to the contract and its stakeholders.
Manual review
Follow the Checks-Effects-Interactions Pattern: Ensure that the contract’s state is updated before making any external calls.
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.