Christmas Dinner

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

function deposit()

Summary

The deposit function in the contract allows users to deposit tokens but does not check if the _amount being deposited is greater than zero.

Vulnerability Details

The deposit function does not enforce a minimum deposit amount, allowing users to call the function with _amount = 0.

function deposit(address _token, uint256 _amount) external beforeDeadline {
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));
}
}

Impact

Inconsistent Balances:

  • Inconsistent Balances:

    • Zero-value deposits update the balances mapping unnecessarily.

  • Misleading Events:

    • Zero-value transactions emit events, falsely suggesting that contributions were made.

Tools Used

Manual review

Recommendations

Add a require check to ensure that _amount > 0 at the start of the deposit function.

function deposit(address _token, uint256 _amount) external beforeDeadline {
require(amount > 0, "Amount must be greater than zero");
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 about 1 year ago
Submission Judgement Published
Invalidated
Reason: Design choice

Support

FAQs

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

Give us feedback!