The RockPaperScissors smart contract contains a vulnerability in its game cancellation functionality. Currently, only the game creator (Player A) can cancel a game that is still in the created state. Player B, despite having joined and staked funds or tokens, lacks the ability to cancel the game before moves are committed, creating an unfair power imbalance in the contract's permission structure.
The vulnerability exists in the cancelGame function (lines 310-318):
This function explicitly checks that the message sender is game.playerA, preventing Player B from canceling the game even if they've joined but no moves have been committed. This creates an asymmetric power dynamic where Player B has no exit option until the game progresses to the next phase or reaches a timeout.
The issue is particularly concerning because:
Player B has already committed funds (ETH) or tokens to the game
The game is still in an early state (no moves committed)
Player B is forced to wait for the timeout or for Player A to take action
While it doesn't result in direct loss of funds (as Player B can eventually recover their stake through timeout mechanisms), it creates an unfair user experience and potentially locks Player B's funds or tokens for extended periods. Player B must wait for the game to timeout or for Player A to voluntarily cancel the game, with no ability to exit independently.
This could lead to:
Temporary fund/token lockup for Player B
Poor user experience and lack of control
Potential game abandonment by Player A, forcing Player B to wait for timeout periods
Manual code review
Implement a modified cancelGame function that permits both players to cancel the game while in the created state, but with different behavior based on which player initiates the cancellation:
The deadline is increased if playerB canceled so that in situations where playerB canceled close to the deadline, the creator does not have to create a new game. and since playerA can cancel anytime, this does not create any issue.
Protocol does not provide a way for Player B to exit a game and reclaim their stake if Player A stops participating
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.