The claimThrone()
function contains a critical logic error where the require statement checks if msg.sender == currentKing
instead of msg.sender != currentKing
. This backwards condition makes it impossible for anyone to claim the throne for the first time (since currentKing
starts as address(0)
), and prevents any new user from ever becoming king, effectively rendering the entire game contract completely unusable.
The vulnerability exists in the second require statement of the claimThrone()
function where the logic is inverted:
Key issues:
The condition requires the caller to already be the current king to claim the throne
Since currentKing
is initialized as address(0)
, only the zero address could theoretically claim first
The error message "You are already the king" contradicts the actual check (which requires you to be the king)
This creates an impossible condition that prevents any legitimate user from participating
Likelihood: High - This bug affects every single call to the core functionality. Any user attempting to play the game will encounter this issue.
Impact: Critical - The entire contract is non-functional. The game cannot be played, making all development and deployment efforts worthless.
High severity because:
All users are locked out from participating in the game
Contract must be redeployed with the fix
Based on the test results showing the revert, here's what happens when anyone tries to claim the throne:
Fix the require statement to properly check that the caller is NOT the current king:
This simple change will:
This simple change will allow new users to claim the throne when they're not already king
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.