MyCut

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

Unable to close pot if the claimant are more than 500 due to OOG

Vulnerability Details

The close pot function loops over the claimant array paying each claimant one by one, the problem here is that this could easily become too expensive to do or waste exceeds the blockgas limit which is 30 million in most chains.

For example, the average cost of transferring ERC20 tokens is 65000gas, let's say the total amount of claimants is 500.

The total gas cost will be 65000 * 500 = 32500000, this is over the block gas limit of must chain and will revert.

function closePot() external onlyOwner {
if (block.timestamp - i_deployedAt < 90 days) {
revert Pot__StillOpenForClaim();
}
if (remainingRewards > 0) {
uint256 managerCut = remainingRewards / managerCutPercent;
i_token.transfer(msg.sender, managerCut);
uint256 claimantCut = (remainingRewards - managerCut) / i_players.length;
for (uint256 i = 0; i < claimants.length; i++) {
@-> _transferReward(claimants[i], claimantCut);
}
}
}

Impact

The remaining rewards will be lost forever, and the owner won't get their cut.

Tools Used

Manual analysis

Recommendations

Remove the loop from the claimPot function and create a second function for claimants to get their rewards.

Updates

Lead Judging Commences

equious Lead Judge 9 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Unbound loop in closePot

Support

FAQs

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