MyCut

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

Constructor Does Not Validate That players.length == rewards.length

Constructor Does Not Validate That players.length == rewards.length

DescriptionNormal behavior

Each player should have exactly one corresponding reward.

For example:

Alice → 100
Bob → 200
Charlie → 300

Therefore:

players.length == rewards.length

must always hold.

Specific issue

The constructor directly accesses:

i_rewards[i]

for every element in i_players.

No length validation exists.

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

Risk

Likelihood:

  • Invalid input can be supplied by the caller of createContest().

Impact:

  • Contest deployment reverts.

  • Incorrect contest configuration cannot be detected with a clear custom error.

Proof of Concept

function testMismatchedArraysRevert() public {
address[] memory players = new address[](3);
uint256[] memory rewards = new uint256[](2);
​
// Pot deployment reverts when i == 2.
new Pot(players, rewards, token, 300);
}
​

Recommended Mitigation

constructor( address[] memory players, uint256[] memory rewards, IERC20 token, uint256 totalRewards ) { + if (players.length != rewards.length) { + revert InvalidArrayLength(); + } ... }
Updates

Lead Judging Commences

ai-first-flight-judge Lead Judge about 1 hour 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!