The nonReentrant
modifier in the Christmas Dinner contract does not effectively lock the function against reentrancy attacks. It fails to set the locked
state to true
before function execution, rendering it ineffective. This exposes the contract to potential reentrancy vulnerabilities, especially in the refund()
function.
The nonReentrant
modifier is incorrectly implemented:
The locked
variable is only reset to false
after the function call but is not set to true
initially, allowing attackers to re-enter the function before the lock is applied.
refund()
Any future functions that rely on this modifier for reentrancy protection.
An attacker could exploit the refund()
function to call it multiple times in a single transaction, draining the contract’s balance and causing a loss of funds for legitimate participants.
Manual review of the contract code.
Static analysis using tools such as Slither to identify reentrancy patterns.
Dynamic testing via Echidna to simulate potential exploits.
Update the nonReentrant
modifier to lock the function correctly:
Replace the existing nonReentrant
modifier in the contract with the fixed version above.
Consider using OpenZeppelin’s ReentrancyGuard
for a standardized and well-tested implementation:
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.