No incentive to liquidate when CR <= 1 as asset received < dyad burned
The liquidation function requires the liquidator to burn the full borrowed amount but only returns collateral worth less than that when the collateral ratio is below 1, so liquidators lose money and have no incentive to liquidate. This could leave bad debt unliquidated, potentially worsening the protocol's losses.
Infect3d Follow with ZanyBonzy, ArmedGoose and 21 others
Originally disclosed on Code4rena
Submitted by Infect3d, also found by ZanyBonzy, ArmedGoose, 0xleadwizard, peanuts, Myrault, vahdrak1, jesjupyter, SBSecurity, miaowu, OMEN, ke1caM, Bauchibred, Abdessamed, 0xnilay, HChang26, Bigsam, iamandreiski, 0xAlix2, alix40, atoko, GalloDaSballo, T1MOH, and 0x486776
Right now there are no incentives to liquidate a position with a CR<1, as the liquidator will have to burn the full borrowed amount, and will get the full collateral.
But a CR<1 means collateral is worth less than borrowed amount. So this is a clear loss for the liquidator, meaning no one will liquidate the position.
File: src/core/VaultManagerV2.sol
205: function liquidate(
206: uint id, //The ID of the dNFT to be liquidated.
207: uint to //The address where the collateral will be sent
208: )
...: // ... some code ...
215:❌ dyad.burn(id, msg.sender, dyad.mintedDyad(address(this), id)); //<@audit: caller need to burn full borrowed amount
216:
217: uint cappedCr = cr < 1e18 ? 1e18 : cr; /// == max(1e18, cr)
218: uint liquidationEquityShare = (cappedCr - 1e18).mulWadDown(LIQUIDATION_REWARD); /// if cr<1, this is equal 0
219: uint liquidationAssetShare = (liquidationEquityShare + 1e18).divWadDown(cappedCr); /// if cr<1, this is equal 1e18
220:
221: uint numberOfVaults = vaults[id].length();
222: for (uint i = 0; i < numberOfVaults; i++) {
223: Vault vault = Vault(vaults[id].at(i));
224: uint collateral = vault.id2asset(id).mulWadUp(liquidationAssetShare);
225: vault.move(id, to, collateral);
226: }
227: emit Liquidate(id, msg.sender, to);
228: }
Impact
If CR<1, position will not be liquidated, protocol possibly incurring worse bad debt than this could have been.
Recommended Mitigation Steps
Refactor the liquidation calculation, to allow liquidator to repay the debt and still get a reward out of this.
Assessed type
Context
shafu0x (DYAD) disputed and commented:
If the
CR < 100, where should the reward come from?
Koolex (judge) decreased severity to Low and commented:
Looks like a systematic risk. If CR drops below 100 before it gets liquidated, there is a much bigger problem.
I don’t think this is an unsolvable systemic issue, and this would be a mistake to not implement mechanism to take care underwater loans.
This issue, and the remediations are well established in CDP protocols:
- If a loan CR is
<100%, then it must be cut down as soon as possible to limit the even bigger potential losses.- To do so, the operation must be profitable for the liquidators so that they act quickly (which is not the case right now)
- This will indeed create a bad debt into to protocol, but here’s come the remediation.
- That’s why protocols like MakerDAO or other CDP build an “insurance fund” (usually through fees, that can come from liquiations) which role is to absorb bad debt in such events.
We will not implement something like an “insurance fund”. Do you have another mitigation option?
@shafu0x - I believe the other possibilities would be based on a debt socialization:
- Allow liquidator to burn only the DYAD equivalent of collateral.
- Award Kerosene from the 1B total supply as a bonus to cover missing part of collateral.
But I feel like a fund/balance, generated by fees taken from “good” liquidation, to cover for these rare situations is still the best way to go.
Koolex (judge) increased severity to Medium and commented:
Upgrading this to Medium due to the following:
- The absence of a mechanism to allow liquidating bad debts (
CR < 1) creates a potential risk for the protocol.- I couldn’t find in the documentation/code that it is an accepted risk based on an intended design.
award Kerosene from the 1B total supply as a bonus to cover missing part of collateral
This seems to be a good starting point. LP will be incentivised to liquidate, in return, they receive Kerosene. Kerosene then can be sold in the secondary market or re-used to mint DYAD.
However, consequences of this approach should be taken into account and addressed; for example, circulating Kerosene will increase which will influence the price.
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 logic always requires burning the full debt but caps the collateral share at 100% when the collateral ratio is below 1, leaving no reward for the liquidator.
Impact
Positions with a collateral ratio below 1 may never be liquidated, potentially causing the protocol to incur worse bad debt than if a mechanism existed.
What the attacker needed
A position with CR < 1; liquidator must burn full debt
The fix
The liquidation calculation should be refactored so that a liquidator can repay the debt and still receive a reward, for example by allowing them to burn only the DYAD equivalent of the collateral or by awarding Kerosene as a bonus.
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 this lending system, if a borrower's collateral becomes worth less than what they borrowed, someone else is supposed to step in, repay the debt, and take the collateral as a reward. But here, when the collateral is worth less than the debt, the helper would have to pay more than the collateral is worth, so they would lose money. As a result, nobody wants to do it, and the bad debt stays on the books.
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.