A vulnerability exists in the VectorRuleQuantAMMStorage contract where the _quantAMMPack128Matrix function performs unsafe storage writes that could corrupt arbitrary contract state. Here is the vulnerable code section:
This vulnerability is particularly dangerous because the function is called directly from QuantAMMCovarianceBasedRule's core logic:
The issue is severe because:
The function performs storage writes using an unchecked index
Storage layout in Solidity is sequential, meaning overflow could corrupt:
Other state variables in VectorRuleQuantAMMStorage
State in inherited contracts like QuantAMMCovarianceBasedRule
Critical AMM parameters like pool weights and balances
Example exploitation scenario:
The vulnerability in array bounds checking affects the integrity of the QuantAMM's storage system. While the initial length check provides some protection, subsequent unchecked increments of targetArrayIndex within the matrix packing loop could still result in out-of-bounds writes. The primary risk lies in corruption of the packed covariance data itself, as the storage slots adjacent to the matrix array likely contain other critical pool parameters. If targetArrayIndex exceeds bounds, it would overwrite these adjacent parameters, potentially corrupting pool weights, fee calculations, or other AMM state variables. This would cause the pool to operate with incorrect parameters until the corruption is detected, though the likelihood of bypassing the initial length check is relatively low.
Add explicit bounds checking before storage writes:
Remove the unchecked block from critical operations:
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.