MyCut

First Flight #23
Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: high
Invalid

Missing Check of rewards[] and totalAwards in Constructor (Pot.sol)

Summary

The sum of the rewards array should be checked to be equal to totalAwards (Pot.sol). totalAwards is used to set i_totalRewards and remainingRewards.

Vulnerability Details

constructor(address[] memory players, uint256[] memory rewards, IERC20 token, uint256 totalRewards) {
i_players = players;
i_rewards = rewards;
i_token = token;
i_totalRewards = totalRewards;
remainingRewards = totalRewards;
i_deployedAt = block.timestamp;
//@audit - need to check that sufficient rewards were provided. That totalRewards equals the sum of all rewards in rewards[]
// i_token.transfer(address(this), i_totalRewards);
for (uint256 i = 0; i < i_players.length; i++) {
playersToRewards[i_players[i]] = i_rewards[i];
}
}

Impact

If there is a mismatch between the rewards[] and the totalAwards, the remainingRewards variable will potentially be too high or too low, resulting in an accounting problem. This will potentially distribute incorrect amounts to the players.

Tools Used

Manual Review

Recommendations

Implement a check in the constructor to ensure that the sum rewards[] == totalAwards.

Updates

Lead Judging Commences

equious Lead Judge 12 months ago
Submission Judgement Published
Invalidated
Reason: Known issue

Support

FAQs

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