QuantAMM

QuantAMM
49,600 OP
View results
Submission Details
Severity: low
Invalid

Lack of Normalized Weight Invariant Check in setWeights Function

Summary

The setWeights function fails to enforce the normalized weight invariant, which ensures that the sum of weights equals FixedPoint.ONE.

This check is present in the _setInitialWeights function but is missing in setWeights, creating a significant inconsistency.

Without this check, invalid weight updates can disrupt the pool’s behavior, potentially causing incorrect balance calculations and trading operations.

Vulnerability Details

In the _setInitialWeights function, the contract ensures the sum of weights equals FixedPoint.ONE:

if (uint256(normalizedSum) != FixedPoint.ONE) {
revert NormalizedWeightInvariant();
}

However, in the setWeights function, there is no equivalent check to validate the updated weights:

if (_weights.length > 8) {
int256[][] memory splitWeights = _splitWeightAndMultipliers(_weights);
_normalizedFirstFourWeights = quantAMMPack32Array(splitWeights[0])[0];
_normalizedSecondFourWeights = quantAMMPack32Array(splitWeights[1])[0];
} else {
_normalizedFirstFourWeights = quantAMMPack32Array(_weights)[0];
}

The lack of this validation means that the weights could sum to a value other than FixedPoint.ONE, breaking the invariant that the pool depends on for its calculations.

Impact

The absence of normalized weights can lead to invalid balance calculations, disrupting the pool's trading and weight adjustment logic.

Recommendations

To address this vulnerability, add a validation check in the setWeights function to ensure the sum of weights equals FixedPoint.ONE

Updates

Lead Judging Commences

n0kto Lead Judge 10 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

invalid_sum_of_weights_can_exceeds_one_no_guard

According the sponsor and my understanding, sum of weights does not have to be exactly 1 to work fine. So no real impact here. Please provide a PoC showing a realistic impact if you disagree. This PoC cannot contains negative weights because they will be guarded per clampWeights.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.