Last Man Standing

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

DoS: Game is unplayable from deployment due to currentKing check

Root + Impact

Description

  • Normal behavior:
    When a player sends the required claim fee to claimThrone(), they should be able to claim the throne, dethroning the previous king, who receives a reward.

  • Problem:
    Due to a faulty require condition, only the current king can call claimThrone(). Since the initial currentKing is the zero address, no one can ever match it, making the game impossible to start.

// Root cause
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:

  • The issue occurs immediately upon deployment.

  • No player can ever claim the throne because currentKing is the zero address, and no real player can match that.

Impact:

  • The game is completely unplayable from the beginning.

  • Core functionality (claiming the throne) is blocked for all players.

Proof of Concept

This test shows that no one can enter the game at all. When the contract is first deployed, currentKing is set to the zero address (address(0)), so any real player calling claimThrone() fails the require(msg.sender == currentKing) check. Since no one can ever be the zero address, the game is completely unplayable from the start.

function test_CannotEnterGame() public {
vm.startPrank(player1);
vm.expectRevert();
game.claimThrone{value: 1 ether}();
vm.stopPrank();
}

Recommended Mitigation

Replace the incorrect require condition to prevent the current king from reclaiming, not everyone else.

- 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 9 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.