As per the WeightedMath
, the normalized weight has a boundary which is between 0.01 and 0.99. If the normalized weight set by the setWeights
function breaks this boundary, the computeBalance
will revert due to math overflow.
The comments in WeightedMath
imply that the boundary of the normalized weights is between 0.01 and 0.99:
However, the boundary of the normalized weights is not checked in the setWeights
function in QuantAMMWeightedPool
contract:
If the weights are out of bounds, this may lead to an overflow in the WeightedMath
calculation. For example, the computeBalance
function will revert due to the math overflow.
Adding the following test case in QuantAMMWeightedPool2TokenTest
, it sets the weights to 0.0006 and 0.9994
run forge test --match-test testComputeBalanceInitial
We can see that the computeBalance
will revert due to math overflow.
The impact is HIGH because this will dos the computeBalance
function.
The likelihood is LOW because the weight should be less than 0.01 or greater than 0.99, which is not a normal case.
As a result, the severity should be MEDIUM.
Manual Review
In QuantAMMWeightedPool
contract, consider adding a check on the weight boundaries in the setWeights
function.
Likelihood: Low, this will only happen in extreme case. Impact: High, DoS computeBalance which is used to add liquidity for single tokens
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.