Last Man Standing

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

Logical error when checking does `msg.sender` is `currentKing` at `Game.sol::claimThrone()` causes the function always revert, leaves the game unplayable

Logical error when checking does msg.sender is currentKing at Game.sol::claimThrone() causes the function always revert leave the game unplayable

Description

  • `Game.sol::claimThrone()` function intended to be a function that called by players to takes King (currentKing) position

  • However, the check part at the function appears to be always reverted because requiring `msg.sender` to be currentKing while at initial state, there are no king.

Risk

Likelihood:

  • HIGH, players who want to play are using this function to claim the throne to be a King and win the game

Impact:

  • HIGH, always reverted `Game.sol::claimThrone()` function cause the game unplayable. There's no King, no winner, no fee generated. Causing massive losses.

Proof of Concept

// @audit This is a mislogic error, claimThrone() function is for players to claim the throne, therefore the players don't have the currentKing role. This function will always revert whoever msg.sender is causing the game unplayable.
@> require(msg.sender == currentKing, "Game: You are already the king. No need to re-claim.");

Recommended Mitigation

To check does the `msg.sender` is King or not, change the following line:

- 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 about 2 months 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.