A vulnerability exists in the _quantAMMPack128Matrix function of the VectorRuleQuantAMMStorage contract where the absence of proper matrix dimension validation can lead to data corruption or reverts in core covariance calculations. Here's the vulnerable implementation:
The contract's storage packing assumes square matrices throughout its logic, as evidenced by these impacted functions:
If a non-square matrix is passed (which is possible due to lack of validation), it could result in:
The absence of square matrix validation creates a critical vulnerability in the QuantAMM's covariance calculations. When a non-square matrix is processed by _quantAMMPack128Matrix(), it either results in array access errors (if rows are too short) or incorrect data packing (if rows are too long). These packed values are then used by _calculateQuantAMMCovariance() for updating pool weights and prices. In the case of array access errors, the transaction reverts, potentially freezing pool operations. More dangerously, if rows are longer than expected, the excess data gets packed, leading to incorrect covariance calculations that directly affect asset pricing and pool balances. Since the matrix dimensions are fundamental assumptions in the AMM's mathematical model, any violation compromises the entire system's reliability.
Add explicit validation of matrix dimensions:
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.