Last Man Standing

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

Incorrect validation prevents throne claims - Game is unusable

Incorrect validation prevents throne claims - Game is unusable

Description

The claimThrone() allows any new player to become the new king by sending the required claim fee, increamenting the pot, and updating the game state accordingly.

However, the function currently includes a faulty validation check that requires msg.sender to already be the current king. This logic prevents anyone, including new participants, from claiming the throne - effectively rendering the game unplayable.

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.");

Risk

Likelihood: High

This issue will occur when any user attempts to claim the throne.

Impact: High

No one can claim the throne, halting the core functionality of the game. The game remains stuck in the initial state, with no progress possible.

Proof of Concept

The following PoC demonstrates that the validation logic is inverted — it blocks all valid claim attempts from non-kings, including the first player.

function test_cannotClaimThrone() public {
assertEq(game.currentKing(), address(0), "Initial king should be address(0)");
vm.prank(player3);
vm.expectRevert();
game.claimThrone{value: INITIAL_CLAIM_FEE}();
}

Recommended Mitigation

- require(msg.sender == currentKing, "Game: You are already the king. No need to re-claim.");
+ require(msg.sender != currentKing, "Game: You are already the king. No need to re-claim.");

By flipping the condition, the current king is prevented from re-claiming the throne while allowing new participants to join and advance the game.

Updates

Appeal created

inallhonesty Lead Judge about 2 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Game::claimThrone `msg.sender == currentKing` check is busted

Support

FAQs

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