Rock Paper Scissors

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

Unchecked transferFrom Leads to Token-less Game Creation in `RockPaperScissors:createGameWithToken()`

Summary

The createGameWithToken function calls winningToken.transferFrom(msg.sender, address(this), 1) without validating the return value. This is known as an unchecked ERC20 transfer vulnerability.

In Solidity, the transferFrom function of an ERC20 token returns a boolean value indicating the success or failure of the operation. If this value is not explicitly checked, malicious or non-standard tokens can falsely report a successful transfer, allowing users to bypass the token requirement.

Vulnerability Details

Transfer token to contract

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

This line assumes the token transfer always succeeds, without verifying it.

Proof of Concept (PoC)

A malicious token contract:

function transferFrom(address, address, uint256) public pure returns (bool) { return true; // or return false; }

Using this fake token, an attacker calls:

fakeToken.approve(gameContractAddress, 1);
gameContract.createGameWithToken(3, 300);

No real tokens are transferred, but the game is created.

Impact

An attacker can:

  • Deploy a fake ERC20 token that always returns true or false from transferFrom.

  • Call createGameWithToken() to create a game without actually transferring any tokens.

  • This undermines the token-based game logic and can result in abuse of the game system or denial-of-service against other users.

Tools Used

Manual Review

Recommendation

Update the token transfer line to

require(winningToken.transferFrom(msg.sender, address(this), 1),"Token transfer failed" );
Updates

Appeal created

m3dython Lead Judge about 2 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Informational

Code suggestions or observations that do not pose a direct security risk.

m3dython Lead Judge about 2 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Informational

Code suggestions or observations that do not pose a direct security risk.

Support

FAQs

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