The internal _cancelGame
function incorrectly processes refunds for cancelled token-based games. Instead of returning the WinningTokens previously deposited by the players, it mints new tokens for them, leaving the original deposits locked within the contract.
For token-based games (game.bet == 0
), the standard flow involves Player A depositing 1 WinningToken via createGameWithToken
. If Player B joins using joinGameWithToken
, they also deposit 1 token. Thus, the contract holds 1 or 2 tokens depending on whether Player B joined before cancellation.
If the game is cancelled (e.g., via timeoutJoin
or timeoutReveal
leading to cancellation), the _cancelGame
function is called to handle refunds. The logic for token games within this function is:
The winningToken.mint(...)
calls create new WinningTokens for the players involved. This mechanism fails to return the actual token(s) that were deposited into the contract when the game was created (and potentially joined). These original tokens remain held by the RockPaperScissors contract address.
This vulnerability mirrors the issues found in _finishGame
and _handleTie
, specifically for cancelled games:
Locked Tokens:
The 1 or 2 WinningTokens deposited for the cancelled game become permanently locked within the RockPaperScissors contract. There is no way to retrieve these specific tokens later.
Unnecessary Token Inflation:
The WinningToken supply increases by 1 or 2 tokens (depending on whether Player B joined) for every cancelled token game. This inflates the supply unnecessarily.
Incorrect Refund Mechanism:
Players expect their original deposit back when a game is cancelled. Receiving a newly minted token is not the correct way to handle a refund of staked assets.
Manual code review.
The _cancelGame
function should be updated to transfer the existing tokens held by the contract back to the players involved, instead of minting new ones.
Replace the mint calls with transfer calls:
Mints new tokens upon game completion or cancellation for token-based games
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.