Skip to content
Business logic Audit finding Intermediate

Bad debts should not continue to accrue interest

The protocol allows bad debt to keep accruing interest, and when the DAO collects interest it mints new stablecoins. An attacker could exploit this by leaving a position unliquidated, causing unbacked stablecoins to be minted and damaging the stablecoin's authenticity.

WatchPug Follow

Originally disclosed on Code4rena

Submitted by WatchPug

NFTVault.sol#L844-L851

uint256 debtAmount = _getDebtAmount(_nftIndex);
require(
    debtAmount >= _getLiquidationLimit(_nftIndex),
    "position_not_liquidatable"
);

// burn all payment
stablecoin.burnFrom(msg.sender, debtAmount);

In the current design/implementation, the liquidator must fully repay the user’s outstanding debt in order to get the NFT.

When the market value of the NFT fell rapidly, the liquidators may not be able to successfully liquidate as they can not sell the NFT for more than the debt amount.

In that case, the protocol will have positions that are considered bad debts.

However, these loans, which may never be repaid, are still accruing interest. And every time the DAO collects interest, new stablecoin will be minted.

When the proportion of bad debts is large enough since the interest generated by these bad debts is not backed. It will damage the authenticity of the stablecoin.

Proof of Concept

Given:

  • NFT 1 worth 30,000 USD
  • creditLimitRate = 60%
  • liquidationLimitRate = 50%
  • debtInterestApr = 10%
  • Alice borrowed 10,000 USD with NFT #1;
  • After 1 year, NFT 1’s market value in USD has suddenly dropped to 10,000 USD, no liquidator is willing to repay 11,000 USD for NFT #1;
  • The DAO collect() and minted 1,000 stablecoin;
  • After 1 year, the DAO call collect() will mint 1,100 stablecoin. and so on…

Recommended Mitigation Steps

Consider adding a stored value to record the amount of bad debt, and add a public function that allows anyone to mark a bad debt to get some reward. and change accrue to:

uint256 internal badDebtPortion;

function accrue() public {
    uint256 additionalInterest = _calculateAdditionalInterest();

    totalDebtAccruedAt = block.timestamp;

    totalDebtAmount += additionalInterest;

    uint256 collectibleInterest = additionalInterest * (totalDebtPortion - badDebtPortion) / totalDebtPortion;
    totalFeeCollected += collectibleInterest;
}

spaghettieth (JPEG’d) acknowledged, but disagreed with High severity

LSDan (judge) commented:

I agree with the warden. Left unchecked, this issue is almost certain to occur and will cause substantial negative impacts on the protocol. The only way this would not occur is if the NFT market never crashes.


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

If bad debt accumulates, the interest generated from it is not backed, which could damage the authenticity of the stablecoin.

What the attacker needed

NFT market value drops below debt; No liquidator willing to repay debt; DAO collects interest

The fix

The report recommends adding a stored value to record bad debt and modifying the accrue function to exclude bad debt from collectible interest.

How it was found

  1. Alice borrows 10,000 USD using NFT #1 as collateral.
  2. After one year, the NFT's market value drops to 10,000 USD, making the debt (11,000 USD) greater than the collateral value.
  3. No liquidator is willing to repay 11,000 USD for the NFT, so the position becomes bad debt.
  4. The DAO calls collect() and mints 1,000 stablecoin as interest.
  5. After another year, the DAO calls collect() again and mints 1,100 stablecoin, and so on.

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 (an NFT) drops in value below what they owe, the loan becomes 'bad debt' because no one wants to buy the collateral to repay the debt. The problem is that the system keeps charging interest on that bad debt, and when the DAO collects that interest, it creates new stablecoins out of thin air. This can make the stablecoin less trustworthy because it is not backed by real assets.

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 WatchPug

View all

197 more disclosed reports, best first.

More from JPEG'd contest

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.