The Last Man Standing game has a critical vulnerability in its core claimThrone()
function that completely breaks the game's functionality. The function contains an incorrect condition check that prevents any player from ever claiming the throne.
Players should be able to claim the throne by sending the required ETH amount, as long as they are not already the current king.
The condition in claimThrone()
is reversed, requiring that the sender must already be the current king to claim the throne. Since the initial king is set to address(0)
, no real address can ever satisfy this condition, making the game completely unplayable.
The vulnerability exists in the claimThrone()
function where the condition check uses ==
instead of !=
:
The error message "You are already the king. No need to re-claim" indicates that the intention was to prevent the current king from claiming the throne again. However, the condition msg.sender == currentKing
does the opposite - it only allows the current king to claim the throne.
The impact is catastrophic as it completely breaks the core functionality of the game:
No player can ever claim the throne
The game cannot progress beyond its initial state
No pot can be accumulated
No winner can ever be declared
The likelihood is extremely high as this issue will be encountered by the very first player who attempts to interact with the game. It's not an edge case but affects the primary function of the contract.
The following test demonstrates the issue:
The condition should be reversed to check that the sender is NOT the current king:
The fix changes the equality check (==
) to an inequality check (!=
), which correctly implements the intended behavior of preventing the current king from claiming the throne again. This allows new players to claim the throne while preventing the current king from reclaiming unnecessarily.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.