An vulnerability exists in the _quantAMMUnpack128Array function's handling of odd-length arrays that affects both the base ScalarRuleQuantAMMStorage contract and its implementations in the QuantAMM system.
This inconsistency manifests in gradient calculations:
And similarly affects variance calculations:
The issue stems from a mismatch between packing and unpacking operations for the final element in odd-length arrays. The corruption of the final element in odd-length arrays has serious implications for pool operations. When the final weight, gradient, or variance value is extracted incorrectly, it creates a persistent error in core calculations that involve complete vector operations. For example, if the final element represents a critical pool weight or variance measure, its corruption directly impacts price calculations and risk assessments for that specific asset or parameter. Given that AMM operations require precise mathematical calculations across all elements, this corruption can cause significant mispricing and incorrect token allocations. The impact is particularly severe in pools with odd numbers of assets, where the corrupted final element could represent a major token's weight or risk parameter, leading to substantial financial losses through incorrect pricing and swaps.
Modify the final element handling to extract high bits instead of low bits:
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.