Players can prematurely cancel a game using the timeoutReveal
function even when the game hasn't entered the reveal phase. This is possible because the revealDeadline
may not be initialized yet if only one player has committed their move.
The timeoutReveal
function is designed to resolve games when one or both players fail to reveal their moves after committing. However, the function lacks a guard to ensure that the reveal phase has actually started.
The following check in the function is vulnerable:
Since revealDeadline
is initialized only after both players commit, its default value is 0. This allows any player to call timeoutReveal()
after the game has started but before both commitments are submitted, causing an unintended cancellation.
Premature game cancellation
Disruption of game flow
Potential abuse to escape from a losing position
Manual code review
Foundry
The following test simulates a scenario where Player B commits their move but Player A calls timeoutReveal()
before the reveal phase has officially started. Since revealDeadline
is still zero, the timeout succeeds and the game is improperly cancelled.
The following test_playerAUsesTimeoutRevealBeforeDeadlineSet
test function can be placed in the RockPaperScissorsTest.t.sol file:
Add a guard to ensure the reveal deadline has been set before allowing timeout:
This ensures that the timeout logic can only execute after both players have committed and the reveal phase is officially active.
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.