Summary
Users can't collectPresent
before christmas as well as can collectPresent
way more days after christmas because of wrong implementation of time check in SantasList::collectPresent
Vulnerability Details
Users should be able to collectPresent
24 hours before and after the christmas, but they can only collectPresent
after christmas but not before
@> if (block.timestamp < CHRISTMAS_2023_BLOCK_TIME) {
revert SantasList__NotChristmasYet();
}
//Here is the POC, for not able to mint before christmas
function test_canNotMintBeforeChristmas() public {
vm.startPrank(santa);
santasList.checkList(user, SantasList.Status.EXTRA_NICE);
santasList.checkTwice(user, SantasList.Status.EXTRA_NICE);
vm.stopPrank();
vm.warp(santasList.CHRISTMAS_2023_BLOCK_TIME() - 6 hours);
vm.startPrank(user);
vm.expectRevert();
santasList.collectPresent();
vm.stopPrank();
}
//Here is the POC, for minting after more than 24 hours ie 1 day
function test_canMintAfter24Hours() public {
vm.startPrank(santa);
santasList.checkList(user, SantasList.Status.EXTRA_NICE);
santasList.checkTwice(user, SantasList.Status.EXTRA_NICE);
vm.stopPrank();
vm.warp(santasList.CHRISTMAS_2023_BLOCK_TIME() + 6 days);
vm.startPrank(user);
santasList.collectPresent();
vm.stopPrank();
}
Impact
Users will not be able to mint before christmas which breaks the core of protocol, potentially reducing lack of trust in the protocol
Tools Used
Recommendations
- if (block.timestamp < CHRISTMAS_2023_BLOCK_TIME) {
revert SantasList__NotChristmasYet();
}
if (
+ block.timestamp > CHRISTMAS_2023_BLOCK_TIME + 1 days || block.timestamp < CHRISTMAS_2023_BLOCK_TIME - 1 days
) {
revert SantasList__NotChristmasYet();
}