Skip to content
Business logic Audit finding Intermediate

Lack of way to handle not fully repaid bad debt after liquidation after the lending pool share or WLP are fully seized

After a liquidation seizes all of a borrower's collateral, any remaining debt cannot be written off because the collateral-removal function rejects a zero share amount. This leaves bad debt permanently recorded, inflating total assets and blocking other users from borrowing.

ladboy233 Follow with rvierdiiev

Originally disclosed on Code4rena

Submitted by ladboy233, also found by rvierdiiev

When user has bad debt, user’s borrow credit > collateral credit. Liqudiator can step in and liquidate and seize user’s share or seize user WLP and repay the debt.

While the liquidate function aims to let liqudiator take the min share available for bad debt repayment.

// take min of what's available (for bad debt repayment)
shares = shares.min(IPosManager(POS_MANAGER).getCollAmt(_posId, _poolOut)); // take min of what's available
_require(shares >= _minShares, Errors.SLIPPAGE_CONTROL);

After the user’s pool share is transferred out, or after user’s WLP is seized, the rest of unpaid debt becomes bad debt permanently. For example, user’s borrow 1000 USDT and has debt 1000 USDT. His share is only worth 500 USD as collateral price drops. Because the code lets liquidator take min of what’s available for both lending pool share and take min of what’s available (for bad debt repayment) for WLP amount. The liqudiator can repay 800 USD and seize share of 500 USD. However, there are 200 USD remaining debt. When other liquidators (even this liquidator belongs to protocol) writes to repay and erase the rest 200 USD bad debt, he cannot because removeCollateralTo validates share > 0, if share is 0, revert.

_require(_shares > 0, Errors.ZERO_VALUE);

If the underlying collateral is WLP, the second liquidation aims to write off bad debt does not work as well because if all WLP is transfered out, calling _harvest and unwrap again is likely to revert.

_harvest(_posId, _wLp, _tokenId);
IBaseWrapLp(_wLp).unwrap(_tokenId, _amt, _receiver);

The bad permanently inflates the totalAssets() in lending pool and inflates the total debt to not let other users borrow from protocol because of the borrow cap checks.

Also, the lender suffers the loss because if the bad debt is not repaid, the lender that deposit cash into the lending pool is lost.

Recommended Mitigation Steps

Add a way to handle not fully repaid bad debt after liquidation after the lending pool share or WLP is fully seized.

Add a function to donate to the lending pool to let user supply asset or add a function to socialize the bad debt as loss explicilty.

fez-init (INIT) confirmed


The original report as published on Code4rena, by ladboy233. 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 collateral-removal function requires a positive share amount, so a second liquidation attempt to write off remaining bad debt after all collateral is seized reverts.

Impact

The unpaid debt remains permanently, inflating total assets and total debt, which can block other users from borrowing due to borrow cap checks and causes losses to lenders.

What the attacker needed

Borrower has bad debt; collateral fully seized by liquidator

The fix

Add a way to handle not fully repaid bad debt after liquidation, such as a donation function or a function to socialise the bad debt as an explicit loss.

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 pool, a borrower puts up collateral and borrows assets. If the collateral's value falls below the debt, a liquidator can take the collateral and repay part of the debt. This report says that when the collateral is fully taken but some debt remains, the system has no way to clear that leftover debt, so it stays on the books and can stop other people from borrowing.

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 ladboy233

View all

47 more disclosed reports, best first.

More from INIT Capital Invitational

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.