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 {
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));
}
}