Chainlink - Use latestRoundData instead of latestAnswer to run more validations
The contract used Chainlink's latestAnswer, which returns a price without freshness checks. An attacker could exploit stale or invalid price data to cause incorrect valuations and potentially serious consequences.
Submitted by adelamo, also found by 0xRajeev, cmichel, greiart, and shw_
UniswapV3Oracle.sol is calling latestAnswer to get the last WETH price. This method will return the last value, but you won’t be able to check if the data is fresh. On the other hand, calling the method latestRoundData allow you to run some extra validations
(
roundId,
rawPrice,
,
updateTime,
answeredInRound
) = AggregatorV3Interface(XXXXX).latestRoundData();
require(rawPrice > 0, "Chainlink price <= 0");
require(updateTime != 0, "Incomplete round");
require(answeredInRound >= roundId, "Stale price");
See the chainlink documentation for more information.
talegift (Wild Credit) confirmed
Since slate prices could have quite serious consequences, I’ll bump it to medium risk.
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 used latestAnswer instead of latestRoundData, missing validations for positive price, non-zero update time, and round completeness.
Impact
Stale prices could have quite serious consequences, potentially leading to incorrect contract behaviour.
What the attacker needed
None
The fix
The contract should use latestRoundData and add checks for rawPrice > 0, updateTime != 0, and answeredInRound >= roundId.
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.
A smart contract relied on an external price feed but used a simple function that only gives the latest number, without checking if that number is old or from a valid round. If the price data is stale, the contract might make decisions based on wrong information, which could be exploited.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.