The withdrawWinnings()
function allows winners to withdraw their ETH safely using a secure withdrawal pattern with reentrancy protection.
The function makes an external call (call{value: amount}
) to the user before updating the state variable pendingWinnings[msg.sender] = 0
. This violates the Checks-Effects-Interactions (CEI) pattern, which is a well-known best practice for secure smart contract development.
The contract uses a nonReentrant
modifier, which protects against reentrancy attacks, but relying solely on this guard instead of also following CEI introduces unnecessary risk and reduces code resilience.
Likelihood:
The issue will occur on every withdrawal, but not in a way that causes failure or loss due to the nonReentrant
modifier.
Impact:
Not following CEI introduces a known anti-pattern, making the code harder to audit and less robust against changes or integrations with external contracts.
Follow CEI: update 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.