QuantAMM

QuantAMM
49,600 OP
View results
Submission Details
Severity: low
Invalid

The oracle may return a stale price, causing losses for the protocol.

Summary

The function UpdateWeightRunner::_getData() retrieves data from the oracle and returns it to calculate updated weights. However, in edge cases, this function can return a null value or a price of 0.

Vulnerability Details

The function UpdateWeightRunner::_getData() loops through all the oracles of a token. If all the oracles return stale prices, the function reverts.

However, if there is only one oracle present for a token, the price returned can be 0 (null value).

Consider the function UpdateWeightRunner::_getData():

  • If the optimized oracle returns a stale price, the function attempts to fetch the price from the value stored in the mapping poolBackupOracles[_pool][i][j].

  • In cases where only a single oracle (the optimized oracle) is stored, the value of numAssetOracles = poolBackupOracles[_pool][i].length will be 1. This prevents the execution from entering the for loop due to the condition (j < numAssetOracles)=> 1<1 => false.

The problematic code section:

outputData[i] = oracleResult.data; //@audit In this case, `oracleResult.data` will have a null value.

As a result:

  • outputData[i] stores the staleness result.

  • This staleness price will then be used to calculate the weights.

  • Consequently, the weights will be calculated incorrectly.

Impact

Calculating the weight with a staleness price can lead to incorrect weights, potentially affecting the overall functionality of the protocol.

Tools Used

Manual review.

Recommendations

Add additional checks to handle cases where only one oracle is present. Specifically:

  • Ensure the function verifies that the price is non-zero before using it in weight calculations.

Updates

Lead Judging Commences

n0kto Lead Judge 10 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Appeal created

nikhil20 Submitter
10 months ago
n0kto Lead Judge
10 months ago
n0kto Lead Judge 10 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement
Assigned finding tags:

invalid_stale_price_when_no_backup_oracles_set

Cyfrin audit: 7.2.4 Stale Oracle prices accepted when no backup oracles available

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!