MyCut

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

Missing Validation of Player and Reward Array Lengths Causes Contest Creation to Revert

Root + Impact

The Pot constructor iterates over the players array and accesses the corresponding element in rewards without checking that both arrays have the same length. If players.length exceeds rewards.length, accessing i_rewards[i] reverts, causing createContest() to fail. This prevents the owner from creating the contest with the supplied inputs.

The issue occurs whenever the owner supplies more players than reward entries. It is an input-validation and availability issue rather than a permissionless fund-draining vulnerability.

Description

The constructor copies both arrays and then iterates over the players without validating their lengths

If the players array contains two addresses but the rewards array contains only one value, the second iteration attempts to read an out-of-bounds array element. Solidity reverts the transaction, so the contest cannot be created with those inputs.

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

Risk

Likelihood: An inconsistent input pair reliably triggers the revert.

Impact: Contest creation fails, but the owner can recover by supplying arrays with matching lengths. No direct loss of funds is established by this issue.

Proof of Concept

Expected result: The constructor reverts when it accesses i_rewards[1], which does not exist.

function testCreateContestRevertsWhenRewardArrayIsShorter()
public
{
address[] memory players = new address[](2);
players[0] = address(0xA1);
players[1] = address(0xB2);
​
uint256[] memory rewards = new uint256[](1);
rewards[0] = 100;
​
vm.expectRevert();
new Pot(
players,
rewards,
IERC20(address(token)),
100
);
}

Recommended Mitigation

Validate the array lengths before storing or processing the supplied values.

This provides a clear validation error and prevents invalid configurations from reaching the reward-assignment loop.

constructor(
address[] memory players,
uint256[] memory rewards,
IERC20 token,
uint256 totalRewards
) {
+ require(
+ players.length == rewards.length,
+ "Players/rewards length mismatch"
+ );
​
i_players = players;
i_rewards = rewards;
Updates

Lead Judging Commences

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