Rock Paper Scissors

First Flight #38
Beginner FriendlySolidity
100 EXP
View results
Submission Details
Severity: high
Valid

Incorrect Game Joining: Token Games Can Be Joined via ETH Function Without Staking Tokens

Summary

The protocol allows players to join token-based games using ETH functions without staking tokens, violating game rules and enabling unfair token rewards.

Vulnerability Details

RockPaperScissors::joinGameWithEth

The joinGameWithEth function lacks a check to ensure the game was created with ETH (game.bet > 0). This allows players to join token-based games (created via createGameWithToken) by sending msg.value = 0, bypassing token staking requirements.

πŸ”— Code Reference

Impact

  • Unfair Token Minting: Players can win tokens without staking, inflating the token supply.

  • Protocol Integrity: Trust in the game’s fairness is compromised.

  • Direct Financial Loss: Legitimate players lose rewards to exploiters.

Tools Used

  • Manual Code Review

Recommendation

Add a simple check in the joinGameWithEth function to ensure the game was created with ETH:

function joinGameWithEth(uint256 _gameId) external payable {
Game storage game = games[_gameId];
require(game.bet > 0, "Game requires ETH"); // βœ… Add this line
// ... rest of the code ...
}

Proof of Concept (PoC)

function testCreateGameWithEthAndJoinGameWithToken() public {
vm.startPrank(playerA);
​
token.approve(address(game), 1);
vm.expectEmit(true, true, false, true);
emit GameCreated(0, playerA, 0, TOTAL_TURNS);
gameId = game.createGameWithToken(TOTAL_TURNS, TIMEOUT);
​
vm.stopPrank();
vm.startPrank(playerB);
​
game.joinGameWithEth(gameId); // ❌ Incorrectly joins a token game with ETH
​
vm.stopPrank();
}
Updates

Appeal created

m3dython Lead Judge 2 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Game Staking Inconsistency

joinGameWithEth function lacks a check to verify the game was created with ETH

m3dython Lead Judge 2 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Game Staking Inconsistency

joinGameWithEth function lacks a check to verify the game was created with ETH

Support

FAQs

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