Platform: Code4rena
Start Date: 19/04/2022
Pot Size: $30,000 USDC
Total HM: 10
Participants: 43
Period: 3 days
Judges: moose-code, JasoonS
Total Solo HM: 7
Id: 90
League: ETH
Rank: 40/43
Findings: 1
Award: $22.05
🌟 Selected for report: 0
🚀 Solo Findings: 0
22.0499 USDC - $22.05
Oracle can retrieve unchecked stale data
In ChainlinkpriceOracle.sol
the function
function refreshedAssetPerBaseInUQ(address _asset) public override returns (uint) { AssetInfo storage assetInfo = assetInfoOf[_asset]; (, int basePrice, , , ) = baseAggregator.latestRoundData(); (, int quotePrice, , , ) = assetInfo.aggregator.latestRoundData(); require(basePrice > 0 && quotePrice > 0, "ChainlinkPriceOracle: NEGATIVE"); uint assetPerBaseInUQ = ((uint(basePrice) * 10**assetInfo.decimals).mulDiv( FixedPoint112.Q112, (uint(quotePrice) * 10**baseDecimals) ) * 10**assetInfo.answerDecimals) / 10**baseAnswerDecimals; assetInfo.lastAssetPerBaseInUQ = assetPerBaseInUQ; return assetPerBaseInUQ; }
Is checking that baseprice and quoteprice are higher than zero. However, according to chainlink documentation you also need to check if the data retrieved is stale
Manual code review
Add
(uint80 roundID, int basePrice, ,uint updatedAt, uint 80 answeredInRound ) = baseAggregator.latestRoundData(); require( updatedAt != 0, “ChainlinkPriceOracle: round is not complete” ); require( answeredInRound >= roundID, “ChainlinkPriceOracle: stale data” );
and the same logic for quotePrice
#0 - olivermehr
2022-05-02T20:26:54Z
Duplicate of issue #1