In the QuantAMMCovarianceBasedRule abstract contract, the _calculateQuantAMMCovariance function calculates the covariance matrix, a crucial component for updating pool weights. This process relies on a decay factor lambda (lambda), which balances historical data with recent observations. However, the absence of a validation check for lambda's value introduces significant vulnerabilities. Without a proper threshold, lambda can fall outside its intended range, leading to erratic calculations and destabilization of the protocol.
QuantAMMCovarianceBasedRule::_calculateQuantAMMCovariance:
Unvalidated Lambda: Without validation, lambda could exceed the range, resulting in:
Exponential growth of covariance values.
Erratic or unstable pool weight updates.
Overly reactive or overly rigid weight behavior.
Length Mismatch: Missing length validation for _newData and movingAverage arrays could lead to out-of-bounds errors, causing transaction failures or undefined behavior.
Explosive Growth in Covariance Values: Results in instability and increased protocol risk.
Erratic Pool Behavior: Causes unpredictable and unreliable pool weight updates.
Oscillatory or Divergent Covariance Updates: Invalidates portfolio performance and renders the system unreliable.
Loss of Trust: Deters users and liquidity providers due to unreliable behavior.
Potential Funds Loss: Leads to higher impermanent loss or exploitable conditions in the market.
Manual Review
Add a validation check to ensure lambda remains within a valid range before it is used:
Or, for fixed-point arithmetic:
Additionally, ensure that array lengths are validated before processing to avoid out-of-bounds errors. For example:
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.
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.