Skip to content
Business logic Audit finding Advanced

In some situations the liquidation can become unprofitable for liquidators, keeping unhealthy positions

The liquidation incentive is calculated using the pool's average price, but the actual swap occurs at the current price, which can differ. This can make liquidation unprofitable for liquidators, leaving unhealthy positions unliquidated.

panprog Follow

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-10-aloe-judging/issues/43

Found by

panprog

When liquidators liquidate unhealthy accounts and the swap is required, they receive LIQUIDATION_INCENTIVE to compensate for the potentially unprofitable swap price required (as the swap price is the pool average price over the UNISWAP_AVG_WINDOW, which lags the current price). However, this only happens when swap is required at the average price. The assets composition can be different depending on price if the user has uniswap position as a collateral. Such uniswap position can happen (intentionally or not) to be composed in such way, that it has 100% of one asset at the current average price, but 100% of the other asset at the current market price, thus liquidator's incentive will be 0.

In particular, it can happen in the following situation:

  1. Current price is different from the average price by a reasonable amount (like 1%+)
  2. Uniswap position is such, that it's fully in one asset at the average price and fully in the other asset at the current price

In this case, there is no swap required at the average price (thus liquidation incentive = 0), however at the current price a swap of all user assets is required from liquidator at the unfavorable average price (which is worse than current price). Since liquidator doesn't receive its bonus in such case, the liquidation will be unprofitable and liquidator won't liquidate user.

Vulnerability Detail

Example scenario of the situation when liquidation is not profitable for the liquidator:

  1. Current ETH price = 1000 USDT. Average price over the last 30 minutes = 1010 USDT
  2. Alice position is 1 ETH in the range [1000, 1006]. Alice debt is 9990 USDT. Alice account in not healthy.
  3. Bob wants to liquidate Alice account. Since at the average price of 1010 USDT Alice position composition is 0 ETH + 1003 USDT, this fully covers Alice debt and liquidation incentive = 0. However, as the liquidation proceeds, at the current price of 1000 USDT Alice's position will be converted into 1 ETH + 0 USDT and Bob will have to exchange 1 ETH into 1010 USDT without any additional bonus.

3.1. If Bob decides to liquidate Alice account, Alice will have her 1 ETH converted into 1010 USDT, which she can immediately exchange into 1.01 ETH, creating a profit for Alice (and Bob will lose 10 USDT based on the current ETH price) 3.2. If Bob is being rational and doesn't luiquidate unprofitably, Alice unhealthy position will remain active without being liquidated.

Impact

In some cases, liquidation will require swap of assets at unfavorable (lagging average) price without any bonus for the liquidator. Due to this, liquidation will not happen and user account will stay unhealthy, this can continue for extended time, breaking important protocol mechanism (timely liquidation) and possibly causing bad debt for unhealthy account.

Code Snippet

BalanceSheet.computeLiquidationIncentive sets incentive only when liabilities0 > assets0 or liabilities1 > assets1 at the average prices: https://github.com/sherlock-audit/2023-10-aloe/blob/main/aloe-ii/core/src/libraries/BalanceSheet.sol#L125-L149

In liquidation it is called with compositions of uniswap position assets at the average price (C): https://github.com/sherlock-audit/2023-10-aloe/blob/main/aloe-ii/core/src/Borrower.sol#L213-L219

However, _getAssets withdraws uniswap position at current price, which can be different: https://github.com/sherlock-audit/2023-10-aloe/blob/main/aloe-ii/core/src/Borrower.sol#L209

Tool used

Manual Review

Recommendation

Quite hard to come up with good recommendations here, because allowing liquidation incentive at current price opens up different attack vectors to abuse it. Possibly choose max amount required to swap at average price, average price-5% and average price+5% (or some other %) and pay out based on this max (still not on current price to be fair and not force liquidators manipulate pool for max profit) or something like that.

Discussion

sherlock-admin2

1 comment(s) were left on this issue during the judging contest.

MohammedRizwan commented:

valid

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

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 liquidation incentive is computed using the pool's average price, while the actual asset swap occurs at the current price, creating a mismatch that can eliminate the incentive.

Impact

Liquidation may not occur, leaving unhealthy positions active and potentially causing bad debt for the protocol.

What the attacker needed

Price difference between average and current; uniswap position composition as described

The fix

The incentive should be based on a conservative estimate of the swap amount, such as the maximum required at average price ±5%, rather than the current price.

How it was found

  1. Current price differs from average price by a reasonable amount (e.g., 1%+).
  2. Uniswap position is fully in one asset at average price and fully in the other at current price.
  3. Liquidator sees no swap needed at average price, so incentive is zero.
  4. At current price, liquidator must swap all assets at unfavorable average price.
  5. Liquidation becomes unprofitable, so liquidator does not liquidate.

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.

When a borrower's position becomes risky, someone else (a liquidator) can close it and get a bonus. Here, the bonus is calculated using an old average price, but the actual trade happens at the current price. If the prices differ, the liquidator might lose money, so they won't do it, and the risky position stays open.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by panprog

View all

66 more disclosed reports, best first.

More from Aloe

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.