Price oracle could get a stale price
The wstETH Chainlink oracle contract reads the latest price but does not verify the round ID or timestamp, so it may accept a stale price. An attacker could exploit this to trade at an outdated price, potentially causing financial loss.
rajatbeladiya Follow with Lambda, Chom and 4 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2022-09-notional-judging/issues/133
Found by
rajatbeladiya, Lambda, Chom, Waze, GimelSec, ak1, GalloDaSballo
Summary
_calculateAnswer() will get baseAnswer from Chainlink oracle. But it doesn't check round id and timestamp, leading to it may get a stale price from Chainlink oracle.
Vulnerability Detail
In wstETHChainlinkOracle.sol, it check baseAnswer > 0, but it doesn't check for the stale price by updateAt and roundId.
Impact
Price oracle could get a stale price without checking roundId.
Code Snippet
Tool used
Manual Review
Recommendation
Check answer, updateAt and roundId when getting price:
(uint80 roundId, int256 answer, , uint256 updatedAt, uint80 answeredInRound) = oracle.latestRoundData();
require(updatedAt > 0, "Round is not complete");
require(answer >= 0, "Malfunction");
require(answeredInRound >= roundID, "Stale price");
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 only checks that the price is positive, but omits validation of the round ID and update timestamp from Chainlink's latestRoundData.
Impact
The oracle could return a stale price, potentially allowing trades at incorrect values.
What the attacker needed
None
The fix
The contract should be fixed to check the answer, updateAt, and roundId when fetching 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.
A price oracle is a service that provides current asset prices to a smart contract. This contract fetched the price but didn't check how old it was, so it might use an outdated price. That could let someone trade at a wrong price and profit unfairly.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.