The QuantAMMMathGuard contract is vulnerable to integer overflow/underflow in its weight calculations, allowing weights to reach extreme negative values (~-1e34) that completely break the system's mathematical foundations. This vulnerability could be exploited to manipulate pool prices and potentially drain assets.
Location: pkg/pool-quantamm/contracts/rules/base/QuantAMMMathGuard.sol
The issue occurs when processing extreme input values during weight calculations. The contract fails to properly validate and bound input weights, leading to arithmetic overflow in the normalization process.
Exploit Conditions:
Input weights: [6.837e50, 1.167e33]
Previous weights: [0.98e18, 0.01e18, 0.01e18]
epsilonMax: 0.01e18 (1%)
Result:
Attacker identifies pool with concentrated weights
Submits transaction with carefully crafted weight values
Triggers overflow in normalization calculation
Pool enters invalid state with extreme negative weights
Price calculations become invalid
Attacker exploits price discrepancies for profit
Severity: CRITICAL
Technical Impact:
Integer overflow leads to extreme negative weights (~-1e34)
Completely breaks pool mathematics and pricing
Bypasses existing guard rails
System becomes unusable
Affects all pools using QuantAMMMathGuard
Economic Impact:
Potential for complete pool failure
Could be exploited for economic gain through arbitrage
May affect connected pools or protocols
Loss of user funds possible
Reputational damage to protocol
Foundry fuzzing tests
Manual code review
Mathematical analysis of normalization algorithm
Custom test suite for weight boundary conditions
Add Comprehensive Input Validation:
Implement Safe Arithmetic:
Use OpenZeppelin's SafeMath for all calculations
Add overflow checks at critical points
Consider using uint256 instead of int256 for weights
Implement safe normalization algorithm
Add System-Wide Safeguards:
Implement circuit breakers for extreme weight changes
Add monitoring for unusual weight distributions
Consider gradual weight adjustment mechanism
Add invariant checks throughout weight update process
This is distinct from the previously reported negative weights issue (mathguard-negative-weights.md):
Different root cause (arithmetic overflow vs algorithmic flaw)
Much larger magnitude (-9.999e33 vs -0.096e18)
Requires different mitigation strategies
More severe impact on system stability
Potentially more exploitable for economic gain
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.