Bad debt is never handled which places insolvency risks on BendDAO
The protocol lacks a mechanism to handle bad debt that arises when collateral value crashes or debt spikes, leaving outstanding debt that cannot be repaid. This can cause a liquidity shortfall, preventing users from withdrawing their deposits indefinitely.
Originally disclosed on Code4rena
Submitted by 0x73696d616f
Bad debt is never handled, which may happen whenever the collateral asset price crashes or the debt value spikes. Whenever this happens ERC20 positions will be partially liquidated and ERC721 positions will not be profitable for liquidation, which means the debt will not be repaid. When this happens, the protocol will not have enough liquidity to fulfill withdrawals, DoSing them forever or until the price comes back up again.
Proof of Concept
LiquidationLogic::executeCrossLiquidateERC20() allows partial, liquidations, so the likely outcome here would be liquidation of the debt corresponding to the available collateral, but some debt could be outstanding. ERC721 liquidations don’t allow partial liquidations in the same way, as the price of each collateral asset is based on the debt value only, so it could happen that these debt assets are not liquidated at all.
As withdrawing deposits depends on the protocol having liquidity, if these assets are borrowed and there is no way to repay them, users will not be able to withdraw.
Tools Used
Vscode, Foundry
Recommended Mitigation Steps
On liquidation, place a mechanism to handle the creation of bad debt. This could be implemented as a reserve or by decreasing the supply index or similar, so the bad debt is redistributed by the suppliers.
thorseldon (BendDAO) disputed and commented:
The bad debt should be handled by the DAO Treasury and the protocol income.
0x73696d616f (warden) commented:
@0xTheC0der - There was no mention of the treasury handling bad debt at the time of the audit. As per the report, the bad debt is not handled because:
- ERC20 tokens clear debt up to the available collateral, so if
debt > collateral, this leftover debt will never be handled.- ERC721 tokens are not profitable for liquidation (separate issue here).
Also, for ERC20 tokens, the treasury and protocol income can not cover the bad debt because it is not possible to clear the extra debt. It will revert here as the user has no collateral left. So the only option for the protocol to clear this bad debt would be gifting the user collateral to liquidate him, which is a very weird flow.
Thanks for following up with more info after I initially closed due to insufficient proof.
The Warden has shown that the protocol seems to have no graceful way of handling bad debt position in case of collateral value crashes which are common in the DeFi space.
Also, the source of truth (codebase &
README) do not outline how these situations could be handled by the DAO treasury.
thorseldon (BendDAO) commented:
@0xTheC0der, @0x73696d616f - For the bad debt, DAO treasury should actively repay the debt using
crossRepayERC20. I don’t know why reopen this finding? Most of the lending pool will has bad debt need to covered by DAO treasury or protocol income.I think security audit should focus on the vulnerabilities in the code, not question the service model design.
0x73696d616f (warden) commented:
@thorseldon - it wasn’t publicly mentioned at the time of the audit you would be taking losses and handling bad debt directly, so the finding is in scope.
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 does not account for or socialise bad debt when collateral is insufficient to cover the debt, and there is no reserve or mechanism to absorb losses.
Impact
The protocol may lack liquidity to fulfil withdrawals, causing a denial of service for depositors until prices recover.
What the attacker needed
Collateral price crashes or debt value spikes; bad debt remains after liquidation
The fix
A mechanism should be added to handle bad debt, such as a reserve or by decreasing the supply index so losses are redistributed to suppliers.
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 deposit assets and borrowers take loans backed by collateral. If the collateral's value falls below the loan amount, the loan becomes 'bad debt' that cannot be fully recovered by selling the collateral. This report says the protocol has no way to deal with that leftover debt, so it may run out of money and users cannot withdraw their deposits.
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.