Christmas Dinner

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

Host can set deadline multiple times

[H-2] Host can set deadline multiple times

Description: The deadlineSet variable is never set to true, so the host change the deadline at any time.

function setDeadline(uint256 _days) external onlyHost {
// this will never trigger
@> if(deadlineSet) {
revert DeadlineAlreadySet();
} else {
deadline = block.timestamp + _days * 1 days;
emit DeadlineSet(deadline);
}
}

Impact: The host can extend the deadline, or immediately end the event.

Proof of Concept:

  1. HOST can extend the deadline by 10 days.

  2. HOST can end the event immediately.

Add the following code into ChristmasDinner.t.sol:

function test_hostChangeDeadline() public {
vm.startPrank(deployer);
uint256 oldDeadline = cd.deadline();
// extend deadline by 10 days
cd.setDeadline(DEADLINE + 10);
uint256 newDeadline = cd.deadline();
assertGe(newDeadline, oldDeadline);
// end the event
cd.setDeadline(0);
assertEq(cd.deadline(), block.timestamp);
vm.stopPrank();
}

Recommended Mitigation:
change 'deadlineSet' to true after the deadline is set.

function setDeadline(uint256 _days) external onlyHost {
// this will never trigger
if(deadlineSet) {
revert DeadlineAlreadySet();
} else {
+ deadlineSet = true;
deadline = block.timestamp + _days * 1 days;
emit DeadlineSet(deadline);
}
}
Updates

Lead Judging Commences

0xtimefliez Lead Judge 11 months 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.