Last Man Standing

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

Incorrect validation blocks players to claim the throne

Root + Impact

Incorrect valildation blocks players to claim the throne

Description

Incorrect validation in claimThrone() prevents any participant from joining the game and becoming a King, effectively blocking gameplay and rendering the game logic meaningless.

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

After a game is initialized, the value of currentKing is initially set to address(0). However, the second require statement — require(msg.sender == currentKing, ...) — enforces that only the current king can claim the throne. Since currentKing is address(0) at the start, this condition effectively requires msg.sender to be the zero address, which is not feasible and incompatible with normal gameplay. As a result, no participant can ever claim the throne, rendering the game logic blocked and meaningless.

Risk

Likelihood: High

Impact:

  • Incorrect validation blocks players to claim the throne and become a kings.

  • Noone can claim the throne, which blocks the game nad makes it meaningless.

Proof of Concept

function testClaimThrone_PlayersNotAbleToClaimTheThrone() public {
// current king -> initial address(0)
address initialKing = game.currentKing();
console2.log("initialKing: ", initialKing);
// player1 tries to claim the trone
vm.prank(player1);
// the logic fails and do not allow player to become the current king
vm.expectRevert("Game: You are already the king. No need to re-claim.");
game.claimThrone{value: 1 ether}();
// current king is still the initial address(0)
address newKing = game.currentKing();
console2.log("newKing: ", newKing);
}

Tools Used

Manual review
Foundry

Recommended Mitigation

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

This adjustment ensures that the game's requirements for claiming the throne are properly enforced and the core logic is correctly implemented. Only an address different from the current king will be allowed to claim the throne and become the new king. Most importantly, this change removes the critical blocker that previously prevented new players from participating in the game.

Updates

Appeal created

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