Santa's List

AI First Flight #3
Beginner FriendlyFoundry
EXP
View results
Submission Details
Impact: medium
Likelihood: high
Invalid

`collectPresent` cannot be called before Christmas despite intended grace period

Description

The contract is intended to allow users to collect presents around Christmas, including a small grace period before the exact Christmas timestamp. As mentioned in the documentation, collecting presents within 24 hours before Christmas is considered acceptable behavior.

However, the current implementation only allows collectPresent to be called at or after the exact CHRISTMAS_2023_BLOCK_TIME. Any call made before this timestamp always reverts, even if it falls within the documented pre-Christmas grace period. This makes the time check stricter than intended and prevents valid users from collecting during the expected window.

function collectPresent() external {
if (block.timestamp < CHRISTMAS_2023_BLOCK_TIME) {
@> revert SantasList__NotChristmasYet();
}
...
}

Risk

Likelihood: High

  • Any user attempting to collect presents shortly before Christmas is affected.

  • This is a realistic and expected usage window based on the documented grace period.

Impact: Medium

  • Eligible users may be prevented from collecting their presents.

  • The contract behavior does not match the documented pre-Christmas collection window.

  • This breaks expected protocol behavior for valid users.

Proof of Concept

This test shows that even within a reasonable pre-Christmas window(24 hours before christmas), the call reverts due to the strict lower-bound check.

function test_CannotCollectWithinPreChristmasWindow() public {
vm.warp(CHRISTMAS_2023_BLOCK_TIME - 12 hours);
vm.expectRevert();
santasList.collectPresent();
}

Recommended Mitigation

Update the lower-bound check so it matches the documentation, which explicitly allows users to collect presents within a small grace period before Christmas.

- if (block.timestamp < CHRISTMAS_2023_BLOCK_TIME) {
+ if (block.timestamp < CHRISTMAS_2023_BLOCK_TIME - 1 days) {
revert SantasList__NotChristmasYet();
Updates

Lead Judging Commences

ai-first-flight-judge Lead Judge about 4 hours ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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

Give us feedback!