Skip to content
DoS Audit finding Advanced

Reward checkpointing can consume the full liquidation CPU budget and disable aToken-based collateral seizure

The incentives system allows up to 20 reward tokens per asset, and a receive-aToken liquidation triggers reward checkpoints for the debt token and collateral aToken multiple times, multiplying the work to up to 100 reward-stream iterations. This can exceed Soroban's CPU budget, causing the liquidation to fail and leaving unhealthy accounts unliquidated.

Egobouros Follow with maxzuvex

Originally disclosed on Code4rena

Submitted by Egobouros, also found by maxzuvex

  • contracts/incentives/src/storage.rs #L75-L78
  • contracts/incentives/src/contract.rs #L91-L187
  • contracts/debt-token/src/contract.rs #L268-L269
  • contracts/a-token/src/contract.rs #L518-L520
  • contracts/kinetic-router/src/liquidation.rs #L387-L487

K2 treats incentives as an inline side effect of aToken and debt-token balance changes. That is safe only if the reward checkpointing cost remains small enough to fit inside every lending operation that can trigger it.

The current incentives cap is local to one token contract: each aToken or debt token may have up to 20 reward tokens. A receive-aToken liquidation, however, touches both the debt token and the collateral aToken several times in the same transaction. As a result, one liquidation can synchronously process up to 100 reward checkpoints while it is already doing the normal liquidation work.

The PoC shows that the same direct liquidation costs:

no incentives:        21,421,816 CPU
max-valid incentives: 103,775,427 CPU

The max-valid case exceeds Soroban’s normal 100,000,000 CPU budget and fails. This blocks the receive-aToken liquidation mode, which is the mode that should remain available when the collateral reserve has insufficient idle underlying for ordinary receive-underlying liquidation.

Root Cause

The incentives limit is applied at the wrong level of composition.

MAX_REWARD_TOKENS_PER_ASSET bounds the number of reward tokens registered for one incentivized token contract:

const MAX_REWARD_TOKENS_PER_ASSET: u32 = 20;

handle_action() then performs work proportional to that list length every time an incentivized token calls it. For each configured reward token, it loads the reward config, checks whether it is active, updates the asset reward index, updates the user’s reward snapshot, and emits an event:

let reward_tokens = storage::get_reward_tokens(&env, &asset);

for i in 0..reward_tokens.len() {
    let reward_token = reward_tokens.get(i).ok_or(KineticRouterError::InvalidAmount)?;

    let config =
        match storage::get_asset_reward_config(&env, &asset, &reward_token, reward_type) {
            Some(config) => config,
            None => continue,
        };

    if !config.is_active {
        continue;
    }

    let updated_index = calculation::update_asset_reward_index(
        &env,
        &config,
        &current_index,
        total_supply,
    )?;

    storage::set_asset_reward_index(
        &env,
        &asset,
        &reward_token,
        reward_type,
        &updated_index,
    );

    let mut user_data =
        storage::get_user_reward_data(&env, &asset, &reward_token, &user, reward_type);

    ...

    storage::set_user_reward_data(
        &env,
        &asset,
        &reward_token,
        &user,
        reward_type,
        &user_data,
    );
}

The protocol never asks whether a full liquidation path can afford the aggregate cost of all hooks it is about to trigger. The per-token cap is therefore insufficient: a high-level router operation can multiply the capped work several times.

Affected Flow

The vulnerable path is direct liquidation with _receive_a_token = true.

First, the liquidator repays the borrower’s debt and the router burns debt tokens:

let debt_burn_result = env.try_invoke_contract::<(bool, i128, i128), KineticRouterError>(
    &updated_debt_reserve_data.debt_token_address,
    &Symbol::new(env, "burn_scaled"),
    args,
);

The debt-token burn checkpoints borrow rewards once:

Self::handle_incentives_action(&env, &pool_address, &borrowed_asset, &on_behalf_of, 1)?;

Then, because _receive_a_token = true, the router transfers collateral aTokens from the borrower to the liquidator:

let xfer_result = env.try_invoke_contract::<bool, KineticRouterError>(
    &updated_collateral_reserve_data.a_token_address,
    &Symbol::new(env, "transfer_on_liquidation"),
    xfer_args,
);

That aToken transfer checkpoints supply rewards for both addresses:

Self::handle_incentives_action(&env, &state.pool_address, &state.underlying_asset, &from, 0)?;
Self::handle_incentives_action(&env, &state.pool_address, &state.underlying_asset, &to, 0)?;

The same receive-aToken branch also sends protocol-fee collateral to treasury when a fee is due and treasury is configured:

let fee_xfer_result = env.try_invoke_contract::<bool, KineticRouterError>(
    &updated_collateral_reserve_data.a_token_address,
    &Symbol::new(env, "transfer_on_liquidation"),
    fee_xfer_args,
);

That second aToken transfer again checkpoints supply rewards for two addresses.

Under a valid configuration with 20 borrow rewards on the debt token and 20 supply rewards on the collateral aToken, one liquidation performs:

debt burn hook:
  20 borrow reward streams

collateral aToken transfer to liquidator:
  20 borrower supply reward streams
  20 liquidator supply reward streams

collateral aToken fee transfer to treasury:
  20 borrower supply reward streams
  20 treasury supply reward streams

total:
  100 reward-stream iterations

The token contracts catch ordinary incentives-call failures and continue, but CPU exhaustion is not an ordinary contract error that can be cleanly ignored. Once the host budget is exhausted, the whole top-level liquidation cannot complete.

Impact

This is a liquidation liveness issue.

The PoC creates an unhealthy borrower and deliberately leaves the collateral reserve short of idle underlying. In that state, receiving underlying collateral is not viable because the collateral aToken does not hold enough cash to transfer out. The receive-aToken path is supposed to be the resilient alternative: it can seize the borrower’s aToken balance without moving underlying.

With max-valid rewards configured, that fallback path becomes too expensive and fails under the normal CPU budget. The result is that an unhealthy account can remain unliquidated until incentives are changed, rewards are disabled, or the position changes enough for another liquidation path to become available.

This does not let an attacker steal funds. The damage is delayed liquidation and increased bad-debt exposure under a configuration the protocol itself permits.

Recommended Mitigation

Keep optional reward accounting out of the critical liquidation budget.

Reasonable fixes include:

  • reducing the reward-token cap to a value proven safe for composed liquidation flows;
  • using a lower cap for token hooks invoked from liquidation;
  • deferring reward checkpoints during liquidation and allowing users to checkpoint later;
  • processing only a bounded number of reward streams per hook invocation; or
  • moving incentives accounting to a pull-based model for high-cost paths.

The important invariant is that a valid incentives configuration must not be able to make an otherwise valid liquidation exceed the network transaction budget.

Proof of Concept

See original finding for full Proof of Concept


The original report as published on Code4rena, by Egobouros. 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 per-asset cap on reward tokens does not account for the fact that a single liquidation can invoke multiple incentivized token operations, each processing all reward tokens for that asset, leading to an aggregate cost that exceeds the transaction budget.

Impact

A valid incentives configuration can cause receive-aToken liquidations to fail due to CPU exhaustion, delaying liquidation and increasing bad-debt exposure, though no funds are stolen.

What the attacker needed

Unhealthy borrower; collateral reserve short of idle underlying; max reward tokens configured (20 per asset); liquidation with receive-aToken mode

The fix

The incentives cap should be reduced or reward checkpoints deferred during liquidation so that a valid configuration cannot make a liquidation exceed the network transaction budget.

How it was found

  1. Create an unhealthy borrower and leave the collateral reserve with insufficient idle underlying.
  2. Configure the maximum allowed reward tokens (20) on both the debt token and the collateral aToken.
  3. Initiate a direct liquidation with _receive_a_token = true.
  4. Observe that the transaction fails due to CPU budget exhaustion.

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 this lending protocol, when someone repays a debt or moves collateral tokens, the system also updates reward points for various reward tokens. Each update costs computing power. A liquidation can trigger many such updates, and if there are many reward tokens configured, the total computing cost can exceed the network's limit, making the whole liquidation fail. This means a borrower who should be liquidated might avoid it simply because the reward configuration is too heavy.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More by Egobouros

View all

1 more disclosed report, 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.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.