The RockPaperScissors::createGameWithToken
and RockPaperScissors::joinGameWithToken
functions call the external WinningToken.transferFrom()
before updating internal state variables such as gameCounter
, game.playerA
, or game.playerB
. This breaks the checks-effects-interactions pattern and opens up a reentrancy vector, especially since WinningToken
is a custom contract controlled by the same developers. While this does not currently lead to direct loss of funds or tokens, it introduces unnecessary risk, such as inconsistent game state or malicious recursive calls, especially if the token's behavior changes in the future.
External Call Before State Mutation
Calling transferFrom
before updating internal state allows a malicious token contract to call back into the RockPaperScissors
contract before it's fully initialized.
Missing Reentrancy Guard
Neither function has a nonReentrant
modifier or any other reentrancy lock. If the token calls createGameWithToken
again during transferFrom
, it can cause unintended game creation.
Custom Token Surface
The WinningToken
contract is deployed and owned by this system. If future upgrades add hooks or callbacks (like ERC777-style behavior), the reentrancy path could become exploitable.
Inconsistent State Risk
Reentrant calls during incomplete execution may create multiple partially-initialized games or pollute the games
mapping with corrupted data.
Inconsistent State: Reentrant transferFrom
calls could lead to duplicated or invalid game entries.
Game Counter Pollution: gameCounter++
may be called multiple times unintentionally.
Unexpected Behavior: Hard-to-detect bugs in downstream logic, game listings, or refunds may emerge.
Future-Exploit Vector: If WinningToken
ever adds hooks or changes behavior, this becomes a critical security risk.
Aderyn
Follow the checks-effects-interactions pattern strictly:
createGameWithToken
joinGameWithToken
Add nonReentrant
modifier to both functions for future-proofing.
Document that WinningToken
must not contain callbacks into the game contract.
Even though this issue does not currently result in an exploit, proactively restructuring these functions improves safety, maintainability, and audit readiness.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.