The Collateral.getPrice() function makes an unchecked external call to an IPriceAdapter contract to fetch the price of a collateral asset. If the priceAdapter address is invalid or the external call fails, the transaction will revert, potentially disrupting the system. This unchecked external call introduces risks such as denial of service and reliance on an untrusted oracle.
The getPrice() function is defined as follows:
Unchecked External Call : The function directly calls IPriceAdapter(priceAdapter).getPrice() without any safeguards. If the priceAdapter contract reverts or behaves maliciously, the entire transaction will fail.
No Fallback Mechanism : There is no backup mechanism (e.g., caching the last valid price or using a secondary oracle) in case the external call fails.
Invalid Price Adapter Risk : While the function checks that priceAdapter is not zero, it does not validate whether the address points to a legitimate IPriceAdapter implementation. A malicious or misconfigured address could cause issues.
An attacker exploits a governance flaw or gains control over the priceAdapter address.
The attacker sets the priceAdapter to a malicious contract that always reverts when getPrice() is called.
Any function relying on getPrice() (e.g., getAdjustedPrice()) will fail, causing disruptions in collateral valuation and pricing.
Alternatively, the attacker sets the priceAdapter to an invalid address (e.g., a non-contract address), causing the external call to revert.
Denial of Service : Functions relying on getPrice() will fail, rendering critical operations unusable.
Financial Losses : Incorrect or unavailable pricing data could lead to improper valuations, affecting debt calculations, liquidations, and rewards.
Oracle Dependency : The system becomes overly reliant on a single external oracle, introducing centralization risks.
Manual Code Review : Analyzed the getPrice() function and its interactions with the priceAdapter.
Slither : Static analysis tool used to identify unchecked external calls and potential vulnerabilities.
MythX : Security analysis platform used to verify risks associated with external calls and oracle dependencies.
Add a fallback mechanism to handle external call failures gracefully. For example:
Introduce a cachedPrice field in the Collateral.Data struct to store the last valid price.
Multiple Oracles : Implement a decentralized oracle system with multiple price feeds. Use a median or weighted average of prices to reduce reliance on a single source.
Price Validation : Add validation to ensure the fetched price is within an acceptable range compared to the last known price.
Governance Controls : Restrict updates to the priceAdapter address to trusted entities using role-based access control (RBAC).
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.