Christmas Dinner

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

setDeadline Function Does Not Update deadlineSet State

Summary

The setDeadline function in the contract fails to update the deadlineSet state variable to true after the deadline is successfully set. This oversight allows repeated calls to setDeadline, which contradicts the intended behavior of the function.

Vulnerability Details

The deadlineSet variable remains false after a successful call to setDeadline. As a result, the function can be called repeatedly, leading to inconsistent contract behavior and potential misuse.

function test_tryResettingDeadlineAsHost() public {
vm.startPrank(deployer);
cd.setDeadline(8 days);
cd.deadlineSet();
console.log("The deadline is still set to", cd.deadlineSet());
vm.stopPrank();
}

Out Put

Ran 1 test for test/ChristmasDinnerTest.t.sol:ChristmasDinnerTest
[PASS] test_tryResettingDeadlineAsHost() (gas: 26632)
Logs:
The deadline is still set to false
Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 6.30ms (343.30µs CPU time)

Impact

Breaks the intended logic of the contract by allowing multiple deadlines to be set.

Tools Used

Foundry and Manual review

Recommendations

Update the setDeadline function to include a statement setting the deadlineSet variable to true after successfully setting the deadline.

function setDeadline(uint256 _days) external onlyHost {
if (deadlineSet) {
revert DeadlineAlreadySet();
} else {
deadline = block.timestamp + _days * 1 days;
deadlineSet = true; // Update the flag to reflect the set state
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!