Sparkn

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

Unbounded loop might cause gas griefing because of long winners.length

Summary

If winners.length is long, gas griefing inside loop is possible.

Vulnerability Details

uint256 winnersLength = winners.length; // cache length
for (uint256 i; i < winnersLength;) { // @audit - unbounded gas consumption
uint256 amount = totalAmount * percentages[i] / BASIS_POINTS;
erc20.safeTransfer(winners[i], amount);
unchecked {
++i;
}
}

Impact

DoS of Prize distribution

Tools Used

Manual Review

Recommendations

Should have maximum limit for winner length.

uint256 winnersLength = winners.length; // cache length
+ require(winnersLength <= MAX_WINNERS_LENGTH, Distributor__WinnersLengthReched());
for (uint256 i; i < winnersLength;) {
uint256 amount = totalAmount * percentages[i] / BASIS_POINTS;
erc20.safeTransfer(winners[i], amount); // @audit - any of the winner is blacklisted.
unchecked {
++i;
}
}

Support

FAQs

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