Should check return data from chainlink aggregators #1
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
invalid
This doesn't seem right
sponsor disputed
Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue
Lines of code
https://github.com/code-423n4/2022-04-mimo/blob/main/core/contracts/inception/priceFeed/ChainlinkInceptionPriceFeed.sol#L78
Vulnerability details
Impact
The getAssetPrice function in the contract ChainlinkInceptionPriceFeed.sol fetches the asset price from a Chainlink aggregator using the latestRoundData function. However, there are no checks on roundID nor timeStamp, resulting in stale prices. The oracle wrapper calls out to a chainlink oracle receiving the latestRoundData(). It then checks freshness by verifying that the answer is indeed for the last known round. The returned updatedAt timestamp is not checked.
If there is a problem with chainlink starting a new round and finding consensus on the new value for the oracle (e.g. chainlink nodes abandon the oracle, chain congestion, vulnerability/attacks on the chainlink system) consumers of this contract may continue using outdated stale data (if oracles are unable to submit no new round is started)
Although there is a timestamp check, Round ID is not checked in the function. That can also cause stale price.
Proof of Concept
https://github.com/code-423n4/2022-04-mimo/blob/main/core/contracts/inception/priceFeed/ChainlinkInceptionPriceFeed.sol#L78
Medium Severity Issue From The FEI Protocol : https://consensys.net/diligence/audits/2021/09/fei-protocol-v2-phase-1/#chainlinkoraclewrapper-latestrounddata-might-return-stale-results
Tools Used
Code Review
Recommended Mitigation Steps
Consider to add checks on the return data with proper revert messages if the price is stale or the round is incomplete, for example:
Consider checking the oracle responses updatedAt value after calling out to
chainlinkOracle.latestRoundData() verifying that the result is within an allowed margin of freshness.
The text was updated successfully, but these errors were encountered: