The game is intended to be a "last man standing" contest where players can usurp the current king by paying a fee. This allows for continuous competition until a final winner is determined after a grace period.
The claimThrone function has an inverted logic check that requires the caller to already be the king. This critical flaw prevents any new player from ever claiming the throne, permanently locking the kingship to the first person who claims it.
Likelihood:
The vulnerability manifests the moment the first player calls claimThrone() and becomes currentKing.
Every subsequent call to claimThrone() by any other player is guaranteed to revert, as the caller's address will not match the currentKing's address.
Impact:
The core game mechanic is broken. The "last man standing" game becomes a "first man wins" game, as no one can challenge the initial king.
The first player to claim the throne is guaranteed to win the entire prize pot, completely centralizing the outcome and removing any element of competition or fairness.
The following Proof of Concept can be added as a test to test/Game.t.sol. It demonstrates the vulnerability by simulating the exact exploit scenario:
player1 successfully calls claimThrone() to become the first king.
player2 then attempts to claim the throne by sending the new, increased fee.
The test asserts that player2's transaction reverts. This is because the flawed logic require(msg.sender == currentKing) blocks any user who is not already the king.
This test proves that the kingship is locked to the first claimant, rendering the game unplayable for all other participants.
The fix is to correct the inverted logic in the require statement within the claimThrone function. The comparison operator should be changed from == (equals) to != (not equals). This change ensures that a transaction will only proceed if the sender is not the current king. This correctly prevents the king from reclaiming the throne from themselves while allowing any other challenger to do so. This single change restores the core "King of the Hill" mechanic and makes the game playable as intended.
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.