QuantAMM

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

Timestamp and price retrieved from MultiHopOracle are not in sync

Summary

This function returns the lowest timestamp from all the oracles, but the data are comming from the last one.

function _getData() internal view override returns (int216 data, uint40 timestamp) {
HopConfig memory firstOracle = oracles[0];
(data, timestamp) = firstOracle.oracle.getData();
...
for (uint i = 1; i < oracleLength; ) {
HopConfig memory oracleConfig = oracles[i];
(int216 oracleRes, uint40 oracleTimestamp) = oracleConfig.oracle.getData();
if (oracleTimestamp < timestamp) {
timestamp = oracleTimestamp; // Return minimum timestamp
}
if (oracleConfig.invert) {
data = (data * 10 ** 18) / oracleRes;
} else {
data = (data * oracleRes) / 10 ** 18;
}
...
}
}

Vulnerability Details

https://github.com/Cyfrin/2024-12-quantamm/blob/a775db4273eb36e7b4536c5b60207c9f17541b92/pkg/pool-quantamm/contracts/MultiHopOracle.sol#L40

_getData function iterates over oracles and it returns data from the last one, and the oldest timestamp. Which might lead to situation where the last oracle has valid current price, but the timestamp is returned from the first oracle.

Example:

Oracle 1: timestamp 100_000, price: 1$

Oracle 2: timestamp <current>, price 0.5$

returns price => 0.5$, timestamp => 100_000

Impact

getData() might return new date with invalid timestamp. So it might give impression that the data are old.

Tools Used

Manual Review

Recommendations

That function should returns data from the highest timestamp, so the prices would be the most accurate.

Updates

Lead Judging Commences

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

invalid_MultiHopOracle_return_oldest_timestamp

Here we’re searching for the weakest element in the chain to know if we can trust the entire chain. That’s why we need the oldest timestamp to check if the all chain returns at least one staled data.

Support

FAQs

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

Give us feedback!