The refund function allows participants to reclaim their deposits (both ERC20 tokens and ETH) before the deadline. However, the function does not update the participant's state after the refund, leaving participant[msg.sender] as true. This can lead to significant vulnerabilities, as refunded participants might retain the ability to participate in functions intended only for active participants.
Root Cause:
The refund function fails to reset the participant[msg.sender] state to false after a successful refund, allowing refunded users to retain participant privileges.
Expected Behavior:
After a refund, participant[msg.sender] should be set to false, ensuring that the participant is no longer recognized as active and preventing unauthorized re-participation.
Current Behavior:
The function refunds the participant’s balances but does not update the participant state. This allows refunded users to:
Retain participant privileges.
Access other functions restricted to participants.
This issue has critical consequences:
State Inconsistency:
The participant state does not align with the participant's actual status, leading to potential logical errors in the protocol.
Economic Exploits:
A malicious actor could repeatedly exploit this state inconsistency to gain unintended advantages.
Manual Code Review
Foundry
1. Update participant State in the refund Function
Modify the refund function to set participant[msg.sender] to false after successfully processing the refund:
2. Add Tests for Participant State Updates
Include unit tests to verify that the participant state is updated correctly after refunds.
A user deposits funds and is marked as a participant (participant[msg.sender] = true).
The user calls refund and retrieves their deposit.
The participant[msg.sender] state remains true.
The user could be the host or attend the event, for example.
By failing to update the participant's state, the refund function introduces the potential for state inconsistencies and economic exploits. Immediate remediation is required to ensure that refunded users are properly excluded from participant-only operations.
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.