Christmas Dinner

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

Missing Update of deadlineSet Flag Allows Unlimited Changes

Summary

In the current implementation of the setDeadline function, the flag deadlineSet is never updated to true after the deadline is successfully set. This issue allows the host to modify the deadline an unlimited number of times, bypassing the intended restriction that should prevent further changes once the deadline is set.

Vulnerability Details

The setDeadline function is designed to allow the host to set the event deadline. The logic checks whether the deadlineSet flag is true, and if it is, reverts the transaction. However, the flag deadlineSet is never updated after a successful deadline change. This oversight means that the host can continue to modify the deadline without any restrictions, even after an initial deadline is set.

function setDeadline(uint256 _days) external onlyHost {
if(deadlineSet) {
revert DeadlineAlreadySet();
} else {
deadline = block.timestamp + _days * 1 days;
emit DeadlineSet(deadline);
}
}

Impact

The flag deadlineSet is meant to prevent the host from modifying the deadline once it has been set. Since the flag is not updated after setting the deadline, the host can call the setDeadline function repeatedly to change the deadline, potentially manipulating the event timing to their advantage.

Tools Used

Manual

Recommendations

To fix this vulnerability, the deadlineSet flag should be updated to true when the deadline is successfully set. This will ensure that subsequent attempts to modify the deadline are blocked.

function setDeadline(uint256 _days) external onlyHost {
if(deadlineSet) {
revert DeadlineAlreadySet();
} else {
deadline = block.timestamp + _days * 1 days;
deadlineSet = true; // Update the flag to prevent further changes
emit DeadlineSet(deadline);
}
}
Updates

Lead Judging Commences

0xtimefliez Lead Judge about 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

deadline is never set to true

Support

FAQs

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

Give us feedback!