Last Man Standing

First Flight #45
Beginner FriendlyFoundrySolidity
100 EXP
View results
Submission Details
Severity: medium
Valid

Game cannot be play because of a bad require statement

[H] Game cannot be play because of a bad require statement

Description:
The function Game:claimThrone has the following requirement:

require(msg.sender == currentKing, "Game: You are already the king. No need to re-claim.");

At the beginning of the function.
If the msg.sender is the currentKing then he/she can claim the throne, and the first King is address(0).

Impact:

Nobody can claim the throne and the game cannot be play.

Proof of Concept:

add the following test in Game.t.sol

function test_claim_throne() public {
vm.prank(player1);
vm.expectRevert("Game: You are already the king. No need to re-claim.");
game.claimThrone{value: INITIAL_CLAIM_FEE}();
}

Recommended Mitigation:

Change the requirement as follow :

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

Appeal created

inallhonesty Lead Judge 21 days ago
Submission Judgement Published
Validated
Assigned finding tags:

Game::claimThrone `msg.sender == currentKing` check is busted

Support

FAQs

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