Skip to content
Audit finding Intermediate

.latestRoundData() does not update the oracle - ExchangeRate.sol

The oracle's latestRoundData() returns a stale price rather than the current price, so an attacker could deposit when the price is outdated and withdraw after it updates, profiting from the difference. This could lead to a large loss of funds.

A Follow

Originally disclosed on Code4rena

Submitted by adelamo, also found by tensors, JMukesh, cmichel and defsec_

The method .latestRoundData() on an oracle returns the latest updated price from the oracle, but this is not the current price of an asset. To get an accurate current price you need to query it by calling the oracle and waiting for a callback to fulfill the request.

Inaccurate price data could quickly lead to a large loss of funds. Suppose the price of an asset changes downward 5% but your oracle is not updated. A user could deposit funds (credited with an extra 5% since the oracle isn’t updated), wait until .latestRoundData() updates (or update it himself) and becomes accurate. He then withdraws to the same asset he put in for an extra 5%. ExchangeRate.sol L84

Recommend not fetching the latest price (having to call the oracle to update the price instead), and then waiting for the callback.

The original report as published on Code4rena, by a. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the contract reads the oracle's stored latest price without triggering an update and waiting for the fresh value.

Impact

An attacker could profit from stale prices, causing a large loss of funds to the protocol.

What the attacker needed

Oracle price is stale; attacker can deposit and withdraw

The fix

The contract should not fetch the latest price directly; it should request an oracle update and wait for the callback before using the price.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

An oracle is a service that feeds outside price data into a smart contract. This report says the contract reads the last saved price instead of asking for a fresh one, so the price can be out of date. Someone could take advantage of that gap to put money in and take more out.

More by A

View all

1 more disclosed report, best first.

More from Notional contest

View all

The newest disclosed reports for this program.

Similar reports

Same bug class and techniques, clearest first.