Beginner FriendlyFoundryNFT
100 EXP
View results
Submission Details
Severity: low
Invalid

### [L-2] Not respecting CEI pattern in the `Dussehra::withdraw` function.

[L-2] Not respecting CEI pattern in the Dussehra::withdraw function.

Description: According to the CEI pattern, state changes should be made before doing external calls. In the context of the withdraw function this is not the case. Although I did not find an immediate impact for this, I still think this is prone to errors in the future, such as reentrancy.

Impact: Possibility of adding reentrancy vulnerability in the future.

Recommended mitigation: In the withdraw function, move the line totalAmountGivenToRam = 0; above the external call.

function withdraw() public RamIsSelected OnlyRam RavanKilled {
if (totalAmountGivenToRam == 0) {
revert Dussehra__AlreadyClaimedAmount();
}
uint256 amount = totalAmountGivenToRam;
+ totalAmountGivenToRam = 0;
(bool success, ) = msg.sender.call{value: amount}("");
require(success, "Failed to send money to Ram");
- totalAmountGivenToRam = 0;
}
Updates

Lead Judging Commences

bube Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Invalid - reentrancy in withdraw

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.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.