sherlock-audit / 2023-05-ironbank-judging

2 stars 2 forks source link

Delvir0 - Missing stale price check from Chainlink oracle #384

Closed sherlock-admin closed 1 year ago

sherlock-admin commented 1 year ago

Delvir0

medium

Missing stale price check from Chainlink oracle

Summary

PriceOraclegetPriceFromChainlink uses latestRoundData and checks if price > 0 for uptime output but does not check if the price is stale.

Vulnerability Detail

Chainlink's latestRoundData could return a stale price, e.g. due to round completeness not met. If this occurs, it has impact on collateral calculation, mostly on IronBank.sol where collateral is calculated to check account liquidity when borrowing or for a liquidation.

Impact

Collateral value could return a wrong value.

Code Snippet

https://github.com/sherlock-audit/2023-05-ironbank/blob/9ebf1702b2163b55479624794ab7999392367d2a/ib-v2/src/protocol/oracle/PriceOracle.sol#L66-L71

Tool used

Manual Review

Recommendation

Next to answer which is used as price here, check the other returned output from Chainlink: uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound

Duplicate of #9