MyCut

AI First Flight #8
Beginner FriendlyFoundry
EXP
View results
Submission Details
Impact: medium
Likelihood: low
Invalid

[M-1]Missing Length Validation at ContestManager::createContest() function

Missing Length Validation Between players[] and rewards[] Arrays Leads to Incorrect Reward Mapping

Description

In ContestManager::createContest(), the owner passes two arrays to the Pot constructor:

  • players[]

  • rewards[]

However, there is no validation ensuring:

players.length == rewards.length

Inside the Pot constructor, rewards are assigned using:

for (uint256 i = 0; i < i_players.length; i++) {
playersToRewards[i_players[i]] = i_rewards[i];
}

If rewards.length < players.length, the loop will attempt to access an out-of-bounds index in i_rewards, causing a revert.

If rewards.length > players.length, some reward values will never be mapped, causing inconsistent accounting between i_totalRewards and actual assigned rewards.

Because no validation exists in either createContest() or the Pot constructor, the contract allows inconsistent array inputs.


Risk

Likelihood: Low

Reason 1:
Only the owner can call createContest(), so this is a misconfiguration risk.


Impact: Medium

Impact 1:
Contest deployment may revert due to out-of-bounds access.

Impact 2:
Reward mapping may become inconsistent, potentially leading to incorrect distribution or locked funds.


Proof of Concept

Scenario 1 — rewards.length < players.length (Revert / DoS)

players = [alice, bob, charlie]; // length = 3
rewards = [100, 200]; // length = 2
  • Loop in constructor accesses i_rewards[2] → ❌ out-of-bounds → revert

  • Contest deployment fails → functional denial of service

Scenario 2 — rewards.length > players.length (Incorrect mapping)

players = [alice, bob]; // length = 2
rewards = [100, 200, 300]; // length = 3
  • Extra reward 300 is never assigned → inconsistent accounting

  • totalRewards ≠ sum of mapped rewards → logic inconsistency



Recommended mitigation

Validate array lengths before deployment.

+ require(players.length == rewards.length, "Length mismatch");
Updates

Lead Judging Commences

ai-first-flight-judge Lead Judge about 7 hours ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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

Give us feedback!