the contract differentiates between scalar (lambda.length == 1
) and vector calculations (lambda.length > 1
):
Scalar Calculation (lambda.length == 1
): Works as expected by using one lambda
value for all operations.
Vector Calculation (lambda.length > 1
): Expected to work with a lambda
array that matches the number of assets (n
).
However, the contract lacks any validation that lambda.length
matches the expected length (n
). This results in the following potential issues:
Out-of-Bounds Access:
If lambda.length
exceeds n
, during the iteration, the code accesses memory at indices that are not valid (lambda[i]
for i >= n
), leading to an out-of-bounds error.
Incomplete Calculation:
If lambda.length
is smaller than n
, the calculation will incorrectly compute the covariance matrix because some assets will lack corresponding lambda
values.
Deploy the contract and initialize it with a pool that has n
assets.
Pass an array lambda[]
with a size greater or smaller than n
.
Call the _calculateQuantAMMCovariance
function with new data.
Observe that the function either:
Accesses an out-of-bounds index when lambda.length > n
.
Results in incorrect computations when lambda.length < n
.
Out-of-bounds errors can result in memory corruption, which can disrupt contract logic and cause unexpected outcomes.
Incomplete covariance calculations will impact critical contract states like pricing or decision-making, potentially causing substantial losses in assets or disrupting intended functionality.
manual
Add a validation check to ensure that lambda.length
is equal to n
before proceeding with the covariance calculations.
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.