game::claimThrone()
Prevents All Users from Claiming the Throne.Description: In a working protocol, users are able to call claimThrone()
multiple times during the duration of a game to become king. In the current Game::claimThone()
implementation, nobody is able to successfully become king. The "require(msg.sender == currentKing,...) breaks the intended flow and functionality of the entire protocol. Please see the code below:
Impact: HIGH
Protocol functionality is totally destroyed
Likelihood: HIGH
The successful calling of Game::claimThrone()
is an integral part of the entire "Last Man Standing" protocol. This would likely be called mutliple times per game.
Proof of Concept:
Prank player 1.
Call Game::claimThrone
with the required INITIAL_CLAIM_FEE
.
Compare the address of the current king to the address of player 1.
Run the console2.log of the current king to see that the king address stays as address zero.
Proof of Code: Paste the below code in Game.t.sol
:
This test will pass becasue we are expecting the revert due to the logic error in the second require line of the function.
Recommended Mitigation: I would recommend changing the second require line in Game::claimThrone()
to "!=" instead of "==". This would allow users who are NOT the current king to call the function. This would align with the protocol's intended functionality.
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.