The _refundERC20
function in the ChristmasDinner contract violates the Check-Effects-Interactions (CEI) pattern by performing external calls before state changes, creating potential reentrancy vulnerabilities despite the presence of a reentrancy guard.
The current implementation performs operations in this order:
Makes external token transfers via safeTransfer
(Interactions)
Updates user balances to zero (Effects)
While the parent refund()
function uses a nonReentrant
modifier, violating CEI:
Makes the code more vulnerable if the reentrancy guard is removed/modified
Could lead to state inconsistencies if token transfers fail
Makes the code less maintainable and harder to audit
Increases gas costs by potentially reading state variables multiple times
Manual Review
Solidity Visual Developer
Restructure the function to follow CEI pattern:
This implementation:
Follows CEI pattern
Uses local variables to cache state reads
Updates state before external calls
Is more gas efficient
Maintains better state consistency
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.