The RockPaperScissors contract allows players to submit bytes32(0)
as a valid commit hash, while simultaneously using the same value (bytes32(0)
) as a sentinel to check if a player has already committed. This creates a critical ambiguity in the contract state and opens the door to multiple exploitation scenarios, including denial of service attacks and game state manipulation.
In the commitMove
function, the contract uses bytes32(0)
to check if a player has already committed:
However, the function never validates that _commitHash
cannot be bytes32(0)
, meaning a player can submit bytes32(0)
as a valid commit value.
Additionally, in the first turn logic check:
The function assumes that bytes32(0)
means "not committed yet," creating a situation where the contract cannot distinguish between a player who has not committed yet and a player who has committed the value bytes32(0)
.
When the _determineWinner
function resets for the next turn, it does the following:
This creates further ambiguity for subsequent turns.
Critical severity. This vulnerability enables multiple attack vectors:
Game State Confusion: A player deliberately submitting bytes32(0)
as their commit hash creates a state where the contract logic cannot determine if they've committed.
Denial of Service: A malicious player could repeatedly submit bytes32(0)
as their commit hash, causing the game to behave unexpectedly or preventing proper state transitions.
Game Stalling: The game could get stuck in the first turn logic branch, as it would always see commitA
and commitB
as bytes32(0)
even after commits have been made.
Revelation Manipulation: A player who committed bytes32(0)
could potentially manipulate the reveal phase since they can claim to have either committed or not committed.
In the worst case, this vulnerability completely breaks the commit-reveal pattern that is fundamental to the Rock Paper Scissors game's fairness.
Manual code review
Explicitly reject zero-hash commits:
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.