The _setInitialMovingAverages function in the QuantammMathMovingAverage contract uses an OR condition to determine when moving averages can be set, leading to potential ambiguity:
For New Pools: The condition allows initialization regardless of _initialMovingAverages.length, potentially causing invalid data to be set.
For New and Existing Pools: If updates are allowed for both new and existing pools, only the length check is required.
pkg/pool-quantamm/contracts/rules/base/QuantammMathMovingAverage.sol:_setInitialMovingAverages#L69
This OR relationship creates ambiguity in the intended behavior: For new pools, the condition allows initialization irrespective of _initialMovingAverages.length, potentially leading to incorrect initial values.
For Both New and Existing Pools: If the function is meant to update moving averages for both new and existing pools, it is sufficient to check:
For New Pools Only: If the function is restricted to new pools, the condition should use an AND relationship to ensure stricter checks:
Data Integrity Risk: Ambiguous logic may cause incorrect behavior, depending on the intended usage.
Operational Vulnerabilities: Incorrect assumptions in the function’s design may lead to inconsistent pool data or overwriting of existing data.
Potential Exploitation: Malicious actors or programming errors could exploit this to tamper with moving averages.
Manual Review
Clarify Intended Functionality: Determine whether _setInitialMovingAverages should support:
Both New and Existing Pools: Simplify the check to ensure only the length matches:
Only New Pools: Update logic to strictly enforce the AND condition.
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.