A vulnerability exists in the Rock-Paper-Scissors (RPS) game smart contract that allows users to bypass token requirements when joining a token-based game. The issue stems from insufficient validation in the joinGameWithEth
function, allowing users to join token games without transferring the required tokens, potentially leading to accounting inconsistencies and economic damage to the protocol.
The contract distinguishes between ETH-based games and token-based games using the game.bet
value:
ETH games: game.bet > 0
(set to the ETH amount sent by the creator)
Token games: game.bet = 0
(explicitly set to zero for token games)
The vulnerability exists in the joinGameWithEth
function:
For token-based games where game.bet = 0
, a user can call joinGameWithEth
with msg.value = 0
, which passes the requirement check msg.value == game.bet
. This allows them to join a token game without sending any tokens, bypassing the token transfer requirement that exists in the proper joinGameWithToken
function:
Users can participate in games without contributing any tokens#
Lack of correct token balancies which will cause errors when it comes time for rewards
The protocol will lack adequate funds to distribute to the rightful recipients
Manual code review
Add an explicit check in the joinGameWithEth
function to ensure it can only be used for ETH-based games:
This additional check prevents users from using the ETH joining function for token-based games, ensuring that users must use the appropriate function which enforces token transfers.
joinGameWithEth function lacks a check to verify the game was created with ETH
joinGameWithEth function lacks a check to verify the game was created with ETH
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.