Rock Paper Scissors

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

Players can call commitMove() function multiple times to increase game.revealDeadline

Summary

commitMove() function can be called multiple times to increase game.revealDeadline

Vulnerability Details

PlayerA or PlayerB can call commitMove() function multiple times and increase game.revealDeadline as there is no check before increasing game.revealDeadline to see if player has already committed move.

// If both players have committed, set the reveal deadline
if (game.commitA != bytes32(0) && game.commitB != bytes32(0)) {
game.revealDeadline = block.timestamp + game.timeoutInterval;
}

Impact

malicious player can call commitMove() function multiple times so other player can not call timeoutReveal() function as the check in timeoutReveal() function:

" block.timestamp > game.revealDeadline "

won't be true.

Tools Used

Manual Review

Recommendations

Make these changes

if (msg.sender == game.playerA) {
require(game.commitA == bytes32(0), "Already committed");
game.commitA = _commitHash;
} else {
require(game.commitB == bytes32(0), "Already committed");
game.commitB = _commitHash;
+ game.revealDeadline = block.timestamp + game.timeoutInterval;
}
// If both players have committed, set the reveal deadline
- if (game.commitA != bytes32(0) && game.commitB != bytes32(0)) {
- game.revealDeadline = block.timestamp + game.timeoutInterval;
-}
Updates

Appeal created

m3dython Lead Judge about 2 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement
Assigned finding tags:

Informational

Code suggestions or observations that do not pose a direct security risk.

m3dython Lead Judge about 2 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement
Assigned finding tags:

Informational

Code suggestions or observations that do not pose a direct security risk.

Support

FAQs

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