Last Man Standing

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

Inverted logic condition prevents any throne claims

Description:

The claimThrone() function contains a critical logic error that makes the entire game unplayable. The require statement uses inverted logic:

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

This condition requires that the message sender MUST be equal to the current king to proceed. However:

  1. currentKing is initialized as address(0) in the constructor

  2. No user can have address address(0) as their wallet address

This creates an impossible condition where no legitimate user can ever claim the throne, as msg.sender can never equal address(0).

Impact:

  • No player can ever call claimThrone() successfully

  • The game becomes entirely non-functional from deployment

PoC:

Put this into Game.t.sol file and run forge test --mt testCantJoinTheGame -vvv

function testCantJoinTheGame() public {
vm.prank(player1);
vm.expectRevert();
game.claimThrone{value: INITIAL_CLAIM_FEE}();
}

Recommended Mitigation:

Fix the logic condition changing the equality operator to inequality:

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

Appeal created

inallhonesty Lead Judge 24 days 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.