Skip to content
DoS Audit finding Intermediate

Reserve-slot squatting DoS via forced aToken recipient collateral bit

The router automatically marks any aToken transfer recipient as using that reserve as collateral, without consent. An attacker can send dust aTokens from 15 reserves to fill a victim's reserve bitmap, causing future supplies to revert and blocking liquidators from receiving aTokens.

coinsspor Follow with 0xki, AllTooWell and 8 others

Originally disclosed on Code4rena

Submitted by coinsspor, also found by 0xki, AllTooWell, deccs, Falofi, honey-k12, MinionTechs, samuraii77, twicek, v12, and wuji

Found with V12

  • contracts/kinetic-router/src/router.rs #L1877-L1882
  • contracts/kinetic-router/src/operations.rs #L100-L105
  • contracts/kinetic-router/src/liquidation.rs #L414-L421
  • contracts/kinetic-router/src/storage.rs #L9

validate_and_finalize_transfer unconditionally sets is_using_as_collateral(reserve_id) = true on any aToken transfer recipient whose post-transfer scaled balance is greater than zero. Combined with the K2-specific hard cap MAX_USER_RESERVES = 15, an attacker can permanently grief any target address by dust-transferring 1 wei of aTokens from 15 distinct reserves. Once the victim’s user-config bitmap is saturated, every subsequent supply() that would open a new reserve position panics with MaxUserReservesExceeded, and the same MAX_USER_RESERVES check in liquidation_call blocks any liquidator whose bitmap was pre-squatted from seizing collateral via the _receive_a_token=true path.

Root Cause

In validate_and_finalize_transfer (router.rs:1877-1882), after computing the recipient’s new aToken balance, the function executes:

if to_balance_after > 0 && !to_config.is_using_as_collateral(reserve_id) {
    to_config.set_using_as_collateral(reserve_id, true);
}

This auto-enables collateral on fresh aToken receipt with no consent gate and no collateral-cap check. Aave V3’s SupplyLogic.executeFinalizeTransfer contains no such recipient-side flip — it only manipulates the sender’s bitmap. This is a novel K2-introduced behavior that diverges from Aave V3.

The MAX_USER_RESERVES = 15 hard cap (K2-specific; Aave V3 allows 128) turns a previously-innocuous auto-enable into a DoS weapon: 15 dust transfers completely saturate any target’s bitmap.

Attack Scenario — Base DoS

  1. Attacker supplies MIN_FIRST_DEPOSIT = 1000 wei into each of 15 configured reserves. Total cost: 15 times 1000 wei across 15 distinct tokens — sub-cent on any realistic asset.
  2. For each reserve, attacker sends 1 wei of the corresponding aToken to the victim. Each transfer triggers validate_and_finalize_transfer, flipping the collateral bit for that reserve on the victim’s user-config.
  3. Victim’s count_active_reserves() equals 15.
  4. Any supply() call by the victim into a 16th reserve panics at operations.rs:104 with MaxUserReservesExceeded.
  5. The victim’s only “escape” is to manually withdraw the 1-wei dust from an old reserve to clear the bit — but the attacker re-stuffs the freed slot at near-zero cost on the next block. Unbounded griefing.

Attack Scenario — Liquidator DoS (Higher Impact)

An underwater-prone borrower can weaponize this bug before going underwater to lock out specific liquidation bots:

  1. Borrower supplies collateral and borrows to near-max LTV.
  2. Borrower (or a Sybil address they control) stuffs a target liquidator’s user-config with 15 dust aToken positions. Cost: about 15k wei total.
  3. Asset price drops, the borrower’s HF falls below 1.
  4. The target liquidator calls liquidation_call(..., _receive_a_token=true).
  5. Liquidation reverts at liquidation.rs:417-419 with InvalidLiquidation because the liquidator’s count_active_reserves() >= MAX_USER_RESERVES check fails.

The _receive_a_token=false fallback path still works, but:

  • It requires sufficient underlying liquidity in the aToken contract — often drained during market stress when liquidations matter most.
  • It forces the liquidator to accept underlying immediately instead of aTokens, disrupting bots optimized for the aToken-receive path (avoiding DEX slippage, earning supply rate while waiting to exit).
  • During volatile markets, this can delay liquidations long enough for bad debt to materialize.

Impact

Direct user-facing DoS:

  • Any user can have their ability to open new reserve positions permanently griefed at near-zero attacker cost.
  • The victim must actively monitor and sweep dust from saturated slots; the attacker re-saturates faster than the victim can respond in practice (a single attacker tx vs a user-initiated withdraw loop requiring price oracle availability and per-reserve transactions).

Protocol-level impact via liquidator DoS:

  • Sophisticated liquidation bots using _receive_a_token=true can be selectively disabled by targets before those targets go underwater.
  • The fallback path (_receive_a_token=false) exists, preventing full unliquidatability.
  • Under market stress, when the aToken’s underlying liquidity is drained (liquidations create the outflows that deplete it), the fallback itself may fail with InsufficientBalance, leaving positions genuinely unliquidatable and creating bad-debt accrual.

Proof of Concept

Two runnable tests in tests/c4/src/lib.rs demonstrate the vulnerability end-to-end:

  1. test_forced_collateral_bit_on_atoken_transfer — confirms the root-cause primitive: a 1-wei aToken transfer flips the recipient’s collateral bit without consent.
  2. test_liquidator_slot_squatting_blocks_liquidation — the full impact chain: the borrower squats a liquidator’s 15 slots, price drops, liquidation_call(_receive_a_token=true) reverts with InvalidLiquidation, while the _receive_a_token=false fallback confirms the bug is isolated to the aToken-receive path.

Running the PoC

./build.sh
cargo test --package k2-c4 test_forced_collateral_bit_on_atoken_transfer -- --nocapture
cargo test --package k2-c4 test_liquidator_slot_squatting_blocks_liquidation -- --nocapture

Expected output

test test_forced_collateral_bit_on_atoken_transfer ... ok
test result: ok. 1 passed; 0 failed

[liquidator] post-squat total_collateral_base: 1500000000000
[borrower] HF after price drop: 991666666666666666
[liquidator] try_liquidation_call(receive_a_token=true) = Err(Ok(InvalidLiquidation))
[liquidator] fallback(receive_a_token=false) = Ok(Ok(()))
test test_liquidator_slot_squatting_blocks_liquidation ... ok
test result: ok. 1 passed; 0 failed

Both tests pass, confirming the DoS chain end-to-end: the forced collateral bit flip is the primitive, the MAX_USER_RESERVES cap is the weaponization surface, and the liquidation path is the highest-impact target.

Recommended Mitigation

Mirror Aave V3’s executeFinalizeTransfer semantics: do not auto-flip the recipient’s is_using_as_collateral bit on aToken receipt. The recipient should explicitly opt in via set_user_use_reserve_as_coll. The supply-side flow that legitimately benefits from auto-enable (first supply by the caller themselves) is already covered separately in operations::supply and does not require this code path.

Minimal patch to validate_and_finalize_transfer:

// REMOVE the force-set block on recipient:
if to_balance_after > 0 && !to_config.is_using_as_collateral(reserve_id) {
    to_config.set_using_as_collateral(reserve_id, true);  // DELETE THIS LINE
}

If auto-enable is preferred for UX, gate it on the recipient’s current count_active_reserves() < MAX_USER_RESERVES and fall back to leaving the bit unset when the cap is reached. This preserves the UX convenience for normal flows while removing the DoS vector — an attacker-forced dust transfer into a 16th reserve becomes a no-op on the bitmap rather than a revert on the victim’s next supply.


The original report as published on Code4rena, by coinsspor. 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 transfer finalisation logic automatically enables the collateral bit for the recipient without checking consent or the maximum reserve limit.

Impact

Users can be permanently griefed from opening new reserve positions, and liquidators using the aToken-receive path can be blocked from liquidating, potentially leading to bad debt under market stress.

What the attacker needed

Attacker can supply to 15 reserves; victim receives aTokens; victim has fewer than 15 active reserves

The fix

Remove the automatic collateral bit flip on aToken receipt, or gate it on the recipient's active reserve count being below the maximum.

How it was found

  1. Attacker supplies a minimal deposit into each of 15 reserves.
  2. Attacker sends 1 wei of each aToken to the victim.
  3. Each transfer flips the collateral bit for that reserve on the victim's config.
  4. Victim's active reserve count reaches 15.
  5. Victim's supply into a 16th reserve reverts with MaxUserReservesExceeded.

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 someone receives a small amount of a special token (aToken), the system automatically treats it as collateral they want to use. There is a limit on how many different reserves a user can have active. An attacker can send tiny amounts from many reserves to fill up that limit, so the victim cannot add new reserves and some liquidators cannot receive aTokens.

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 coinsspor

View all

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

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.