Rock Paper Scissors

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

Multiple reentrancy point in `RockPaperScissors` contract can lead to Denial of Service (DoS) attack

Summary

In the RockPaperScissors contract, there are multiple reentrancy points that could be exploited by an attacker, if wrapping the WinningToken in a malicious contract was possible. Therefore, the contract is vulnerable to reentrancy attacks, due to these functions that call external contracts and modify state after the call:

  • createGameWithToken()

  • joinGameWithToken()

require(
winningToken.balanceOf(msg.sender) >= 1,
"Must have winning token"
);
// ...
winningToken.transferFrom(msg.sender, address(this), 1);
// Modifying state after interactions
Game storage game = games[gameId];
game.playerA = msg.sender;
game.bet = 0; // Zero ether bet because using token
game.timeoutInterval = _timeoutInterval;
game.creationTime = block.timestamp;
game.joinDeadline = block.timestamp + joinTimeout;
game.totalTurns = _totalTurns;
game.currentTurn = 1;
game.state = GameState.Created;
emit GameCreated(gameId, msg.sender, 0, _totalTurns);
return gameId;

Vulnerability Details

Impact

If an attacker can wrap the WinningToken in a malicious contract, they could exploit the reentrancy vulnerability to drain funds or manipulate the game state.

POC

  1. An attacker creates a malicious contract that wraps the WinningToken and implements a reentrancy attack on balanceOf() and transferFrom().

  2. The attacker calls createGameWithToken() or joinGameWithToken() with the malicious contract as the winningToken.

  3. The attacker can then exploit the reentrancy vulnerabilities to block the process with reverting calls.

  4. No other player can create or join a game until the attacker decides to stop the attack.

Tools Used

Aderyn and manual review.

Recommendations

Implement the checks-effects-interactions pattern to avoid changing state after external calls.

Updates

Appeal created

m3dython Lead Judge 4 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
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.