Christmas Dinner

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

The `ChristmasDinner::deposit` function lacks a non-zero amount check, allowing zero-value payments to become a member.

Summary

In the ChristmasDinner::deposit function, there is no check to ensure that the value of _amount is greater than zero, allowing attackers to become a participant by passing _amount=0 without actually paying any funds. This vulnerability could be exploited maliciously, impacting the fairness and integrity of the contract.

Vulnerability Details

The ChristmasDinner::deposit function does not verify whether the _amount parameter is greater than zero. An attacker can exploit this by passing _amount=0 to bypass the actual transfer of funds while still becoming a participant. In this case, the attacker can enjoy the privileges or features within the contract without contributing any funds.

The lack of strict validation for input values, especially those related to funds, exposes potential risks in fund management and access control, which may be abused to achieve unfair advantages.

Impact

  • Abuse of Contract Features: An attacker can become a participant by paying _amount=0, potentially gaining access to certain exclusive features or privileges.

  • Financial Loss: If the contract relies on participant status for fund allocation or benefits, this vulnerability may harm the interests of actual contributors.

  • Damage to System Integrity: The contract's reputation and participant trust could be damaged due to exploitation of this vulnerability, reducing community engagement.

Tools Used

Manual review.

Recommendations

Add a check in the deposit function to ensure that _amount is greater than zero.

function deposit(address _token, uint256 _amount) external beforeDeadline {
+ require(_amount > 0, "Amount must be greater than 0");
if(!whitelisted[_token]) {
revert NotSupportedToken();
}
if(participant[msg.sender]){
balances[msg.sender][_token] += _amount;
IERC20(_token).safeTransferFrom(msg.sender, address(this), _amount);
emit GenerousAdditionalContribution(msg.sender, _amount);
} else {
participant[msg.sender] = true;
balances[msg.sender][_token] += _amount;
IERC20(_token).safeTransferFrom(msg.sender, address(this), _amount);
emit NewSignup(msg.sender, _amount, getParticipationStatus(msg.sender));
}
}
Updates

Lead Judging Commences

0xtimefliez Lead Judge 11 months ago
Submission Judgement Published
Invalidated
Reason: Design choice

Support

FAQs

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