The Pot::closePot
function does not properly distribute the remaining rewards to the claimants. The calculation for the claimant's cut uses the length of i_players
instead of claimants
, which can lead to incorrect distribution. Additionally, there is no check to ensure that there is at least one claimant before distributing the rewards.
The Pot::closePot
function in the Pot
contract calculates the claimant's cut using the length of i_players
instead of claimants
. This can result in incorrect distribution of the remaining rewards. Furthermore, if there are no claimants, the remaining rewards should be transferred to the manager instead of being divided among zero claimants.
Proof Of Concept
After the pot has ended (90 days have passed), the owner can call the closePot function. If there are no claimants, the remaining rewards will be incorrectly divided among zero claimants, leading to incorrect distribution.
Place the following test into TestMyCut.t.sol
If the Pot::closePot
function is called, the remaining rewards will be incorrectly distributed among the claimants. This can lead to:
Incorrect reward distribution to claimants.
Potentially leaving tokens locked in the contract
Solidity compiler
Manual code review
Foundry
To mitigate this vulnerability, update the Pot::closePot
function to use the length of claimants instead of i_players
for calculating the claimant's cut. Additionally, add a check to ensure that there is at least one claimant before distributing the rewards. If there are no claimants, a good idea is to transfer the remaining rewards to the manager. Here is an updated version of the Pot contract with the recommended changes:
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.