Every flash liquidation permanently drains the debt-asset reserve, making depositors unable to withdraw their funds
The flash liquidation mechanism in the Kinetic Router mints an internal flash loan from the aToken to fund debt repayment, but the repayment verification only checks that the aToken's balance is restored, not that net-new funds were added. As a result, each liquidation leaves the borrowed amount stranded in the router, permanently reducing the reserve's solvency and preventing depositors from withdrawing their full funds.
juldesbourds Follow with 0xABSattar, 0xastronatey and 46 others
Originally disclosed on Code4rena
Submitted by juldesbourds, also found by 0xABSattar, 0xastronatey, 0xFBI, 0xJoker42, 0xSmartContractSamurai, 4funnds, abdelhaq16, Agontuk, ahahaHard1k, akgyan03, AvantGard, bogach_avgustina, codeconflict, crunter, Cryptor, D_Auditor, daivo, darkodi, dkv27, edoscoba, Eze, falconz28, Fenice, gahbi, gwumex, honey-k12, jjjj05, Joseph_Nwodoh, kammiz, latzcho, Link1337, makishevOmar, Manga, peter941221, pingy97, qed, ranzo, RustyLock, sh1v, snufflesrea, starrohan, t4sk, TheWeb3Mechanic, tipao, twicek, vvuzy, xKeywordx, and yol
contracts/kinetic-router/src/flash_loan.rs#L345-L561contracts/kinetic-router/src/flash_loan.rs#L237-L254contracts/kinetic-router/src/router.rs#L963-L982
The execute_liquidation path in the Kinetic Router mints an internal flash loan equal to actual_debt_to_cover of the debt asset. The loan is sent from the aToken to the pool contract (router) to fund the liquidation. Inside the liquidation callback, the swap proceeds arrive at the pool, the debt token is burned, collateral is transferred to the liquidator, and the pool sends actual_debt_to_cover back to the aToken as the “repayment”.
The repayment verification only checks that the aToken balance is at least as high as it was before the loan. That check passes trivially because the same funds that left the aToken are the same funds that came back.
What is never checked is whether any net-new underlying reached the aToken. The swap proceeds minus protocol fees and liquidator profit equal actual_debt_to_cover, which the pool spends elsewhere. The amount originally sourced from the aToken is simply returned to the aToken, so from the aToken’s perspective nothing improved. The pool, however, received actual_debt_to_cover from the aToken and never eliminates the corresponding residual from its own balance. That amount remains trapped in the router contract.
After every flash liquidation, actual_debt_to_cover units of the debt asset accumulate in the router address with no mechanism to recover them into the reserve. The seized collateral only funds liquidator profit and protocol fees; it does not restore reserve solvency. The reserve becomes short by exactly the sum of all actual_debt_to_cover values across all flash liquidations.
Root Cause
File: contracts/kinetic-router/src/flash_loan.rs, execute_liquidation_callback (lines 345–561)
The circular fund flow is:
aToken ──[flash: debt_to_cover]──► pool
pool ──[seize collateral]──────► pool
pool ──[swap collateral]───────► handler
handler ──[swap output: debt_received]──► pool
pool balance = debt_to_cover + debt_received
pool ──[repay flash: debt_to_cover]────► aToken
pool ──[protocol fee]──────────────────► treasury
pool ──[profit]────────────────────────► liquidator
(total out besides flash repay = debt_received)
pool residual = debt_to_cover
verify_repayment only confirms that the aToken regained at least its starting balance. Since the repayment transfer equals the original loan amount, the check passes even though the reserve has not received any net-new value.
// flash_loan.rs:237–254
fn verify_repayment(env, underlying_asset, atoken_address, debt) {
let current_balance = get_underlying_balance(env, underlying_asset, atoken_address);
let expected_balance = debt.initial_balance
.checked_add(debt.premium) // premium = 0 for internal loans
.ok_or(KineticRouterError::MathOverflow)?;
require!(
current_balance >= expected_balance, // PASSES: aToken gets its own money back
KineticRouterError::FlashLoanNotRepaid
);
}
There is no symmetric post-condition such as “router balance of the debt asset must be zero” after the callback returns.
The Accounting Illusion
There are two sources of funds available to the pool inside execute_liquidation_callback:
Source | Amount |
Internal flash loan from aToken | debt_to_cover |
Swap proceeds from collateral liquidation | debt_received |
Pool total in | debt_to_cover + debt_received |
And the outgoing transfers are:
Destination | Amount |
Repay flash loan back to aToken | debt_to_cover |
Protocol fee to treasury | protocol_fee |
Liquidator profit | debt_received - debt_to_cover - protocol_fee |
Pool total out excluding residual | debt_received |
Residual left in the router:
(debt_to_cover + debt_received) - debt_received = debt_to_cover
The flash loan repayment is not repayment in any economic sense. The pool is simply returning the aToken’s own funds. The swap proceeds, which are the only new funds introduced during liquidation, are consumed by fees and liquidator profit. Nothing replenishes the reserve for the credit it extended.
No Recovery Path
treasury.rs::collect_protocol_reserves only inspects the difference between the aToken’s underlying balance and the protocol’s recorded available_liquidity, then sweeps that excess from the aToken address to the treasury. It cannot touch assets stranded on the router contract.
cover_deficit allows an external actor to manually send funds into the aToken, but it requires off-chain detection and manual recapitalization. There is no automated mechanism that moves the trapped router balance back into the reserve.
The Alice and Bob Scenario
Setup:
- Alice is a passive LP and deposits
1,000,000 asset_b. - Bob supplies
1,000 asset_aas collateral. - Bob borrows
800 asset_b.
At oracle prices of $1.00 for both assets:
Collateral value × 85% threshold = $850
Debt = $800
Health factor = 1.0625
Bob is healthy.
Now asset_a drops to $0.50:
Collateral value × 85% threshold = $425
Debt = $800
Health factor ≈ 0.53
Bob is liquidatable.
Now a flash liquidation covers 400 asset_b:
aTokensends400 asset_bto the router as an internal flash loan.aTokenbalance becomes999,600.- Router burns Bob’s
400debt tokens. - Router seizes Bob’s collateral and receives about
840 asset_a. - Router swaps
840 asset_afor420 asset_b. - Router sends
400 asset_bback to theaToken. - Router pays
1.2 asset_bin protocol fees. - Router pays
18.8 asset_bin liquidator profit. - Router still holds
400 asset_b.
verify_repayment passes because the aToken recovered the exact funds it originally lent, but the reserve did not receive net-new liquidity.
From the reserve’s perspective:
original LP deposit: 1,000,000
minus Bob borrow: -800
plus flash repay: +400
---------
aToken underlying: 999,600
LP claim: 1,000,000
Shortfall: 400 (sitting in router address, unreachable)
If Alice tries to withdraw the full 1,000,000, the withdrawal reverts due to insufficient liquidity even though the missing 400 is still inside the protocol, just trapped on the router instead of being restored to the reserve.
Impact
Every successful flash liquidation permanently reduces reserve solvency by exactly actual_debt_to_cover units of the debt asset. These tokens are not lost due to rounding, not burned, and not theoretical; they accumulate on the router contract with every liquidation. There is no on-chain mechanism to move them back into the aToken.
As liquidations continue, the insolvency compounds monotonically. Long-term depositors will find that increasing portions of their funds cannot be withdrawn. During sharp market downturns, when many undercollateralized positions are liquidated, the shortfall can grow rapidly. The protocol cannot self-correct because there is no automatic reconciliation, no circuit breaker, and no admin function to sweep the stranded router balance back into the reserve.
Proof of Concept
See original finding for full Proof of Concept
Recommended Mitigation
The internal flash-loan mechanism should be removed from the liquidation path. The router does not need to borrow reserve liquidity in order to liquidate debt; it needs to settle debt against seized collateral and ensure the reserve receives the recovered debt asset.
Option A (preferred)
Remove internal_flash_loan_with_reserve_data from execute_liquidation and avoid circular reserve borrowing entirely:
- Seize collateral from the borrower.
- Swap collateral into the debt asset.
- Transfer
debt_to_coverof the recovered debt asset directly into theaToken. - Burn the borrower’s debt against actual recovered value.
- Send only true excess proceeds to the liquidator and protocol fee recipient.
Under this design, the aToken receives net-new underlying from liquidation and the router finishes with zero residual balance.
Option B (stopgap)
After verify_repayment, assert that the router’s balance of the debt asset is zero:
// After verify_repayment for each debt:
let pool_residual = token::Client::new(env, &debt.asset)
.balance(&env.current_contract_address());
require!(pool_residual == 0, KineticRouterError::FlashLoanAccountingError);
This is a defense-in-depth invariant check. It would revert any liquidation that leaves stranded funds on the router, protecting depositors until the liquidation design itself is corrected.
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 repayment check only verifies that the aToken's balance is at least its starting balance, which passes trivially because the same funds are returned, without ensuring that net-new underlying was added to the reserve.
Impact
Each flash liquidation permanently reduces the reserve's solvency by the debt amount, and over time depositors may be unable to withdraw their funds because the missing tokens are trapped in the router with no recovery mechanism.
What the attacker needed
A liquidatable position; a liquidator executes a flash liquidation
The fix
The internal flash-loan mechanism should be removed from the liquidation path so that the router seizes collateral, swaps it, and transfers the recovered debt asset directly to the aToken, ensuring the reserve receives net-new funds.
How it was found
- The aToken sends the debt amount to the router as an internal flash loan.
- The router burns the borrower's debt tokens and seizes collateral.
- The router swaps the collateral for the debt asset.
- The router sends the original loan amount back to the aToken.
- The router pays protocol fees and liquidator profit from the swap proceeds.
- The remaining debt amount stays trapped in the router contract.
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, depositors put money into a pool (the reserve) and borrowers take loans from it. When a borrower's collateral loses value, a liquidator can repay the debt and seize the collateral. This report says that during that process, the protocol borrows money from its own reserve to pay the debt, then returns exactly that same money to the reserve, so the reserve never actually gets back the funds it lent out. The borrowed amount ends up stuck in a separate contract, meaning the reserve has less money than depositors are owed.
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.