Rock Paper Scissors

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

Missing Event for Critical Operation in _handleTie Function

Summary

The RockPaperScissors contract is missing an event emission for a critical operation in the _handleTie() function, specifically when minting WinningTokens to players in a tie scenario. This reduces the transparency and observability of important state changes within the protocol.

Vulnerability Details

In the _handleTie() function, WinningTokens are minted to both players when a game ends in a tie:

// Return tokens for token games
if (game.bet == 0) {
winningToken.mint(game.playerA, 1);
winningToken.mint(game.playerB, 1);
}

However, unlike other similar critical operations in the contract, there is no specific event emitted to track these token mint operations. This creates an inconsistency in logging behavior across similar operations in the contract.

For comparison, the FeeCollected event is properly emitted when fees are accumulated:

accumulatedFees += fee;
emit FeeCollected(_gameId, fee);

Impact

The missing event emission reduces:

  1. Transparency: External observers cannot easily track token minting operations specifically related to tie resolution

  2. Auditability: Makes it more difficult to verify that tokens were correctly minted during tie scenarios

  3. User experience: Dapps relying on events to track game outcomes have incomplete information about tie-related token distributions

The impact is medium severity as funds are not directly at risk, but it creates an information asymmetry and inconsistency in the system's observability.

Tools Used

Manual code review

Recommendations

  1. Create a dedicated event for tracking token minting in tie scenarios:

// Add to the event declarations at the top of the contract
event TokensMinted(uint256 indexed gameId, address indexed player, uint256 amount);
  1. Emit the event when minting tokens in the _handleTie() function:

// Return tokens for token games
if (game.bet == 0) {
winningToken.mint(game.playerA, 1);
emit TokensMinted(_gameId, game.playerA, 1);
winningToken.mint(game.playerB, 1);
emit TokensMinted(_gameId, game.playerB, 1);
}
  1. For consistency, also add similar event emissions for other token minting operations throughout the contract, such as in _finishGame() and _cancelGame() functions.

This enhancement maintains consistent observability across the contract and improves the protocol's transparency for users, auditors, and integrating applications.

Updates

Appeal created

m3dython Lead Judge about 2 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.