Christmas Dinner

First Flight #31
Beginner FriendlyFoundrySolidity
100 EXP
View results
Submission Details
Severity: medium
Invalid

Zero day deadline set locks event permanently

Summary

A potential issue arises when the setDeadline function is called with _days = 0, which sets the deadline to the current timestamp, effectively locking it forever. This could prevent any participants from signing up or interacting with the contract after the deadline is set, as the contract would consider the deadline already passed.

Vulnerability Details

The function setDeadline(uint256 _days) does not currently check for the case when _days = 0. If _days is set to 0, the deadline will be set to the current block's timestamp, locking the event forever and making it impossible to modify the deadline or proceed with event registration.

function setDeadline(uint256 _days) external onlyHost {
if(deadlineSet == true) {
revert DeadlineAlreadySet();
} else {
deadline = block.timestamp + _days * 1 days; // if _days = 0 it will be locked forever
emit DeadlineSet(deadline);
}
}

Impact

The contract will be locked indefinitely if _days = 0 is provided, preventing any participants from signing up or interacting with the event after the deadline.

Tools Used

Manual code review

Recommendations

Add a validation check to ensure that _days is not equal to 0 before setting the deadline

function setDeadline(uint256 _days) external onlyHost {
if(deadlineSet == true) {
revert DeadlineAlreadySet();
} else if (_days == 0) { // Making a check for _days != 0
revert("Deadline cannot be 0");
} else {
deadline = block.timestamp + _days * 1 days;
emit DeadlineSet(deadline);
}
}
Updates

Lead Judging Commences

0xtimefliez Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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

Give us feedback!