Last Man Standing

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

`Game::claimThrone` Check Breaks Protocol

Description

  • When a player calls Game::claimThrone, the game breaks due to the inverted logic in the require statement that only allows the current king to claim the throne again, preventing any new players from ever becoming king and making the entire 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:

The issue will occur every time there is an attempt to claim the the throne since currentKing starts as address(0)

Impact:

No player can ever claim the throne, rendering the entire game unplayable

Declaration of a winner is impossible

Withdrawals can't be executed

Fees are not generated

Game reset is unreachable

Proof of Concept

function testPlayersCannotClaimThrone() public {
assertEq(game.currentKing(), address(0));
vm.prank(player1);
vm.expectRevert();
game.claimThrone{value: 0.5 ether}();
}

Recommended Mitigation

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.");
+ require(msg.sender != currentKing, "Game: You are already the king. No need to re-claim.");
}
Updates

Appeal created

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