The QuantAMMMathMovingAverage contract fails to validate the length of the lambda array in vector mode calculations, allowing mismatched array lengths that could lead to unexpected behavior or array access errors.
Location: pkg/pool-quantamm/contracts/rules/base/QuantammMathMovingAverage.sol
The _calculateQuantAMMMovingAverage
function accepts a lambda array that can be either length 1 (scalar mode) or match the number of assets (vector mode). However, it fails to validate the array length in vector mode, allowing arrays of incorrect length to be processed.
Severity: Low
The lack of validation could lead to:
Unexpected behavior when lambda array length doesn't match asset count
Potential array out of bounds errors in certain scenarios
Incorrect moving average calculations if vector mode is used improperly
The severity is Low because:
Function is internal with controlled access paths
No direct economic impact identified
Likely to cause reversion in most error cases
Main risk is from incorrect implementation of calling code
Add explicit length validation:
Consider adding additional safeguards:
Input validation for all array lengths
Clear documentation of expected array sizes
Events for monitoring calculation parameters
Explicit mode selection rather than inferring from array length
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.