The createContest()
function in the ContestManager
contract does not include essential validation checks to ensure that the length of the players
array matches the length of the rewards
array, and that the sum of the rewards
matches totalRewards
. When the players
array is shorter than the rewards
array, excess rewards remain unclaimed, leading to locked funds and an inaccurate reward distribution.
The createContest()
function is responsible for creating a new Pot
contract and distributing rewards to players. However, the function lacks critical validation checks:
players.length == rewards.length
: The number of players should match the number of rewards. If the rewards array is longer than the players array, the excess rewards will not be assigned to any player and will remain unclaimed.
sum(rewards) == totalRewards
: The sum of the individual rewards should match the totalRewards
value. Without this check, either some funds will be locked in the contract, or there won’t be enough rewards for all players, causing discrepancies.
Without these validation checks, funds may remain unclaimed and locked in the contract, leading to a loss of tokens and potential misuse of resources.
Initial Setup:
The owner creates a new contest with 3 players but provides rewards for 5 players.
players = [Player1, Player2, Player3]
rewards = [100, 200, 300, 400, 500]
totalRewards = 1500
Outcome:
Players 4 and 5 will not be able to claim their rewards because there are no matching player entries for these rewards.
As a result, 900 tokens (400 + 500) remain locked in the contract and cannot be accessed or reclaimed, leading to a loss of funds.
Impact: The contract continues execution without an error, allowing players to claim rewards, but excess rewards remain unclaimed and locked in the contract, which could lead to a permanent loss of funds.
Unclaimable Rewards: If there are more rewards than players, the extra rewards will not be claimed, and these funds remain locked in the contract, creating an unfair distribution.
Locked Funds: Without proper validation, excess rewards may be left in the contract, becoming inaccessible. These locked funds can only be recovered through additional unsafe mechanisms or may remain indefinitely locked.
Steps to Reproduce the Issue:
Step 1: Deploy the ContestManager
contract.
Step 2: Call the createContest()
function with mismatched player and reward array lengths or a total reward value that does not match the sum of the rewards.
Expected Outcome: An error should occur, preventing the contest from being created.
Actual Outcome: The contract allows the creation of the contest, but players may not be able to claim rewards or some funds may be locked.
Manual Review
Add validation checks in the createContest()
function to ensure the length of the players
and rewards
arrays match, and that the sum of the rewards equals totalRewards
.
Check if players.length == rewards.length
: Add a check to ensure that the number of players matches the number of rewards:
Check if sum(rewards) == totalRewards
: Calculate the sum of the rewards and compare it with totalRewards
:
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.