internal_liquidation_call validates close factor before min_remaining_debt bump, allowing liquidators to seize 100% of debt when only 50% is permitted
The liquidation function validates the close factor against the caller-supplied debt amount, then silently bumps that amount to the full debt if the remainder would fall below a configured minimum. A liquidator can therefore pass the 50% check and still have 100% of the debt liquidated, seizing all of the borrower's collateral.
harshsukhii Follow with 0xanmol, 0xApple and 32 others
Originally disclosed on Code4rena
Submitted by harshsukhii, also found by 0xanmol, 0xApple, 0xBeastBoy, 0xc0ffEE, 0xJoker42, akgyan03, aman, amrin123, astahovavaleriya, deki, dhaxor, firatstory, futurehelp, gzeon, hezze, Jean_Pierre_Polnaref, Joseph_Nwodoh, kammiz, Leader11, LeoGold, MadaniSora, Oxhelm, pepoc, phuocpham, prodigysml, qed, rubencrxz, samuraii77, sh1v, Sharkeeeeeee, SOPROBRO, twicek,whitehatanon1, and z3rco
contracts/kinetic-router/src/liquidation.rs#L234-L262
internal_liquidation_call (called by both liquidation_call and execute_liquidation) enforces the close factor in two separate steps that are intentionally decoupled — but should not be:
Step 1 — CF Validation (L234–237):
The original caller-supplied debt_to_cover is checked against the position’s close factor. For positions with HF ∈ (0.5 WAD, 1.0 WAD) and individual debt/collateral ≥ $2,000, the close factor is 50%, meaning at most half the debt may be liquidated per transaction.
// liquidation.rs:234-237
validate_close_factor(
env, user_account_data.health_factor,
individual_debt_base, individual_collateral_base, debt_to_cover_base,
)?;
Step 2 — min_remaining_debt bump (L239–262):
After validation passes, debt_to_cover is silently escalated to the full outstanding balance whenever the remainder would fall below the configured min_remaining_debt threshold:
// liquidation.rs:239-262
let debt_to_cover = {
if remaining > 0 {
if remaining_u128 < min_remaining_debt_val {
safe_i128_to_u128(env, debt_balance) // ← bumped to 100% of debt
} else { debt_to_cover }
} else { debt_to_cover }
};
The bumped value is then used for the actual liquidation computation (L271) and token burn downstream without a second CF check.
Attack Conditions
- Admin has set
min_remaining_debtfor the reserve (legitimate dust-prevention configuration) - The borrower’s position is in the partial-liquidation HF range (HF ∈ (0.5 WAD, 1.0 WAD)) with individual debt and collateral both ≥ $2,000, so the 50% close factor applies
- A liquidator passes exactly the 50%-cap amount, satisfying CF validation
min_remaining_debttriggers a bump to 100%
Concrete Example
- Borrower has 39,000 token debt ($39,000 at$1.00)
- Admin sets
min_remaining_debt = 19,501whole tokens - HF = 0.926 → 50% close factor applies
- Liquidator calls
liquidation_callwithdebt_to_cover = 19,500(exactly 50%) - CF validation:
19,500 ≤ 19,500→ passes - Remaining after 50% =
39,000 − 19,500 = 19,500 < 19,501→ bumped to39,000 - Actual liquidation: 100% of debt is covered — 2× what the close factor permits
- Borrower loses all collateral; liquidator pays only the 50% amount they declared
Impact: A liquidator can bypass the close factor protection entirely and seize a borrower’s full collateral in a single transaction. The borrower suffers up to double the expected loss. The attack requires only that (1) the position is in the partial-liquidation HF range and (2) the admin has configured min_remaining_debt — a routine operational setting — at a value that creates this overlap. No elevated privileges are needed for the liquidator.
Proof of Concept
See original finding for full Proof of Concept
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
The close-factor validation runs on the original debt_to_cover before the min_remaining_debt logic replaces it with the full debt balance, and no second validation is performed on the bumped value.
Impact
A liquidator can bypass the close factor and seize a borrower's full collateral in one transaction, causing up to double the expected loss, provided the position is in the partial-liquidation range and the admin has configured min_remaining_debt at an overlapping value.
What the attacker needed
Admin sets min_remaining_debt; position in partial-liquidation HF range; debt and collateral each at least $2,000; liquidator calls with 50%-cap amount
How it was found
- Admin sets min_remaining_debt for the reserve.
- Borrower's position is in the partial-liquidation health-factor range with debt and collateral each at least $2,000, so the 50% close factor applies.
- Liquidator calls liquidation_call with exactly the 50%-cap amount, which passes close-factor validation.
- The remaining debt falls below min_remaining_debt, so the code bumps debt_to_cover to the full balance.
- The bumped amount is used for the liquidation computation and token burn without a second close-factor check.
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.
When a borrower's health factor drops, a liquidator can repay part of their debt and take collateral as a reward. A close factor limits how much of the debt can be repaid in one go, here to half. The code checks that limit against the amount the liquidator says they will repay, but then quietly increases that amount to the full debt without checking the limit again, so the borrower loses everything.
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.