Skip to content
DoS Audit finding Intermediate

PriceFeed is likely to be disabled in times of volatility, causing liquidations and borrows to freeze

The price aggregator reverts when the closest two of three price feeds differ by more than a configured percentage, so during high volatility liquidations and borrows freeze. An attacker could not directly exploit this, but the protocol becomes unable to liquidate undercollateralised positions when it matters most.

niroh Follow with oakcobalt

Originally disclosed on Code4rena

Submitted by niroh, also found by oakcobalt

https://github.com/code-423n4/2024-01-salty/blob/53516c2cdfdfacb662cdea6417c52f23c94d5b5b/src/price_feed/PriceAggregator.sol#L142

https://github.com/code-423n4/2024-01-salty/blob/53516c2cdfdfacb662cdea6417c52f23c94d5b5b/src/price_feed/PriceAggregator.sol#L183

https://github.com/code-423n4/2024-01-salty/blob/53516c2cdfdfacb662cdea6417c52f23c94d5b5b/src/price_feed/PriceAggregator.sol#L195

  1. The price feed aggregator relies on three feeds (Chainlink feeds, Uniswap 30 minute TWAP and Salty spot price) to report pricing. The aggregation logic is to average the closest two feed prices, and if the price difference between them exceeds maximumPriceFeedPercentDifferenceTimes1000 (default value: 3%), the aggregator reverts. Since liquidation and borrowing operations rely on price feed reporting, these will revert as well when the minimum price disparity between the three oracles exceeds maximumPriceFeedPercentDifferenceTimes1000.
  2. In times of price volatility for the reported pairs (ETH/USD, BTC/USD) the three oracles used are likely to diverge by more than the 3% limit. To understand why, consider the following traits of each of the three feed sources:
  3. Uniswap 30 minutes TWAP reports the time weighed average over the last 30 minutes.
  4. Chainlink uses multiple sources (onchain Dexes, Cexes) and reports immediately on price changes larger than 0.5% (the Chainlink update trigger setting for the two feeds used.)
  5. Salty reports the immediate price taken from the relevant pools on Salty at the time (block) of price aggragation.
  6. When volatility is high, the 30 minutes TWAP is likely to diverge from spot oracles such as Chainlink feeds and Salty’s pools. If for example the market price shifts drastically within 5 minutes, Uniswap’s TWAP will only weigh the change at 20% and the previous price at 80%, while Chainlink and Salty will report the most recent price. In such conditions, a 3% price difference is likely to happen.
  7. Since Salty’s liquidity is likely to be much smaller than the Uniswap pools used (Weth/Wbtc and Weth/Usdc) its reported price is likely to diverge from Uniswap’s price, especially when sharp price shifts occur. This is because large pools such as Uniswaps are likely to be arbitraged sooner (to match centralized exchanges where price discovery typically happens) and smaller pools take longer to catch up to the new price.
  8. The result is that is times of high volatility, Salty’s price feed is likely to enter a state of >3% disparity between the feeds, effetively blocking liquidations at the time they are most crucial.
  9. The maximumPriceFeedPercentDifferenceTimes1000 parameter can be extended up to 7% through a DAO vote, but given that every 0.5% increase requires a vote duration of 10 days at least, the DAO is not likely to react it time to adjust for market volatility.

Tools Used

Foundry

Recommended Mitigation Steps

The common behavior for DeFi price feed aggregators is to fallback to the most trustworthy oracle rather than abort. Typically, Chainlink is selected as the preferred fallback due to the diversity of its sources and reputation of stability. It is recommended to follow this principle and fallback to Chainlink’s price instead of reverting when prices diverge by more than the max.

othernet-global (Salty.IO) acknowledged and commented:

The stablecoin framework: /stablecoin, /price_feed, WBTC/WETH collateral, PriceAggregator, price feeds and USDS have been removed:

https://github.com/othernet-global/salty-io/commit/88b7fd1f3f5e037a155424a85275efd79f3e9bf9

Status: Mitigation confirmed. Full details in reports from zzebra83, 0xpiken, and t0x1c.


The original report as published on Code4rena, by niroh. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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 aggregator treats a large disagreement between price sources as a fatal error and reverts, instead of falling back to a trusted source.

What the attacker needed

High market volatility; three price feeds diverge by >3%

The fix

The aggregator should fall back to the most trustworthy oracle (typically Chainlink) instead of reverting when prices diverge beyond the maximum; the text notes the affected framework was later removed.

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 feed tells a smart contract what an asset is worth. This protocol combines three price sources and refuses to work if two of them disagree by more than 3%. During fast market moves the sources naturally disagree, so the contract stops accepting liquidations and borrows exactly when they are needed.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More by niroh

View all

28 more disclosed reports, best first.

More from Salty.IO

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.