Rock Paper Scissors

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

DOS caused by large joinTimeout

Summary

Denial of Service can occur when block.timestamp + joinTimeout overflows, preventing players from creating games.

Vulnerability Details

The function RockPaperScissors::setJoinTimeout(uint256 _newTimeout) has a minimum timeout duration, but not a maximum timeout duration.

Therefore, an admin could set the joinTimeout to a value large enough to overflow when added with block.timestamp

This addition occurs in both RockPaperScissors::createGameWithEth(uint256 _totalTurns, uint256 _timeoutInterval) and RockPaperScissors::createGameWithToken(uint256 _totalTurns, uint256 _timeoutInterval)

Impact

Potential players will be unable to create a game no matter if RPSW or ETH is used, and therefore, the contract will be unable to collect fees.

Tools Used

Manual Review.

Recommendations

It is recommended to require a maximum timeout like this:

function setJoinTimeout(uint256 _newTimeout) external {
require(msg.sender == owner(), "Only owner can set timeout");
require(_newTimeout >= 1 hours, "Timeout must be at least 1 hour");
require(_newTimeout <= 31 days, "Timeout must be at most 31 days"); // SOLUTION: add this line!
uint256 oldTimeout = joinTimeout;
joinTimeout = _newTimeout;
emit JoinTimeoutUpdated(oldTimeout, _newTimeout);
}
Updates

Appeal created

m3dython Lead Judge 4 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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