Christmas Dinner

First Flight #31
Beginner FriendlyFoundrySolidity
100 EXP
View results
Submission Details
Severity: high
Invalid

[H-3] Reentrancy vulnerability in receive() function

Summary

The receive() function is vulnerable to reentrancy attacks due to state updates occurring after ETH transfers and lack of reentrancy protection.

Vulnerability Details

The receive() function updates state after receiving ETH:

receive() external payable {
etherBalance[msg.sender] += msg.value; // State update after ETH transfer
emit NewSignup(msg.sender, msg.value, true);
}

This violates the checks-effects-interactions pattern and lacks reentrancy protection.

Impact

  • Critical: Potential manipulation of participation status

  • Multiple participation records from single deposit

  • Balance tracking manipulation

  • Event spam possible

Tools Used

  • Foundry for testing and exploitation

  • Manual code review

  • Reentrancy exploit test:

contract ReentrancyAttacker {
uint256 private count;
function attack(address dinner) external payable {
(bool success,) = dinner.call{value: msg.value}("");
require(success, "Attack failed");
}
receive() external payable {
if (count < 3) {
count++;
(bool success,) = msg.sender.call{value: 0.3 ether}("");
require(success, "Reentrance failed");
}
}
}

Recommendations

  1. Add nonReentrant modifier to receive():

receive() external payable nonReentrant {
etherBalance[msg.sender] += msg.value;
emit NewSignup(msg.sender, msg.value, true);
}
Updates

Lead Judging Commences

0xtimefliez Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement
0xtimefliez Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.