Rock Paper Scissors

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

Incorrect use of mint function during refunds in game cancellation and tie scenarios causing loss of staked totekns

Summary

The protocol incorrectly handles token refunds in game cancellation and tie scenarios by minting new tokens instead of returning staked tokens. This results in permanent loss of originally staked tokens and unintended token supply inflation.

Vulnerability Details

Affected Functions:

  1. _cancelGame() - Token refund logic

  2. _handleTie() - Tie resolution logic

Root Cause:

  • When cancelling games or handling ties, the contract attempts to "refund" tokens by minting new ones to players:

// Incorrect implementation in _cancelGame()
winningToken.mint(playerA, 1); // Mints new token
winningToken.mint(playerB, 1); // Instead of returning originals
  • The staked tokens remain permanently locked in the contract while new tokens are created, leading to:

    • Loss of original player tokens

    • Uncontrolled supply growth

Code Proof:

// _cancelGame() snippet
if (game.bet == 0) {
// Should TRANSFER staked tokens back
winningToken.mint(playerA, 1); // Wrong! Creates new tokens
winningToken.mint(playerB, 1);
}

Impact

High Severity:

  • Direct Financial Loss: Players never recover originally staked tokens

  • Contract Lockup: Staked tokens become permanently inaccessible

  • Systemic Risk: Over time, this could collapse token economics

Tools Used

Manual review Identified mismatch between staking/minting logic.

Recommendations

Immediate Fix:

  1. Replace mints with transfers for refunds:

// Corrected _cancelGame() logic
if (game.bet == 0) {
winningToken.transfer(playerA, 1); // Return staked token
winningToken.transfer(playerB, 1);
}

Long-Term Recommendations:

  • Implement a token custody ledger to track player deposits

  • Add circuit breakers for abnormal cancellation rates

  • Use separate contracts for token custody vs game logic

This fix preserves token supply integrity while ensuring players recover their original assets, maintaining the protocol's economic stability.

Updates

Appeal created

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

Minting Instead of Transferring Staked Tokens

Mints new tokens upon game completion or cancellation for token-based games

Support

FAQs

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