Last Man Standing

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

`currentKing` check in `Game::claimThrone()` doesn't allow anyone to call the function

Description

The check to see whether the caller is currentKing or not in claimThrone() is wrong as it only allows zero address to call it instead of the other way around.

Impact

Not a single user can participate in the game at all. This check makes the contract unusable, it is DoSing itself.

PoC

function claimThrone() external payable gameNotEnded nonReentrant {
require(msg.value >= claimFee, "Game: Insufficient ETH sent to claim the throne.");
@> require(msg.sender == currentKing, "Game: You are already the king. No need to re-claim.");
...
}

As the initial currentKing value is set to address(0) by default, this check only allows address(0) to call it, which is impossible. Even if currentKing is given a valid address value, no one would be able to successfully claim the throne except that initial address.

Mitigation Steps

+ 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 4 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.

Give us feedback!