Rock Paper Scissors

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

Unchecked Return Value in ERC-20 Token Transfer `createGameWithToken()` function in `RockPaperScissors.sol`

🚨 Finding: Unchecked Return Value in ERC-20 Token Transfer

📊 Summary

The createGameWithToken() function in RockPaperScissors.sol executes an ERC-20 transferFrom call without checking the return value. This can lead to inconsistent game state if the token transfer fails silently, particularly if the token does not revert on failure and returns false instead.


🔍 Vulnerable Code

File: RockPaperScissors.sol
Function: createGameWithToken()
Line: ~131

winningToken.transferFrom(msg.sender, address(this), 1); // ⚠️ Return value unchecked

In the current implementation, the return value of transferFrom() is not verified. According to the ERC-20 specification, transferFrom should return true on success and false on failure. Some tokens (e.g., USDT) do not revert on failure, so silent failure may go unnoticed.


📈 Impact

  • A player may be allowed to enter a token-based game without successfully transferring a token.

  • This can lead to locked games where playerB is set but no actual stake was transferred.

  • It breaks game fairness and can be exploited if the token fails to transfer due to lack of allowance or balance.


🔎 Recommendation

Always check the return value of transferFrom() to ensure token transfer was successful:

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

This ensures the function halts execution on transfer failure, preserving protocol integrity and fairness.


📄 Conclusion

Failing to check the return value of ERC-20 token operations introduces logic vulnerabilities that can corrupt game state or be used to bypass requirements. While the impact here is moderate, the fix is simple and should be implemented to conform to secure token interaction practices.

📄 Tool Used

Solidity (Wake)
V1.18.0

Updates

Appeal created

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

Missing Check on External Call Return Value

ERC20 implementation typically reverts on transfer failures

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

Missing Check on External Call Return Value

ERC20 implementation typically reverts on transfer failures

Support

FAQs

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