Last Man Standing

First Flight #45
Beginner FriendlyFoundrySolidity
100 EXP
View results
Submission Details
Severity: high
Valid

Missing Grace Period Validation in claimThrone() Enables Invalid Claims Post-Expiration

Root + Impact

The claimThrone() function lacks a check to ensure the grace period has not expired, allowing users to continue claiming the throne after the game should have ended.

Description

  • According to the game’s rules, once the grace period has expired without a new king, the last king should be declared the winner. However, claimThrone() does not verify whether the grace period has elapsed, allowing players to continue claiming the throne even after the deadline, leading to inconsistent game state and broken reward logic.

function claimThrone() external payable {
// Missing check for gracePeriod expiration
currentKing = msg.sender;
...
}

Risk

Likelihood:

  • Any player can claim the throne after the grace period as long as no one calls declareWinner() to end the game.

Impact:

  • The game cannot end properly, preventing the rightful winner from claiming the pot and degrading the user experience.

  • Potentially allows continuous throne claims, making the game unplayable or unfair.

Proof of Concept

The test shows that after the grace period ends, a new player can still claim the throne and become king, which should not be allowed according to the game rules.

function testCanClaimAfterGracePeriodButBeforeDeclareWinner() public {
vm.startPrank(player1);
game.claimThrone{value: INITIAL_CLAIM_FEE}();
vm.stopPrank();
vm.warp(block.timestamp + GRACE_PERIOD + 1);
uint256 newClaimFee = game.getCurrentClaimFee();
console2.log("new claim fee:", newClaimFee);
vm.startPrank(maliciousActor);
game.claimThrone{value: newClaimFee}();
assertEq(game.currentKing(), maliciousActor, "Malicious actor unexpectedly became king after grace period");
}

Recommended Mitigation

Add a grace period validation check at the beginning of claimThrone():

+require(block.timestamp <= lastClaimTime + gracePeriod, "Grace period expired. Declare winner first.");
Updates

Appeal created

inallhonesty Lead Judge 15 days ago
Submission Judgement Published
Validated
Assigned finding tags:

Game::claimThrone can still be called regardless of the grace period

Support

FAQs

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