The for
loop inside the Pot::constructor
override the playersToRewards[i_players[i]]
with new reward i_rewards[i]
.So if a player's address appears multiple times, the reward is overwritten rather than accumulated. This results in the player receiving only the reward from the last occurrence of their address in the array, ignoring prior rewards.
Proof of Concept:
Suppose i_players contains [0x123, 0x456, 0x123] and i_rewards contains [100, 200, 300].
The playersToRewards mapping will be updated as follows during construction:
For address 0x123 at index 0, reward is set to 300.
For address 0x456 at index 1, reward is set to 200.
For address 0x123 at index 2, reward is updated to 100.
As a result, the final reward for address 0x123 in playersToRewards will be 100, not 400 (300+100).This leads to incorrect and lower reward distributions.
Proof of Code (PoC):
place the following in the TestMyCut.t.sol::TestMyCut
The overall integrity of the reward distribution process is compromised. Players with multiple entries in the i_players[] array will only receive the reward from their last occurrence in the array, leading to incorrect and lower reward distributions.
Manual Review
Recommended Mitigation:
Aggregate the rewards for each player inside the constructor to ensure duplicate addresses accumulate rewards instead of overwriting them.This can be achieved by using the += operator in the loop that assigns rewards to players.
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.