The functions RockPaperScissors::joinGameWithEth()
and RockPaperScissors::joinGameWithToken()
allow any player to join an existing game as long as its state is Created
. However, there is no validation to check whether playerB
has already been assigned, which allows a new player to overwrite the existing playerB
.
This introduces a critical issue: if a second player has already joined, and another user calls the join function again, they can replace the original playerB, effectively hijacking the game. If ETH or tokens were already transferred by the original playerB, these funds may become unrecoverable or locked without resolution.
A malicious user can overwrite the original playerB and claim the game.
The overwritten playerB may lose ETH or tokens sent during their join.
This leads to game inconsistencies and broken trust in the protocol.
Could be abused to intentionally grief or sabotage other players.
Test: Join Overwrite Race Condition with joinGameWithEth()
PlayerA creates a new game.
PlayerB joins the game and transfers the required ETH.
PlayerC also joins the same gameId, overwriting PlayerB.
PlayerB attempts to call commitMove()
.
The function reverts with the message "Not a player in this game"
.
Add a validation to prevent overwriting playerB if already assigned:
Manual Review Foundry
Game state remains Created after a player joins
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.