Best Ceramic Yak
Medium
The missing validation checks for the return values of AggregatorV3Interface::latestRoundData
in MasterPriceOracle.sol:83 may allow stale or invalid pricing data to be used. This can lead to inaccurate price feeds on Optimism, exposing users to potential under-collateralization, unnecessary liquidations, or over-collateralization risks.
In MasterPriceOracle.sol:83
, there is no validation of the return values of latestRoundData
, leaving the protocol vulnerable to using stale or invalid price data. Essential fields such as roundId
, updatedAt
, and price
are not verified.
(, int256 price_, , , ) = oracle.latestRoundData();
- The
oracles[underlying]
mapping must point to a valid ChainlinkAggregatorV3Interface
. - An admin initializes the
MasterPriceOracle
with validunderlyings
and_oracles
.
- The Chainlink data feed must provide stale, outdated, or invalid price data (e.g.,
price = 0
orupdatedAt
significantly in the past). - A user or protocol interacts with the
price
function to fetch a price based on the faulty feed.
- A Chainlink oracle provides a stale price due to a lack of sequencer uptime or timeout checks.
- The
MasterPriceOracle::_price
function retrieves this stale price usinglatestRoundData
. - The invalid price is used in downstream calculations, causing inaccurate price-related operations such as borrowing.
The affected users or protocol components may experience:
- Incorrect borrow liquidation based on stale or invalid prices.
- deposit and withdraw usda
No response
To mitigate this issue, implement robust validation checks for the latestRoundData
return values. A recommended implementation is:
(uint80 roundId, int256 price_, , uint256 updatedAt, ) = oracle.latestRoundData();
if (roundId == 0) revert("InvalidRoundId");
if (price_ <= 0) revert("InvalidPrice");
if (updatedAt == 0 || updatedAt > block.timestamp) revert("InvalidUpdate");
if (block.timestamp - updatedAt > TIMEOUT) revert("StalePrice");