Sparkn

CodeFox Inc.
DeFiFoundryProxy
15,000 USDC
View results
Submission Details
Severity: low
Valid

Unchecked Array Iteration in Distributors

Summary

In the _distribute function, the loop that iterates over the percentages array to calculate the totalPercentage lacks a condition to prevent integer overflow. If the percentages array is very large, this could lead to an unintended overflow, resulting in an incorrect value for totalPercentage. As a consequence, this could disrupt the prize distribution logic and impact the accuracy of the distribution percentages.

for (uint256 i; i < percentagesLength;) {
totalPercentage += percentages[i];
unchecked {
++i;
}
}

Vulnerability Details

If the percentages array is very large, this could lead to an unintended overflow, resulting in an incorrect value for totalPercentage. As a consequence, this could disrupt the prize distribution logic and impact the accuracy of the distribution percentages.

Impact

Without proper checks, an unchecked loop like this may cause an integer overflow, leading to an inaccurate totalPercentage value. This can result in incorrect distribution calculations and potentially unauthorized token transfers.

Tools Used

Manual

Recommendations

To prevent integer overflow, add a condition to validate the length of the percentages array and ensure that it doesn't cause an unintended overflow during iteration. This will help maintain accurate calculations and proper distribution of prizes.

Support

FAQs

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