When _getData
is called the oracles are queried for latest results. If primary oracles are stale, backups are used. And in the cyfrin report 7.2.4 the sponsor responded:
A stale update is better than none because of the way the estimators encapsulate a weighted price and a certain level of smoothing...
Yet the _getData
will return stale data when there are no backup oracles and revert if backup oracles provided and all of them are stale.
Currently the getData oracle fetching logic in summary is:
If only primary oracle exists -> it is up to date -> return UP TO DATE primary oracle data
If only primary oracle exists -> it is stale -> return STALE primary oracle data
If primary and backup oracles exist -> primary stale, but backup up to date -> return UP TO DATE backup oracle data
If primary and backup oracles exist -> primary stale and backup stale -> REVERT
The revert condition can be seen in _getData
backup oracle loop:
Since the sponsor stated that stale data update is better than none, the _getData
should always return data, even if it is stale. Thus the final point creates a conflict and should never happen. In case both are stale quantAmm should decide if it wants to use primary oracle or the oracle with the latest data even if it stale.
Furthermore this is happening in a loop:
Which means even if some oracle returned stale data (no backups), another oracle with backups can still cause the whole function call to revert.
Conflicting existing logic will not return data (revert) if any backup oracles provided and they are all stale, but will return stale data if no backup oracles added. _getData
is used in the main performUpdate
, uplift hook deposit/withdraw/transfer flows. Same severity as the original Cyfrin report -> Medium.
Manual review
If data is prefered over reverting, then _getData
should never revert. And in case all backup oracles are stale: use primary oracle or the oracle with the latest data even if it stale.
Another example to simply return the last fetched oracle data:
Keep in mind that when stale data will always be returned it will need a new check against the following:
So you'll need a check like this before choosing the final output
Since in a case where both main and backup return stale data one of them could be simply disapproved.
Cyfrin audit: 7.2.4 Stale Oracle prices accepted when no backup oracles available
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.