Rock Paper Scissors

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

Tokens are minted instead of refunded in tie, cancelled or finished games

Summary

When a game ends in a tie, gets cancelled or finished with a winner, the contract mints new RPSW tokens to players instead of refunding the tokens that were previously transferred into the contract. This creates unnecessary inflation of the token supply and breaks proper accounting.

Vulnerability Details

During token-based game creation and joining, both players transfer one RPSW token each to the game contract:

winningToken.transferFrom(msg.sender, address(this), 1);

However, when the game is cancelled, ends in a tie finished with a winner, instead of refunding the deposited tokens via transferFrom(), the contract uses:

winningToken.mint(game.playerA, 1);
winningToken.mint(game.playerB, 1);

This causes inflation in the total supply of winner tokens, especially problematic in systems where tokens are supposed to be scarce or bounded by gameplay.

Impact

  • Inaccurate token accounting

  • Increased total token supply unnecessarily

  • Potential devaluation of reward tokens

Tools Used

  • Manual code review

Recommendations

Replace token minting with direct transfers from the contract to the players:

if (game.bet == 0) {
- winningToken.mint(game.playerA, 1);
- winningToken.mint(game.playerB, 1);
+ winningToken.transferFrom(address(this),game.playerA, 1);
+ winningToken.transfer(address(this),game.playerB, 1);
}
Updates

Appeal created

m3dython Lead Judge 4 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

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