Normally, the withdrawWinnings()
function allows users to withdraw their earned ETH by reading their balance from pendingWinnings
, transferring the funds, and then resetting the internal balance to zero. It uses a custom nonReentrant
modifier to prevent reentry.
However, the function violates the Checks-Effects-Interactions pattern by performing the external call before clearing internal state. This creates a vulnerability surface for indirect reentrancy attacks, especially via fallback logic or in future additions to the contract that interact with shared storage (pendingWinnings
). Delegatecalls and cross-function logic may also bypass the intended guard.
Likelihood: High
The function executes an external call (call{value: amount}
) before clearing the user’s pendingWinnings
, which opens the door for fallback-triggered logic to execute in the same transaction context.
In future contract versions or additions, cross-function or delegatecall-based logic could interact with pendingWinnings
during a reentrant fallback, increasing exploit potential.
Impact: Medium
If exploited, an attacker could recursively call withdrawal mechanisms and drain more funds than allocated, leading to unauthorized withdrawals and financial loss.
Even if not exploitable today due to the nonReentrant
modifier, the state mutation order creates fragile assumptions, exposing risk in upgradeable or modular deployments.
Simulated exploit contract:
Foundry test:
nonReentrant
, but it proves the fallback is triggered and the logic is exposed.Follow the Checks-Effects-Interactions pattern strictly. Update the internal state before making external calls:
We only audit the current code in scope. We cannot make speculation with respect to how this codebase will evolve in the future. For now there is a nonReentrant modifier which mitigates any reentrancy. CEI is a good practice, but it's not mandatory. Informational
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.