Christmas Dinner

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

setDeadline() needs 0 check and to update deadlineSet

Summary

The seatDeadline() doesn't update the deadlineSetto true when the deadline is set and neither has any 0 check implemented as a safety check.

Vulnerability Details

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

If we dont check whether _daysis 0 or not, it could lead to a Denial of Service. And if the deadlineSet isn't updated to true when the deadline is set, the host can keep changing the deadline whenever they wish to. The revert DeadlineAlreadySet() will never be executed.

Impact

Attack:
After the contract has been deployed with a deadline set, a malicious host can call the function later again with _days = 0then the deadline would become the current block.timestamp, meaning the deadline is effectively immediate. Any functionality dependent on this deadline would become inaccessible as soon as the transaction is mined, as subsequent blocks would have a block.timestamp greater than deadline. And then the host could withdraw everything out scamming the participants.

This could serve as a DoS (Denial of Service). Resulting in users not being able to access their funds anymore.

A malicious host can also change the deadline suddenly to an earlier date without prior notice, resulting in participants not able to refund their funds if they planned to later because the deadlineSet value is never updated

Tools Used

Manual Review

Recommendations

Add a check for _days > 0and deadlineSet = truein the else block so the state is updated when deadline is set

function setDeadline(uint256 _days) external onlyHost {
require(_days > 0, "Deadline must be in the future");//added
if(deadlineSet) {
revert DeadlineAlreadySet();
} else {
deadlineSet = true;//added
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: Incorrect statement

Appeal created

riceee Submitter
about 1 year ago
0xtimefliez Lead Judge
about 1 year ago
riceee Submitter
about 1 year ago
0xtimefliez Lead Judge
about 1 year ago
riceee Submitter
about 1 year ago
0xtimefliez Lead Judge
about 1 year ago
riceee Submitter
about 1 year ago
0xtimefliez Lead Judge
about 1 year ago
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!