The refund() function in the ChristmasDinner contract lacks proper access control, allowing any address to call it regardless of whether they are a registered participant or not.
The refund() function is designed to return deposited funds to participants who wish to withdraw from the Christmas dinner event. However, the function does not verify if the caller is actually a registered participant before processing the refund.
Current implementation:
The function only checks:
Reentrancy protection via nonReentrant
Deadline hasn't passed via beforeDeadline
It critically misses checking if participant[msg.sender] is true before processing the refund.
While the actual impact may be limited since the refund amount is based on recorded balances, this represents a significant security flaw that:
Allows unauthorized access to a privileged function
Wastes gas through unnecessary function calls and failed transfers
Could potentially be exploited if combined with other vulnerabilities
Pollutes the event logs with invalid Refunded events
Manual review
Add a participant check at the start of the function:
Additionally:
Add a custom error NotParticipant() to the contract
Consider adding balance checks before attempting transfers
Update the participant status to false after successful refund
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.