Last Man Standing

First Flight #45
Beginner FriendlyFoundrySolidity
100 EXP
View results
Submission Details
Impact: high
Likelihood: medium
Invalid

missing `gameEndedOnly` modifier in `updateGracePeriod()`

Description

The deployer can update the grace period during the game, either to end it immediately or to make it never end which made the Game untrusted.

Proof of Concept

Add this test to Game.t.sol:

function testupdateGracePeriod() public {
console2.log("Grace Period:", game.gracePeriod());
vm.startPrank(deployer);
game.updateGracePeriod(2 days);
vm.stopPrank();
console2.log("New Grace Period:", game.gracePeriod());
}

Then run:
forge test --match-test testupdateGracePeriod -vvv


🧾 Output

Ran 1 test for test/Game.t.sol:GameTest
[PASS] testupdateGracePeriod() (gas: 26728)
Logs:
Grace Period: 86400
New Grace Period: 172800

As shown, the deployer can update the grace period during the game.

Recommended Mitigation

Add a gameEndedOnly modifier to prevent calling updateGracePeriod() while the game is still running:

- function updateGracePeriod(uint256 _newGracePeriod) external onlyOwner {
+ function updateGracePeriod(uint256 _newGracePeriod) external onlyOwner gameEndedOnly {
Updates

Appeal created

inallhonesty Lead Judge about 1 month ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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