Rock Paper Scissors

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

Missing non-zero ETH value in joinGameWithEt() __RockPaperScissors.sol

Summary

The joinGameWithEth function does not check whether the joining player sends a non-zero ETH value.

Vulnerability Details

Without this check, a player can join the game without contributing any ETH, effectively entering for free.
Currently, there is no validation to ensure that the player has paid, which breaks the expected behavior of ETH-based games.

function joinGameWithEth(uint256 _gameId) external payable {
Game storage game = games[_gameId];
game.playerB = msg.sender;
emit PlayerJoined(_gameId, msg.sender);
}

Impact

Free entry: A player can join without paying

Tools Used

Manual review

Recommendations

Add a check to ensure msg.value > 0 before allowing a player to join.

Corrected code:

function joinGameWithEth(uint256 _gameId) external payable {
require(msg.value > 0, "Must send ETH to join");
Game storage game = games[_gameId];
game.playerB = msg.sender;
emit PlayerJoined(_gameId, msg.sender);
}
Updates

Appeal created

m3dython Lead Judge about 2 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement
m3dython Lead Judge about 2 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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