The RockPaperScissors contract implements a commit-reveal pattern to prevent players from seeing each other's moves before making their own. However, the contract does not enforce any minimum entropy requirements for the salt values used in the commitment hashes. This allows players to use predictable or weak salt values, potentially making their moves guessable and undermining the security of the game.
The commit-reveal mechanism is designed to maintain fairness in the game by requiring players to first commit to a move by submitting a hash, then reveal the actual move and salt used to create that hash. The security of this pattern relies on the unpredictability of the salt value. Without requirements for salt entropy, players might use simple, guessable values such as bytes32(0)
, sequential numbers, or common strings like "salt", making their moves potentially predictable to sophisticated opponents.
The contract never enforces or validates that the salt has sufficient entropy. It only checks that the hash of the move and salt matches the previously committed hash. This means a player could use a weak or predictable salt, potentially allowing an opponent to guess their move by brute-forcing common salt values.
Compromised game fairness: Players using weak salts may have their moves predicted, giving an unfair advantage to opponents.
Reduced security of commit-reveal: The core security mechanism becomes less effective for players who don't follow good salt generation practices.
Strategy leakage: In multi-turn games, a player who successfully guesses an opponent's move pattern based on weak salts gains a significant advantage.
While this vulnerability requires some sophistication to exploit and isn't guaranteed to work in all cases (depends on player behavior), it fundamentally undermines the commit-reveal security model that the game relies on.
Manual code review
Enforce minimum salt entropy:
Auto-incorporate additional entropy:
Document best practices: Provide clear guidelines to users on generating strong, unique salts for each game and move.
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.