Both the deposit function and the receive function lack a minimum contribution check. The absence of such a check allows participants to register with zero value, either via _amount in the deposit function or via msg.value in the receive function. This undermines the protocol’s integrity by allowing users to bypass the intended minimum financial contribution.
Root Cause:
The deposit function does not validate that _amount > 0 before processing the deposit.
The receive function does not validate that msg.value > 0 before adding ETH to the participant’s balance and registering them.
Expected Behavior:
Both functions should enforce a minimum contribution amount to ensure that participants contribute to the total funds.
Current Behavior:
The deposit function allows participants to register with _amount = 0.
The receive function allows participants to register with msg.value = 0.
This vulnerability compromises the event's financial integrity by allowing participants to register without meaningful contributions, which could lead to:
Reduced Total Funds: Some participants might exploit this to avoid contributing while still benefiting from participation.
Financial Planning Issues: Organizers cannot rely on the contributions to meet the event's funding goals.
Exploitation via Bots: Automated bots could exploit this to register multiple zero-value participants, bloating the participant list.
Manual code review
Foundry
Running the test without the fix will show the function execution succeeds:
Test failed: deposit(0) did not revert as expected.
After the fix, the test will pass:
Test passed: deposit(0) reverted.
This PoC highlights that the lack of validation for _amount allows participants to bypass the financial contribution requirement.
1 - Add Validation for _amount: Update the deposit function to include a check for _amount > 0:
2 - Add Validation for msg.value in receive:
Update the receive function to reject zero-value contributions.
3 - Test Validation Logic: Add unit tests to ensure deposits with _amount <= 0 revert as expected.
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.