Last Man Standing

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

Grace Period Can Be Modified Mid-Game

Summary

The contract owner can modify the grace period during an active game round, potentially affecting fairness and player expectations.

Description

The updateGracePeriod() function allows the owner to change the grace period at any time, including during active gameplay. This can extend or shorten the time remaining for current players unexpectedly.

Root Cause

No restriction prevents grace period updates during active gameplay:

function updateGracePeriod(uint256 _newGracePeriod) external onlyOwner {
require(_newGracePeriod > 0, "Game: New grace period must be greater than zero.");
gracePeriod = _newGracePeriod; // No check for active game
emit GracePeriodUpdated(_newGracePeriod);
}

Impact

  • Fairness Issues: Mid-game changes can disadvantage players who planned based on original grace period

  • Trust Erosion: Players may lose confidence in game integrity

  • Strategic Manipulation: Owner could manipulate outcomes by timing grace period changes

Proof of Concept

function testGracePeriodUpdateMidGame() public {
// Player1 claims throne
vm.prank(player1);
game.claimThrone{value: INITIAL_CLAIM_FEE}();
uint256 claimTime = game.lastClaimTime();
uint256 originalGracePeriod = game.gracePeriod();
// Fast forward to near end of grace period
vm.warp(claimTime + originalGracePeriod - 1 hours);
// Owner extends grace period significantly
vm.prank(deployer);
game.updateGracePeriod(7 days);
// Winner declaration now delayed unfairly
uint256 remainingTime = game.getRemainingTime();
assertGt(remainingTime, 6 days);
}

Recommended Mitigation

Restrict grace period updates to when no active game is in progress:

function updateGracePeriod(uint256 _newGracePeriod) external onlyOwner {
require(_newGracePeriod > 0, "Game: New grace period must be greater than zero.");
require(gameEnded || currentKing == address(0), "Game: Cannot update grace period during active game");
gracePeriod = _newGracePeriod;
emit GracePeriodUpdated(_newGracePeriod);
}
Updates

Appeal created

inallhonesty Lead Judge 4 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
icon0x Submitter
4 months ago
inallhonesty Lead Judge
4 months ago
inallhonesty Lead Judge 4 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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

Give us feedback!