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

User can kill Ravana after the event is finished (after 13 October 2024)

Summary

A player can call the function dussehra.killRavana() after 13 October 2024.

Vulnerability Details

According to the specification, a player should not be able to call dussehra.killRavana() after 13 October 2024, but there is a mistake in the function related to the 13 October 2024 timestamp. 13 October 2024 00:00 is -> 1728777600, but in the function dussehra.killRavana() it checks 1728777669, which is 13 October 2024 00:01.

Impact

Users will be able to kill Ravana after the event.

Code Example

This code should be added to the smart contract Dussehra.sol#CounterTest:

function test_killRavanaAfterEvent() public participants {
//organiser select Ram 1 seconds after the Event Beguing
vm.warp(1728691200 + 1);
vm.startPrank(organiser);
choosingRam.selectRamIfNotSelected();
vm.stopPrank();
//Player kill ravana 10 seconds after 13 october 2024
vm.warp(1728777600 + 10);
vm.startPrank(player2);
dussehra.killRavana();
vm.stopPrank();
assertEq(dussehra.IsRavanKilled(), true);
}

Result
The user will be able to kill Ravana 10 seconds after the end of the event.

forge test --mt test_killRavanaAfterEvent
[⠊] Compiling...
[⠊] Compiling 3 files with 0.8.20
[⠢] Solc 0.8.20 finished in 3.06s
Compiler run successful!
Ran 1 test for test/Dussehra.t.sol:CounterTest
[PASS] test_killRavanaAfterEvent() (gas: 399647)
Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 8.93ms (1.46ms CPU time)

Tools Used

Manual review.

Recommendations

Fix the error in the code:

function killRavana() public RamIsSelected {
- if (block.timestamp < 1728691069) {
+ if (block.timestamp < 1728691200) {
revert Dussehra__MahuratIsNotStart();
}
- if (block.timestamp > 1728777669) {
+ if (block.timestamp > 1728777600) {
revert Dussehra__MahuratIsFinished();
}
IsRavanKilled = true;
uint256 totalAmountByThePeople = WantToBeLikeRam.length * entranceFee;
console.log("Total amount by the people:", totalAmountByThePeople);
totalAmountGivenToRam = (totalAmountByThePeople * 50) / 100;
(bool success,) = organiser.call{value: totalAmountGivenToRam}("");
require(success, "Failed to send money to organiser");
}
Updates

Lead Judging Commences

bube Lead Judge about 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

Incorrect timestamp

Support

FAQs

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