OracleLib.sol
implements a hardcoded TIMEOUT value, which is used in the staleCheckLatestRoundData()
function to know if the returned price is stale or not, however in some instances this could be side stepped, see Vulnerability Details
As previously stated in Summary, we can see in this line that TIMEOUT has been hardcoded to three hours.
Additionally it's been used here:
Now the issue is that 3 hours is actually too long for some feeds, take ETH/USD or BTC/USD as an example (using this as an example since DSC is primarily supposed to be backed by BTC/ETH), here is the feed for ETH?USD as seen it has a deviation threshold of 0.5% and also a heartbeat of 1 hour, which means that in the case the price does not make a 0.5% difference in any direction it's supposed to get updated within 1 hour, now would be key to note that stale price checks are done in order to make sure that the right price is integrated, in a case where an update does not get relayed from chainlink within the past hour for any of these feeds the price is stale.
Which means that all instances of querying prices would be affected, use the getUsdValue() as an example
Would be important to note that this function is also used while checking the health factor of an account, or while getting it's information, and multiple other instances within DSCEngine.sol:
This easily means that in the case where a stale price is integrated, the calculation of user's current state in the internal _healthFactor()
could be wrongly returned as above 1 and they can't get liquidated where as they are below the healthy level, leading to DSC allowing users hold over-collaterized tokens, alternatively the current state could be returned as below 1 and users get unfairly liquidated whereas their account is above the healthy level.
DSC would work with outdated price data for ETH/USD and BTC/USD.
Manual Audit
Set a different TIMEOUT value for different feeds, it should be shorter than 3 hours for the aforementioned feeds, i.e BTC, ETH.
Additionally since it's being relayed in the public discord chat that any erc20 token that has a USD chainlink feed can be used for protocol then respective checks should be made for each and the timeout value should be set based on their heartbeats.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.