The RockPaperScissors
smart contract fails to bind player addresses to their committed moves, allowing malicious actors to reuse or intercept another player's commitment. This vulnerability undermines the fairness of the game and opens the door for replay attacks or unauthorized move revelations.
The commit-reveal mechanism implemented in the RockPaperScissors contract allows players to commit to their moves by hashing the move and a secret. However, the contract does not include the player's address in the commitment hash, which leads to the following issues:
Replay Attack:
A malicious player (e.g., Player B) can copy a previously observed commitment from the other player (Player A) and use it as their own, effectively mirroring moves without knowing the secret.
Reveal Phase Exploitation: If Player A later reveals their move and secret, Player B can use the same values to reveal too, and pass the hash check. Since there’s no per-player validation of who originally committed the move, B’s reveal will be accepted.
Game Integrity Compromise:
This allows Player B to always mirror Player A’s commitment, guaranteeing at least a draw or even a win if they selectively reveal. It also opens the door to front-running, collusion, or scripted manipulation in a competitive setting.
The vulnerability allows a malicious player to replicate a legitimate player's commitment and reveal actions, because the contract does not bind moves to player addresses. This breaks the integrity and fairness of the game, enabling:
Commitment spoofing (e.g., B copies A's move).
Forced draws or avoided losses through selective reveals.
Unfair wins, leading to loss of rewards or funds.
Manual Code Review
Foundry (Test framework)
Custom test cases simulating malicious reveal and replay scenarios
Bind Commitments to Player Address:
Change the commitment scheme to include the player’s address when generating the hash, e.g.:
Update Reveal Logic Accordingly:
Ensure that during the reveal phase, the hash is recomputed using msg.sender, the revealed move, and the secret, and that it matches the stored commitment.
Test for Malicious Behavior:
Add unit tests to ensure that a player cannot reuse another’s commitment or spoof reveals.
The contract does not enforce salt uniqueness
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.