Skip to content
Business logic Audit finding Intermediate

Prepared flash liquidation can bypass collateral reserve pause

The two-step flash liquidation flow checks whether the collateral reserve is paused only during the preparation step, not during execution. A liquidator who prepared an authorization before a reserve pause can still execute the liquidation within the 600-second window, seizing and swapping collateral from a paused reserve.

bunnyhunter Follow with 0x04, 0x15 and 48 others

Originally disclosed on Code4rena

Submitted by bunnyhunter, also found by 0x04, 0x15, 0xABSattar, 0xBeastBoy, 0xc0ffEE, 0xCiphky, 0xDemon, 0xGutzzz, 0xtracer, 0xvd, abdelhaq16, Agontuk, AvantGard, AxiosCapex, basekay, binbin2803, boodieboodieboo, botdidy, Brene, caho, cgdusek, ChainSentry, ChargingFoxSec, codegpt, coinsspor, cwk, Dest1ny_rs, Diavolo, doorpost, dqt2506, Drothon, duan, edoscoba, Emmy, Felh, FISHqianli, goldberg8, gther9, guiz, gwumex, gzeon, Haerincode, harry, hezze, honey-k12, ht111111, Infi, ix2b100, jaydenwistrom, jesjupyter, JostarJoseph, khaye26, kodkirmizi, Kryptos, Lamsy, legat, leonardo777, m0l4b0, maigadoh, marianl30, maxzuvex, metaBug, mscgo77, namaila, niffylord, nol, Nyx, orangesantra, Pelz, penguinmiaou, PeterVN, piki, piyushmali, ppddderiarena, qed, r00p, rajatbeladiya, rakanaji, raphaelbgr, Razkky, ret2basic, rubencrxz, rustviper, sahuang, sgtpepper, Sikoh, StevenQ15, TheWeb3Mechanic, Tigerfrake, tofunmi, TrudentHunter, Trynax, udogodwin, unineko, viper3, y4y, and yinziping

  • contracts/kinetic-router/src/router.rs #L463

The two-step flash liquidation flow (prepare_liquidation + execute_liquidation) validates reserve pause state only during preparation. If the collateral reserve is paused between the two transactions, execute_liquidation does not revalidate the collateral reserve’s lifecycle flags before burning the borrower’s aTokens, seizing collateral, and settling through a DEX swap. This allows a liquidator to execute a stale authorization against a paused collateral reserve for up to 600 seconds, bypassing the documented emergency stop for that reserve.

Finding Description

K2’s flash liquidation uses a two-step architecture. In the first transaction, prepare_liquidation fetches and updates both the collateral and debt reserves, then correctly rejects the call if either reserve is inactive or paused:

// contracts/kinetic-router/src/router.rs:526-537
if !collateral_reserve_data.configuration.is_active() {
    return Err(KineticRouterError::AssetNotActive);
}
if !debt_reserve_data.configuration.is_active() {
    return Err(KineticRouterError::AssetNotActive);
}
if collateral_reserve_data.configuration.is_paused() {
    return Err(KineticRouterError::AssetPaused);
}
if debt_reserve_data.configuration.is_paused() {
    return Err(KineticRouterError::AssetPaused);
}

If this passes, the router stores a LiquidationAuthorization valid for 600 seconds.

In the second transaction, execute_liquidation performs the actual settlement. It checks the protocol-wide pause flag, validates the stored authorization, fetches current prices with tolerance checks, reloads both reserves, updates state, and recalculates the health factor. However, it never repeats the is_active() / is_paused() checks for either reserve after the reload:

// contracts/kinetic-router/src/router.rs:711
if storage::is_paused(&env) {
    return Err(KineticRouterError::AssetPaused);
}
// ... authorization, price, and deadline checks ...

// contracts/kinetic-router/src/router.rs:765-769
let raw_debt_reserve = storage::get_reserve_data(&env, &debt_asset)?;
let debt_reserve_data = crate::calculation::update_state(&env, &debt_asset, &raw_debt_reserve)?;

let raw_collateral_reserve = storage::get_reserve_data(&env, &collateral_asset)?;
let collateral_reserve_data = crate::calculation::update_state(&env, &collateral_asset, &raw_collateral_reserve)?;
// No is_paused() or is_active() check follows.

The only subsequent reserve lifecycle validation comes from internal_flash_loan_with_reserve_data, but that function iterates only the assets being flash-loaned. In this flow, the flash-loaned asset is exclusively the debt asset:

// contracts/kinetic-router/src/router.rs:967-982
let mut assets = Vec::new(&env);
assets.push_back(debt_asset.clone());
// ...
crate::flash_loan::internal_flash_loan_with_reserve_data(
    &env, pool_address.clone(), pool_address.clone(),
    assets, amounts, params_bytes, false, Some(&debt_reserve_data),
)?;

Inside the flash loan loop, each asset is validated for is_active() and !is_paused(), but the collateral asset is never in this vector:

// contracts/kinetic-router/src/flash_loan.rs:70-82
require!(reserve_data.configuration.is_flashloan_enabled(), ...);
require!(reserve_data.configuration.is_active(), ...);
require!(!reserve_data.configuration.is_paused(), ...);

The callback then proceeds to burn the borrower’s collateral aTokens, transfer the underlying collateral to the pool, and swap it through a DEX, all using the paused collateral reserve’s data without any lifecycle revalidation.

By contrast, the standard liquidation_call path uses validate_liquidation, which unconditionally rejects the call if either reserve is paused:

// contracts/kinetic-router/src/validation.rs:517-529
if !collateral_reserve_data.configuration.is_active()
    || !debt_reserve_data.configuration.is_active()
{
    return Err(KineticRouterError::AssetNotActive);
}
if collateral_reserve_data.configuration.is_paused()
    || debt_reserve_data.configuration.is_paused()
{
    return Err(KineticRouterError::AssetPaused);
}

This creates an inconsistency: prepare_liquidation and liquidation_call both enforce that the collateral reserve must be unpaused, but execute_liquidation does not, treating the prepare-time validation as still valid even though the two functions are split across separate transactions and the collateral reserve configuration can change in between.

The project documentation reinforces that this is an unintended gap. The liquidation documentation states that liquidations are blocked when the protocol or individual reserves are paused, and specifically says liquidation cannot proceed if either reserve is paused. These statements are unconditional and make no distinction between the standard and flash liquidation paths.

Impact

Emergency reserve pause does not reliably stop liquidation settlement for positions that already have a prepared flash-liquidation authorization. During the 600-second authorization window, a liquidator can continue moving and selling collateral from a reserve that an authorized emergency admin has just paused.

Reserve pauses are incident-response controls used when the protocol detects a suspected oracle issue, asset incident, DEX integration problem, or market emergency. If the collateral reserve is paused for any of these reasons, the prepared flash-liquidation path can still seize and swap that asset while direct liquidation and fresh preparation are both correctly blocked. This undermines the safety guarantee that pause is supposed to provide.

The issue is bounded by several constraints: the liquidator must have prepared the authorization before the reserve was paused, the authorization must not be expired, the borrower must still be liquidatable at execution time, current prices must pass the configured tolerance check, and the debt reserve must remain active and unpaused. These constraints prevent arbitrary exploitation but do not eliminate the bypass. Active liquidators routinely maintain prepared authorizations for efficiency, and 600 seconds is a meaningful window during an active incident.

The issue is a real bypass of a documented emergency control that causes unauthorized post-pause state changes on the paused reserve, but it is limited to outstanding prepared authorizations and does not by itself enable arbitrary asset theft or unbounded loss.

Likelihood Explanation

The scenario requires a liquidator to have called prepare_liquidation on a position before the collateral reserve is paused, and then to call execute_liquidation within the 600-second authorization window after the pause. This is a realistic sequence for several reasons.

Active liquidators on lending protocols typically maintain prepared authorizations for unhealthy positions as part of their normal operation, since the two-step flow is designed for exactly this purpose. A liquidator monitoring several undercollateralized positions will often have multiple live authorizations at any given time.

Reserve pauses are inherently reactive: they are triggered after something unexpected is detected. The 600-second overlap between pre-existing authorizations and a new pause is not an edge case requiring unusual timing. It is the standard window in which the mismatch manifests.

The liquidator needs no special privileges, elevated access, or capital beyond what any liquidator already has. The position must be genuinely undercollateralized, so the liquidator is not creating the conditions; they are exploiting a timing gap in the emergency control. Exploitation is straightforward: a single execute_liquidation call with the same parameters that were already accepted during preparation.

Recommendation

After reloading and updating both reserves in execute_liquidation, repeat the same lifecycle validation used by prepare_liquidation and validate_liquidation:

if !collateral_reserve_data.configuration.is_active()
    || !debt_reserve_data.configuration.is_active()
{
    return Err(KineticRouterError::AssetNotActive);
}

if collateral_reserve_data.configuration.is_paused()
    || debt_reserve_data.configuration.is_paused()
{
    return Err(KineticRouterError::AssetPaused);
}

Place the check immediately after the reserve reload and state update block at line 769. This preserves the existing two-step architecture while ensuring the execution step honors current emergency reserve state.

Proof of Concept

See original finding for full Proof of Concept


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

The execution step of the two-transaction flash liquidation reloads both reserves but never repeats the is_active/is_paused checks that the preparation step and the standard liquidation path enforce.

Impact

A prepared flash liquidation can still seize and swap collateral from a reserve that an emergency admin has just paused, undermining the pause as an incident-response control, though only for outstanding authorizations within the 600-second window and subject to price and health checks.

What the attacker needed

Liquidator prepares before the pause; execution within 600-second window; borrower still liquidatable at execution; prices pass tolerance check

The fix

The execution step should repeat the same is_active and is_paused checks on both reserves immediately after reloading them, as the report recommends.

How it was found

  1. Call prepare_liquidation on a liquidatable position while the collateral reserve is unpaused, obtaining a 600-second authorization.
  2. The collateral reserve is then paused by an admin.
  3. Call execute_liquidation with the same parameters within the authorization window.
  4. The execution proceeds to burn the borrower's aTokens, seize collateral, and swap it through a DEX despite the pause.

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.

A lending protocol lets people borrow assets against collateral. An emergency 'pause' is meant to stop all activity on a reserve, for example when something looks wrong. Here, a liquidator could prepare a liquidation just before the pause and still carry it out afterwards, because the second step never re-checks the pause.

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 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.