Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: high
Invalid

Wrong implementation of time check in `collectPresent`

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();
// User is calling 6 hours before christmas
vm.warp(santasList.CHRISTMAS_2023_BLOCK_TIME() - 6 hours);
vm.startPrank(user);
// This should not revert but its reverting
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();
// User is calling 6 days after christmas
vm.warp(santasList.CHRISTMAS_2023_BLOCK_TIME() + 6 days);
vm.startPrank(user);
// This should revert but its not reverting
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

  • Manual Review

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();
}
Updates

Lead Judging Commences

inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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