The quantAMMUnpack32Array function in ScalarQuantAMMBaseStorage contract contains a critical uninitialized variable vulnerability. The stickyEndSourceElem variable is used for handling "sticky end" elements (remaining elements that don't complete a 256-bit slot) but is left uninitialized in crucial execution paths.
The function's initialization logic creates a dangerous gap in memory management. The stickyEndSourceElem variable is only initialized within a nested conditional structure, specifically when the target array length exceeds 8 and is not divisible by eight. However, the variable is subsequently used in the sticky end handling logic regardless of these conditions.
This uninitialized state leads to undefined behavior when processing arrays with specific lengths. When the target length is 8 or less, or when it's greater than 8 but divisible by 8, the code proceeds to use this uninitialized variable in critical memory operations:
This vulnerability poses a severe risk to the protocol's operation. When the uninitialized variable is used, it can corrupt critical state data used for variance and gradient calculations that directly influence pool pricing. This corruption would silently propagate through the system's exponential decay calculations and moving averages, leading to increasingly incorrect pool weights and pricing. Since these calculations compound over time and directly affect user funds, this vulnerability puts significant financial value at risk.
Initialize stickyEndSourceElem at declaration:
Add validation to ensure proper array access:
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.