Last Man Standing

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

Claims Allowed After Grace Period Expiration

Summary

Players can claim the throne even after the grace period has expired, preventing legitimate winner declarations and disrupting game flow.

Description

The claimThrone() function lacks validation to prevent claims after the grace period expires. This allows players to indefinitely extend the game by claiming the throne after a winner should have been declared.

Root Cause

Missing validation check in claimThrone() to ensure the grace period hasn't expired:

// Missing check:
require(block.timestamp <= lastClaimTime + gracePeriod, "Grace period expired");

Impact

  • Game Disruption: Winners cannot be declared if new claims keep resetting the timer

  • Unfair Advantage: Late claimers can "snipe" victories right before grace period expiration

  • Economic Manipulation: Malicious actors can prevent legitimate winners from claiming prizes

Proof of Concept

function testCanClaimAfterGracePeriod() public {
// Player1 claims throne
vm.prank(player1);
game.claimThrone{value: INITIAL_CLAIM_FEE}();
// Fast forward past grace period
vm.warp(block.timestamp + GRACE_PERIOD + 1);
// Player2 can still claim (should be prevented)
uint256 nextClaimFee = INITIAL_CLAIM_FEE + (INITIAL_CLAIM_FEE * FEE_INCREASE_PERCENTAGE) / 100;
vm.prank(player2);
game.claimThrone{value: nextClaimFee}();
assertEq(game.currentKing(), player2); // This succeeds but shouldn't
}

Recommended Mitigation

Add grace period validation to claimThrone():

function claimThrone() external payable gameNotEnded nonReentrant {
require(msg.value >= claimFee, "Game: Insufficient ETH sent to claim the throne.");
require(msg.sender != currentKing, "Game: You are already the king. No need to re-claim.");
// Add this check
if (currentKing != address(0)) {
require(
block.timestamp <= lastClaimTime + gracePeriod,
"Game: Grace period expired, declare winner first"
);
}
// Rest of function...
}
Updates

Appeal created

inallhonesty Lead Judge 4 months 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.

Give us feedback!