Skip to content
Business logic Audit finding Intermediate

Fixed reward percentage for liquidators in the eUSD vault may cause a liquidation crisis

The liquidation function in the eUSD vault gives a fixed 10% reward to liquidators, which can reduce the collateral ratio of an already undercollateralised position (below 110%) after liquidation. An attacker could repeatedly liquidate such a position, making it unhealthier and potentially causing bad debt for the protocol.

0xRobocop Follow

Originally disclosed on Code4rena

Submitted by 0xRobocop

To not lose generality, the same issue is present in the LybraPEUSDVaultBase contract.

Liquidations are essential for a lending protocol to maintain the over-collateralization of the protocol. Hence, when a liquidation happens, it should increment the collateral ratio of the liquidated position (make it healthier).

The LybraEUSDVaultBase contract has a function named liquidation, which is used to liquidate users whose collateral ratio is below the bad collateral ratio, which for the eUSD Vault is 150%. This function incentives liquidators with a fixed reward of 10% of the collateral being liquidated. However, the issue with the fixed compensation is that it will cause a position to get unhealthier during a liquidation when the collateral ratio is 110% or smaller.

Proof of Concept

Take the following example:

  • USD / ETH price = 1500
  • Collateral amount = 2 ether
  • Debt = 2779 eUSD

The data above will give us a collateral ratio for the position of: 107.9%. The liquidator liquidates the max amount possible, which is 50% of the collateral, one ether, and takes 10% extra for its services; the final collateral ratio will be:

((2 - 1.1) * 1500) / (2779 - 1500) = 1.055

The position got unhealthier after the liquidation, from a collateral ratio of 107.9% to 105%. The process can be repeated until it is no longer profitable for the liquidator leading the protocol to accumulate bad debt.

Justification

I landed medium on this finding for the following reasons:

  • It has the requirement that the position must have a collateral ratio lower than 110%, which means that it was not liquidated before it reached that point.
  • Even though the above point is required for this to become an issue, the position in the example was still over-collateralized (~108%). It should not be possible to liquidate an over-collateralized position and have the consequence of making it unhealthier.

Tools Used

Manual Review

Recommended Mitigation Steps

When a position has a collateral ratio below 110%, the reward percentage should be adjusted accordingly instead of a fixed reward of 10%.

Assessed type

Math

LybraFinance disagreed with severity and commented:

Liquidation due to a collateral ratio below 110% results in a further decrease in the collateral ratio. When the collateral ratio falls below 100%, the liquidation outcome remains the same. In practice, liquidation occurs when the collateral ratio reaches 150%, making it unlikely to have an excessively low collateral ratio.

0xean (judge) decreased severity to Low

0xRobocop (warden) commented:

I think this issue was misjudged:

The issue describes how an over-collateralized position between 101% and 109% (inclusive) gets unhealthier with each liquidation. From my knowledge, there is no CDP protocol that allows this behavior since instead of helping the protocol increment the total collateral ratio, it accelerates to go to lower levels.

I think this is a clear medium issue because it has the requirement of a position to reach a CR of 109% which may not happen, but still it cannot be guaranteed that it will never happen and the protocol should handle these cases.

Medium issue definition:

Assets not at direct risk, but the function of the protocol or its availability could be impacted, or leak value with a hypothetical attack path with stated assumptions, but external requirements.

  • Stated assumption by the protocol: A position will never reach 109%.
  • External requirement: A position reaching 109% which cannot be guaranteed that will never happen.
  • Impact: Liquidations in a CDP protocol should make the protocol healthier when the positions are still over-collateralized, which in the case of this protocol it does not happen in certain conditions.

0xean (judge) increased severity to Medium and commented:

Thanks @0xRobocop for making your case, I think its on the cusp between being a design decision (which I agree is a sub optimal design choice) and a M severity issue.

Liquidation’s cascading into to more liquidations is never a good outcome and I think you are correct that this does lead to that. Lets get some sponsor comment and for the moment, I will upgrade to M.

LybraFinance confirmed and commented:

Although we have been using this design since V1, we have to admit, liquidation’s cascading into to more liquidations is never a good outcome. Therefore, we have decided to modify this logic. Thank you for your valuable suggestions!


The original report as published on Code4rena, by 0xRobocop. 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

Impact

Repeated liquidations of a position with a collateral ratio between 100% and 110% could make it unhealthier, potentially leading to bad debt for the protocol, though the text notes this requires the position to reach such a low ratio first.

What the attacker needed

A position with collateral ratio below 110%; liquidator willing to liquidate

The fix

The reward percentage should be adjusted dynamically when a position's collateral ratio is below 110%, rather than using a fixed 10% reward.

How it was found

  1. Set the USD/ETH price to 1500.
  2. Create a position with 2 ether collateral and 2779 eUSD debt, giving a collateral ratio of 107.9%.
  3. Liquidate the maximum allowed amount (50% of collateral, i.e., 1 ether) and take the 10% reward (0.1 ether).
  4. Observe that the new collateral ratio is 105%, lower than before.

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.

In a lending protocol, users lock collateral (like ETH) to borrow a stablecoin. If the collateral value falls too low compared to the debt, a liquidator can repay part of the debt and take some collateral as a reward. This report shows that if the reward is always 10%, then for positions that are only slightly overcollateralised (between 100% and 110%), the liquidation actually makes the position even less collateralised, which is the opposite of what should happen.

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 0xRobocop

View all

15 more disclosed reports, best first.

More from Lybra Finance

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.