Skip to content
Business logic Audit finding Advanced

Wrong active-slot check

The supply function's first-supply branch used the wrong predicate to decide whether a deposit opens a new reserve slot, checking only the collateral bit rather than whether the reserve was already active through borrowing. A user at the 15-reserve limit who already borrows an asset but never supplied it would be blocked from supplying to that reserve, removing a recovery path.

v12 Follow with codegpt, dee24 and 7 others

Originally disclosed on Code4rena

Submitted by v12, also found by codegpt, dee24, mariannabezgin, oussama_05bm, oxwhite, Pherm007, udogodwin, wuji, and zpbrent

Found by V12

  • contracts/kinetic-router/src/operations.rs #L11

The first-supply branch in supply tries to enforce MAX_USER_RESERVES, but it uses the wrong predicate to decide whether the deposit opens a new reserve slot. It checks only !user_config.is_using_as_collateral(reserve_id) before counting active reserves, even though count_active_reserves() treats a reserve as active when either the collateral bit or the borrowing bit is set. A user who already borrows this asset but has never supplied it will therefore hit the “new position” path even though the reserve is already active in their bitmap. Once the user is at the 15-reserve limit, supplying to that same borrow-only reserve incorrectly panics with MaxUserReservesExceeded. That blocks a legitimate top-up / self-healing action precisely for users with the most complex positions.

Root Cause

The slot-limit check in supply tests is_using_as_collateral instead of testing whether the reserve is already active through either collateral or borrowing. That misclassifies existing borrow-only positions as new reserve entries.

Impact

An attacker can combine this with unsolicited aToken dusting on other reserves to push a victim to the 15-slot ceiling, then prevent the victim from supplying into a reserve they already borrow in order to improve health factor. This is a practical griefing and liquidation-assistance vector, not just a cosmetic accounting issue, because it removes a recovery path while leaving liquidation open.

Proof of Concept

See this gist for full Proof of Concept


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

Likely the slot-limit check tests only the collateral flag instead of whether the reserve is already active through either collateral or borrowing.

Impact

An attacker could combine this with unsolicited aToken dusting to push a victim to the 15-slot ceiling and then block them from supplying into a reserve they already borrow, removing a recovery path while leaving liquidation open.

What the attacker needed

Victim at the 15-reserve limit; victim borrows the asset but never supplied it; attacker can dust aTokens to victim

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 contract lets each user hold a limited number of asset positions, tracked as slots. The code that counts a new slot looked at only one of two flags that mark a position as already in use, so a position the user already had through borrowing was wrongly counted as new and the deposit was rejected.

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 by v12

View all

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

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.