MyCut

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

Unbounded loop in `Pot::closePot` function that may lead to a DOS attack.

Description:

The Pot contract features an unbounded loop in the closePot function, which poses a significant risk of causing a Denial Of Service (DOS) attack.

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);
}
}
}

The unbounded nature of this loop introduces a risk where an unexpected surge of claimants could cause the contract to fail or execute critical functions.

Impact:

Function Execution Failure: In the closePot function, a large claimants array may result in the function failing to execute due to running out of gas. This failure could leave the pot open indefinitely, preventing the distribution of rewards and locking funds within the contract. This would disrupt the intended functionality and could lead to significant financial losses for users and the protocol.

Proof of Concept:

Unbounded Loop in closePot Function:

  • Simulate the scenario where a large number of claimants (e.g., 5,000 or more) have participated.

  • Call the closePot function.

  • Observe that the function fails to execute due to running out of gas, preventing the distribution of the remaining rewards.

Recommended Mitigation:

Redesign the reward distribution process to avoid large loops altogether. Consider implementing a pull-based model where each claimant independently claims their reward without relying on the closePot function to distribute rewards.

Updates

Lead Judging Commences

equious Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Other

Appeal created

oxenzo Submitter
about 1 year ago
equious Lead Judge
about 1 year ago
oxenzo Submitter
about 1 year ago
equious Lead Judge about 1 year 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.