Rock Paper Scissors

First Flight #38
Beginner FriendlySolidity
100 EXP
View results
Submission Details
Severity: medium
Valid

Opponent’s move can be predicted before committing

Summary

The mechanism used to generate a _commitHash for the RockPaperScissors::commitMove function is weak.

Vulnerability Details

If a player reuses the same combination of move + salt across multiple games, the resulting commitHash will be identical. Since the commitment is public on-chain, an attacker can store known commitHash values and their corresponding moves from past games.

For example:

  1. playerA once committed to keccak256(abi.encodePacked(Move.Rock, saltA))

  2. The attacker previously lost to that commit with Move.Scissors, revealing the actual move.

  3. In a future game, the attacker observes the same** commitHash** used again.

  4. The attacker now knows** **playerA is playing Rock, and can safely commit Move.Paper to guarantee a win.

Impact

This breaks the commit-reveal secrecy model and allows strategic players or bots to front-run or script predictable wins by analyzing historical data.

Tools Used

Manual review

Recommendations

Make the salt dynamic. e.g hash with `block.timestamp`

keccak256(abi.encodePacked(block.timestamp, uint8(move), salt))
Updates

Appeal created

m3dython Lead Judge 7 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Lack of Salt Uniqueness Enforcement

The contract does not enforce salt uniqueness

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.