Christmas Dinner

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

The `deposit` Mechanism Does Not Support Signing Up Friends

Vulnerability Details

The ReadMe.md file and the deposit Natspec comment on line 107 (* Allows a user to sign-up other users.) indicate that users should be able to sign up their friends for the Christmas dinner event. However, the deposit function does not enable this functionality, as it relies on msg.sender to register participants, preventing users from signing up others.

Here is deposit function that does not support signing up friends.

function deposit(address _token, uint256 _amount) external beforeDeadline {
// @audit: the deposit mechanism does not allow user to sign-up other users.
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

Users are not allowed to sign-up other users.

Recommended Mitigation

To address this issue, consider updating the deposit function to use an address user parameter instead of relying on msg.sender for the sign-up process.

- function deposit(address _token, uint256 _amount) external beforeDeadline {
+ function deposit(address _token, uint256 _amount, address user) 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;
+ participant[user] = true;
balances[msg.sender][_token] += _amount;
IERC20(_token).safeTransferFrom(msg.sender, address(this), _amount);
- emit NewSignup(msg.sender, _amount, getParticipationStatus(msg.sender));
+ emit NewSignup(user, _amount, getParticipationStatus(user));
}
}
Updates

Lead Judging Commences

0xtimefliez Lead Judge about 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

Deposit function lacks functionality

Support

FAQs

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

Give us feedback!