Sparkn

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

Potential DOS with Block Gas Limit

Summary

The Distributor.sol contract contains a potential gas limit vulnerability that arises from the use of a loop to transfer tokens to an array of addresses.

Vulnerability Details

In the _distribute() function, a for loop is used to distribute the rewards to each winner in the array.

for (uint256 i; i < winnersLength;) {
uint256 amount = totalAmount * percentages[i] / BASIS_POINTS;
erc20.safeTransfer(winners[i], amount);
unchecked {
++i;
}
}

The size of the array winners[] and percentages[] is unspecified. It's possible that this function could require more gas than the block limit to complete its execution.

Impact

The transaction may fail due to a large amount of winners and funds will be stuck inside the Proxy contract since there is no function to withdraw tokens that doesn’t rely on _distribute() logic.

Tools Used

Manual review

Recommendations

Implement a claim() function to allow winners to claim their rewards, reducing gas cost or alternatively add a require statement that checks winners.length e.g.

uint256 winnersLength = winners.length;
require(winnersLength <= MAX_WINNERS, "Too many winners");

Support

FAQs

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