Christmas Dinner

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

Missing Participant Removal in `ChristmasDinner::refund`

Summary

The refund function is designed to allow participants to withdraw their contributions if they no longer wish to attend the event. However, the implementation lacks a mechanism to remove the participant from the participant list (stored in a mapping). This omission leaves the participant marked as attending despite their refund, leading to potential inconsistencies and exploitation.

Vulnerability Details

The participant mapping stores the attendance status of users, marking them as true when they sign up for the event (ex. through ChristmasDinner::deposit). The refund function allows participants to withdraw their contributions but does not update the participant mapping to remove them from the list. As a result, participants who have been refunded still appear as attending, which could create inaccurate participant records or allow refunded users to potentially exploit other functions dependent on participant status.

PoC

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

assertEq(cd.getParticipationStatus(user1), true);

Run the test with forge test --mt test_refundWithinDeadline -vvvv and observe that the assert passes.

Impact

This vulnerability results in:
- Inaccurate Data: The participant list becomes unreliable, affecting event planning and operations.
- Exploitation Risks: Refunded participants could unfairly benefit from functions intended only for valid attendees and from events, emitted as they became participants but lack of such when refunding.

Tools Used

Manual code review, Foundry

Recommendations

Update the Participant Mapping by removing participants from the list upon a successful refund:

function refund() external nonReentrant {
address payable _to = payable(msg.sender);
require(participant[_to], "Not a participant");
_refundERC20(_to);
_refundETH(_to);
participant[_to] = false; // Fix: Remove participant status after refund
emit ChangedParticipation(_to, participant[_to]);
}
Updates

Lead Judging Commences

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

refund does not update participation status

Support

FAQs

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

Give us feedback!