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

`Dussehra.sol::enterPeopleWhoLikeRam` Can be called after the event ends, any Ether sent to the contract will be lost forever

Summary

The Dussehra.sol::enterPeopleWhoLikeRam function can be called after the event ends, any Ether sent to the contract will be lost forever.

Vulnerability Details

Once the killRavana function is called, the totalAmountGivenToRam variable is set. Then once the withdraw function is called, totalAmountGivenToRam is set to 0. This means that the function can only be called once. If someone call's enterPeopleWhoLikeRam and sends ether to the contract, then that money will be lost forever and nobody can withdraw it.

Impact

The test below passes showing that if enterPeopleWhoLikeRam is called after withdraw is called, then that money will not be able to be retrieved.

function test_cannotWithdrawExtraMoneyAfterEvent() public participants {
vm.warp(1728691200 + 1);
vm.startPrank(organiser);
choosingRam.selectRamIfNotSelected();
vm.stopPrank();
vm.startPrank(player2);
dussehra.killRavana();
vm.stopPrank();
uint256 RamwinningAmount = dussehra.totalAmountGivenToRam();
vm.startPrank(player2);
dussehra.withdraw();
vm.stopPrank();
assertEq(player2.balance, RamwinningAmount);
vm.startPrank(player3);
dussehra.enterPeopleWhoLikeRam{value: 1 ether}();
vm.stopPrank();
vm.expectRevert(abi.encodeWithSelector(Dussehra__AlreadyClaimedAmount.selector));
vm.prank(player2);
dussehra.withdraw();
assertEq(address(dussehra).balance, 1 ether);
}

Tools Used

--Foundry

Recommendations

It is recommended to make the enterPeopleWhoLikeRam function revert if someone is trying to call it after killRavana has been called.

function enterPeopleWhoLikeRam() public payable {
if (msg.value != entranceFee) {
revert Dussehra__NotEqualToEntranceFee();
}
if (peopleLikeRam[msg.sender] == true) {
revert Dussehra__AlreadyPresent();
}
+ require(!IsRavanKilled, "Ravan has been killed!");
peopleLikeRam[msg.sender] = true;
WantToBeLikeRam.push(msg.sender);
ramNFT.mintRamNFT(msg.sender);
emit PeopleWhoLikeRamIsEntered(msg.sender);
}
Updates

Lead Judging Commences

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

Invalid - enter people after event or after Ram is selected

It is the user's responsibility to check the date of the event.

Support

FAQs

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