MyCut

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

Unbounded loop in the `Pot::constructor` that may lead to a DOS attack.

Description:

The Pot contract features an unbounded loop in its constructor, which pose a significant risk of causing a Denial of Service (DOS) attack.

constructor(address[] memory players, uint256[] memory rewards, IERC20 token, uint256 totalRewards) {
i_players = players;
i_rewards = rewards;
i_token = token;
i_totalRewards = totalRewards;
remainingRewards = totalRewards;
i_deployedAt = block.timestamp;
@> for (uint256 i = 0; i < i_players.length; i++) {
playersToRewards[i_players[i]] = i_rewards[i];
}
}

The unbounded nature of these loop introduces a risk where an unexpected surge in players could cause the contract to fail to deploy or execute critical functions.

Impact:

Deployment Failure: If the i_players array in the constructor is excessively large, the contract's deployment will fail due to exceeding the block's gas limit. This failure effectively prevents the contract from being created and used.

Proof of Concept:

  1. Unbounded Loop in Constructor:

    • Attempt to deploy the Pot contract with a large i_players array (e.g., 10,000 or more players).

    • The deployment will fail, and the constructor will not complete its execution due to exceeding the gas limit.

Recommended Mitigation:

Impose a maximum limit on the size of the i_players array. This limit ensures that the loop does not grow to a size that could exceed the block gas limit.

Updates

Lead Judging Commences

equious Lead Judge about 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

Unbound for loop in Contest Creation

Support

FAQs

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