Skip to content
Business logic Audit finding Advanced

Exact-collateral liquidation skips deficit accounting

The liquidation code only treats collateral exhaustion as a cap event when the computed seizure is strictly greater than the borrower's balance, so an exact-match seizure is processed as an ordinary partial liquidation. A borrower could self-liquidate to reclaim all remaining collateral while leaving untracked bad debt on the account.

v12 Follow with darkodi, Eniwealth and 6 others

Originally disclosed on Code4rena

Submitted by v12, also found by darkodi, Eniwealth, Ezrel, hezze, khaye26, kimnoic, oxwhite, and sin99xx-waris

Found by V12

  • contracts/kinetic-router/src/calculation.rs #L849

calculate_liquidation_amounts_with_reserves returns a discrete collateral_amount_to_seize, and both liquidation callers only treat collateral exhaustion as a cap event when that amount is strictly greater than the user’s balance. If the computed seizure is exactly equal to the borrower’s full collateral balance, the liquidation proceeds as an ordinary partial liquidation even though it will remove all collateral. In contracts/kinetic-router/src/liquidation.rs, leftover debt is only burned into reserve_deficit inside the collateral_cap_triggered branch, and the MIN_LEFTOVER_BASE guard only runs when both debt and collateral remain. contracts/kinetic-router/src/router.rs repeats the same > comparison and bad-debt handling in the flash-liquidation path. This lets an underwater user choose a debt_to_cover whose computed seizure exactly matches their collateral and end with zero collateral plus positive debt that is never converted into tracked deficit.

Root Cause

Bad-debt cleanup is keyed entirely off collateral_cap_triggered, but that flag is derived from a strict > comparison against the helper’s returned seizure amount. The liquidation code never handles the equally dangerous collateral_amount_to_seize == user_collateral_balance && remaining_debt > 0 case.

Impact

A borrower can self-liquidate, or use a cooperating liquidator, to reclaim all remaining collateral while leaving unrecoverable debt outstanding on the account. The reserve is left with untracked bad debt and inconsistent insolvency accounting, which breaks deficit handling and leaves operators with a stranded position that the protocol no longer has collateral to recover.

Proof of Concept

See this gist for full Proof of Concept


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

Bad-debt cleanup is keyed entirely off a flag derived from a strict greater-than comparison, so the case where the seizure equals the full collateral balance with debt remaining is never handled.

Impact

A borrower could self-liquidate or use a cooperating liquidator to reclaim all remaining collateral while leaving unrecoverable debt outstanding, producing untracked bad debt and inconsistent insolvency accounting.

What the attacker needed

An underwater borrower position; borrower or cooperating liquidator

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, if a borrower's collateral is worth less than their debt, a liquidator can take the collateral to repay part of the debt. The code has a special branch for when all the collateral is taken, which records the leftover debt as a loss. This report says that branch is skipped when the amount taken happens to exactly equal the collateral, so the loss is never recorded.

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 v12

View all

37 more disclosed reports, best first.

More from K2

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.