No `minAnswer/maxAnswer` Circuit Breaker Checks while Querying Prices in Oracle.sol
The Oracle contract does not check whether Chainlink price feeds return the minimum or maximum configured answer, so if an asset's market price falls outside that band, the oracle keeps reporting the boundary value. An attacker could then borrow or interact with the protocol using an incorrect, inflated price for a crashed asset.
Bauchibred Follow with BugBusters, Hama and 3 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2023-04-hubble-exchange-judging/issues/241
Found by
Bauchibred, BugBusters, Hama, crimson-rat-reach, ni8mare, rogue-lion-0619
Summary
The Oracle.sol contract, while currently applying a safety check (this can be side stepped, check my other submission ) to ensure returned prices are greater than zero, which is commendable, as it effectively mitigates the risk of using negative prices, there should be an implementation to ensure the returned prices are not at the extreme boundaries (minAnswer and maxAnswer).
Without such a mechanism, the contract could operate based on incorrect prices, which could lead to an over- or under-representation of the asset's value, potentially causing significant harm to the protocol.
Vulnerability Details
Chainlink aggregators have a built in circuit breaker if the price of an asset goes outside of a predetermined price band. The result is that if an asset experiences a huge drop in value (i.e. LUNA crash) the price of the oracle will continue to return the minPrice instead of the actual price of the asset. This would allow user to continue borrowing with the asset but at the wrong price. This is exactly what happened to Venus on BSC when LUNA imploded.
In its current form, the getUnderlyingPrice() function within the Oracle.sol contract retrieves the latest round data from Chainlink, if the asset's market price plummets below minAnswer or skyrockets above maxAnswer, the returned price will still be minAnswer or maxAnswer, respectively, rather than the actual market price. This could potentially lead to an exploitation scenario where the protocol interacts with the asset using incorrect price information.
Take a look at Oracle.sol#L106-L123:
function getLatestRoundData(AggregatorV3Interface _aggregator)
internal
view
returns (
uint80,
uint256 finalPrice,
uint256
)
{
(uint80 round, int256 latestPrice, , uint256 latestTimestamp, ) = _aggregator.latestRoundData();
finalPrice = uint256(latestPrice);
if (latestPrice <= 0) {
requireEnoughHistory(round);
(round, finalPrice, latestTimestamp) = getRoundData(_aggregator, round - 1);
}
return (round, finalPrice, latestTimestamp);
}
Illustration:
- Present price of TokenA is $10
- TokenA has a minimum price set at $1 on chainlink
- The actual price of TokenA dips to $0.10
- The aggregator continues to report $1 as the price.
Consequently, users can interact with protocol using TokenA as though it were still valued at $1, which is a tenfold overestimate of its real market value.
Impact
The potential for misuse arises when the actual price of an asset drastically changes but the oracle continues to operate using the minAnswer or maxAnswer as the asset's price. In the case of it going under the minAnswer malicious actors obviously have the upperhand and could give their potential going to zero worth tokens to protocol
Code Snippet
Tool used
Manual Audit
Recommendation
Since there is going to be a whitelist of tokens to be added, the minPrice/maxPrice could be checked and a revert could be made when this is returned by chainlink or a fallback oracle that does not have circuit breakers could be implemented in that case
Discussion
asquare08
This is a valid concern. But we will fix this in later releases as initially, we are launching with blue chip tokens only and single collateral (USDC).
asquare08
As mentioned in this comment, we'll fix this later.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the oracle contract does not verify that the price returned by Chainlink is not equal to the aggregator's configured minimum or maximum answer, so it accepts boundary values as real market prices.
Impact
If an asset's price falls below the minimum or rises above the maximum, the protocol could operate on an incorrect price, allowing users to borrow or interact with the asset at an over- or under-estimated value.
What the attacker needed
Asset price moves outside Chainlink band; protocol accepts the asset as collateral
The fix
The contract should check for minAnswer/maxAnswer and revert, or use a fallback oracle without circuit breakers; the team said they will fix this in later releases.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A price oracle is a service that tells a smart contract what an asset is worth. Chainlink, a common oracle, has a safety feature that stops reporting prices outside a set range, so if an asset crashes it may keep reporting the lowest allowed price instead of the real one. This report says the contract never checks for that situation, so it could keep trusting a price that is no longer true.