The ChristmasDinner contract is vulnerable to re-entrancy attack in the ChristmasDinner::refund function.
The ChristmasDinner::refund function does not follow CEI (Checks, Effects, Interactions) and as a result, enables participants to drain the contract balance. Additionally the nonReentrant function is not properly implemented, the locked state variable is not set to true anywhere making the modifier useless. This modifier adds a false sense of security as seen in the developers comments.
Then the function ChristmasDinner::refund calls _refundETH where it transfers all the msg.senders ETH to his address and only after that it updates the ChristmasDinner::etherBalance array.
All the ETHER balance of the ChristmasDinner contract could be stolen.
Manual review
User deposit ETH to the contract
Attacker sets up a contract with a fallback function that calls ChristmasDinner::refund
Attacker ETH to the contract
Attacker calls ChristmasDinner::refund from their attack contract, draining the ChristmasDinner balance.
PoC Code
Add the following to ChristmasDinner.t.sol
Add following test:
Recommendation: To prevent this, we should have the ChristmasDinner::refund function update the etherBalance array before making the transfer call. Also fix the nonReentrant modifier to set the locked to true.
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.