Christmas Dinner

First Flight #31
Beginner FriendlyFoundrySolidity
100 EXP
View results
Submission Details
Severity: medium
Valid

Missing Participant Registration for ETH Contributions in `receive()`

Summary

The receive() function allows participants to contribute ETH to the contract. However, it does not update the participant mapping, which is critical for tracking contributors and enabling features like being the new host. As a result, ETH contributors are effectively excluded from the contract's participant management system.

Vulnerability Details

The function records the ETH contribution by updating etherBalance[msg.sender] and It emits the NewSignup event, suggesting that the sender is considered a participant.
However, it does not update the participant mapping (participant[msg.sender] = true), leaving ETH contributors untracked in this system.

PoC

Append the following line of code at the end of the test_depositEther function in the test suite:

assertEq(cd.getParticipationStatus(user1), false);
Run the test by `forge test --mt test_depositEther -vvvv` and observe that the assert passes.

Impact

  1. Exclusion from Participant-Specific Features: ETH contributors may be unable to participate in functionalities relying on the participant mapping (ex. choosing a new host).

  2. Event Log Misrepresentation: Emitting the NewSignup event without registering the sender as a participant creates a discrepancy between the event logs and the contract’s internal state, which could mislead other entities, relying on the emissions.

Tools Used

Manual code review, Behavioral analysis of contract logic

Recommendations

Modify the receive() function to include the sender in the participant mapping, similar to ChristmasDinner::deposit function :

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

Lead Judging Commences

0xtimefliez Lead Judge about 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

receive does not update participation status

Support

FAQs

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

Give us feedback!