There is a hardcoded value in Distributor.sol::_distribute
.
it can cause funds to stay stuck forever or miscalculate distribution of prizes (depending on the value change) if Owner changes the BASIS_POINTS value before deploying or in a future upgraded implementation and creates a new contest with the changed implementation.
lets say COMMISSION_FEE is still 500 and Owner changes the BASIS_POINTS value to 9,000 and forgets to change the hardcoded value then he creates a new contest with this new implementation. Following will happen when contest ends and organizer tries to distribute the funds.
Organizer will create the data as bellow and sets the percentage to 8500 (totalPercentage = BASIS_POINTS - COMMISSION_FEE) as there is only one winner.
But the distribute
function will revert with error Distributor__MismatchedPercentages();
because 8500 != 9500
.
So the only way to execute distribute
function is to pass the percentage as 9500 because the if statement requires it to be (10000 - COMMISSION_FEE = 9500) which will cause the erc20.safeTransfer(winners[i], amount);
function to always revert because the following formula will always calculate more amount then the balance of contest.
lets say COMMISSION_FEE is still 500 and Owner changes the BASIS_POINTS value to 20,000 and forgets to change the hardcoded value then he creates a new contest with this new implementation. Following will happen when contest ends and organizer tries to distribute the funds.
Organizer will create the data as bellow and sets the percentage to 19500 as there is only one winner.
But the distribute
function will revert with error Distributor__MismatchedPercentages();
because 19500 != 9500
.
So the only way to execute distribute
function is to pass the percentage as 9500 because the if statement requires it to be (10000 - COMMISSION_FEE = 9500) which will cause way less prize distribution to winner and way more commission distribution to protocol.
Funds can stay stuck forever or prizes and commission fee can be miscalculated.
Manual analysis
Replace the hardcoded value with BASIS_POINTS as below.
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.