Last Man Standing

First Flight #45
Beginner FriendlyFoundrySolidity
100 EXP
View results
Submission Details
Impact: medium
Likelihood: high
Invalid

Legitimate Player Can't Claim Throne (Logic Flaw)

Root + Impact

Description

  • Each player should be able to claim the throne by paying the correct claimFee, as long as they are not already the current king.

  • When a player who is not the current king tries to claim the throne, the transaction reverts unexpectedly due to broken logic. This halts all future gameplay after just one claim.

// Root cause in the codebase with @> marks to highlight the relevant section
function claimThrone() external payable {
if (msg.sender == currentKing) {
revert("Game: You are already the king. No need to re-claim.");
}
@> if (msg.sender != currentKing) {
@> revert(); // Unexpected revert when another player tries to claim
}
// Remaining logic to update king and pot...
}

Risk

Likelihood:

  • This occurs every time a player other than the current king tries to claim the throne after one successful claim.

  • It is triggered immediately after the first claim and halts gameplay entirely.

Impact:

  • The game becomes unplayable for all new participants after the first claim.

  • Rewards, platform fees, and winner declaration logic become inaccessible, breaking core game functionality.

Proof of Concept

This test demonstrates the broken behavior:
After player1 claims the throne, player2 is unable to claim it despite paying the correct amount. This shouldn't happen and indicates a logic flaw in access control.

function testClaimThrone_FailsForNonKing_Bug() public {
vm.prank(player1);
game.claimThrone{value: INITIAL_CLAIM_FEE}();
vm.expectRevert(); // Shouldn't revert here
vm.prank(player2);
game.claimThrone{value: game.claimFee()}(); // Unexpected revert
}

Recommended Mitigation

The current claimThrone() logic contains contradictory checks that always result in a revert. Remove the redundant second if statement to allow valid players to claim the throne.

- if (msg.sender == currentKing) revert("Game: You are already the king. No need to re-claim.");
+ if (msg.sender == currentKing) {
+ revert("Game: You are already the king. No need to re-claim.");
+ }
- if (msg.sender != currentKing) {
- revert();
- }
Updates

Appeal created

inallhonesty Lead Judge about 1 month ago
Submission Judgement Published
Invalidated
Reason: Lack of quality

Support

FAQs

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