QuantAMM

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

Weight Normalization Bypass in QuantAMM Guard Rails Due to Single-Weight Correction

Vulnerability Detail

The QuantAMMMathGuard contract implements guard rails for weight updates in the QuantAMM protocol through its _normalizeWeightUpdates() function. This function is responsible for ensuring that weight updates respect both the maximum change limit (_epsilonMax) and that weights sum to ONE (1e18).

The current implementation attempts to correct any deviation from the target sum by adding the entire difference to the first weight:

_newWeights[0] = _newWeights[0] + (ONE - newWeightsSum);

This creates a vulnerability where an attacker could manipulate input weights to force a large correction on the first weight, potentially breaking the guard rail constraints. While the implementation assumes corrections will be minimal (around 1e-18), there's no enforcement of this assumption.

For example, if an attacker provides weights that sum to significantly less than ONE after epsilon-based rescaling, the entire difference would be added to _newWeights[0], potentially causing it to exceed the _absoluteWeightGuardRail limit that was previously enforced by _clampWeights().

Impact

Pool weights can be manipulated beyond their intended guard rail limits, enabling potential price manipulation.

Recommendation

Implement proportional distribution of weight corrections across all tokens instead of applying to a single weight:

if (abs(ONE - newWeightsSum) > ACCEPTABLE_DEVIATION) {
revert WeightDeviationTooLarge();
}
int256 weightDiff = ONE - newWeightsSum;
for (uint i = 0; i < _newWeights.length; i++) {
_newWeights[i] = _newWeights[i] + (weightDiff * _newWeights[i] / newWeightsSum);
}
Updates

Lead Judging Commences

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

Informational or Gas / Admin is trusted / Pool creation is trusted / User mistake / Suppositions

Please read the CodeHawks documentation to know which submissions are valid. If you disagree, provide a coded PoC and explain the real likelyhood and the detailed impact on the mainnet without any supposition (if, it could, etc) to prove your point.

Support

FAQs

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