Rock Paper Scissors

First Flight #38
Beginner FriendlySolidity
100 EXP
View results
Submission Details
Severity: low
Invalid

[L-3] Missing Validation in Game Finalization

Description

The internal function _finishGame() is responsible for distributing ETH prizes (if any) and minting a token to the winner. However, it lacks any validation to ensure that the _winner address is one of the players involved in the game (playerA or playerB).

While this is not directly exploitable under the current logic—since _finishGame() is marked internal and only called from controlled game flows—this lack of defensive programming increases the risk of future bugs or misuse, especially if the contract is modified or extended.

Impact

  • Leaves the codebase prone to future logic errors.

  • Could allow token minting or ETH transfers to invalid or unintended addresses in the event of upstream logic flaws.

  • Increases maintenance risk and reduces robustness of the system.

Code

function _finishGame(uint256 _gameId, address _winner) internal {
......
(bool success,) = _winner.call{value: prize}("");
require(success, "Transfer failed");
winningToken.mint(_winner, 1);
}

Recommended Mitigation

Add a validation check to ensure the _winner is indeed one of the participants in the game:

require(_winner == game.playerA || _winner == game.playerB, "Invalid winner address");

Additionally, consider verifying that the game is in a finalizable state (e.g., Finished) to reduce risk of misuse.

Updates

Appeal created

m3dython Lead Judge about 2 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Informational

Code suggestions or observations that do not pose a direct security risk.

m3dython Lead Judge about 2 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Informational

Code suggestions or observations that do not pose a direct security risk.

Support

FAQs

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