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

Unlimited Range for `raffleDuration` Variable

Vulnerability Details

The raffleDuration variable is used to determine the duration of each raffle. This variable is set in the constructor and can be any uint256 value, including 0 or the maximum value for a uint256 (approximately ( 1.15 \times 10^{77} ) seconds or 3.7 billion billion billion years). The lack of restrictions on the range of raffleDuration can lead to unintended behavior.

uint256 public raffleDuration;
constructor(uint256 _entranceFee, address _feeAddress, uint256 _raffleDuration) ERC721("Puppy Raffle", "PR") {
...
raffleDuration = _raffleDuration;
...
}

Impact

The unrestricted range of raffleDuration can cause several issues:

  1. Zero Duration: If raffleDuration is set to 0, the raffle could end immediately after starting, potentially causing confusion or manipulation opportunities.

  2. Excessively Long Duration: Setting raffleDuration to an extremely high value could effectively lock the raffle for an impractical period, rendering the contract unusable for its intended purpose.

  3. Contract Usability and Fairness: The ability to set any duration, including extremely short or long periods, can affect the usability and fairness of the raffle process, impacting participant confidence and engagement.

Recommendations

  • Implement Range Checks: Introduce validation in the constructor to ensure that raffleDuration falls within a reasonable and practical range. For instance, you might enforce a minimum duration of 1 minute and a maximum of 1 year.

  • Document Reasonable Ranges: Clearly document the recommended and supported ranges for raffleDuration to guide contract deployers in choosing appropriate values.

Updates

Lead Judging Commences

Hamiltonite Lead Judge about 2 years ago
Submission Judgement Published
Invalidated
Reason: User experience and design improvement

Support

FAQs

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

Give us feedback!