Last Holder Can’t Exit, Zero‑Supply Unstake Reverts
When the last holder of a liquid staking token unstakes their entire balance, the token supply becomes zero before the asynchronous processing step runs. That step then divides by the zero supply and aborts, so the final staker's funds are permanently locked.
Submitted by maxzuvex
Finding description and impact
When a user burns the entire remaining supply of a Cabal LST ( sxINIT or Cabal LPT) via initiate_unstake, the follow‑up processing step always aborts with a divide‑by‑zero and the user can never exit.
- User calls
initiate_unstake(stake_type, S)– S equals the whole supply. unstake_xinit/unstake_lpqueuesprocess_*_unstakewithcosmos::move_execute( … "process_xinit_unstake" | "process_lp_unstake" … )for next transaction.- After queuing,
initiate_unstakeburns the LST:cabal_token::burn(S)⇒ live supply becomes 0. - Transaction 1 finishes and state now shows
supply = 0,pending[i] = S. - Later, Transaction 2 executes
process_*_unstake. - Calls
compound_*_pool_rewards(does not change LST supply). - Reads the current LST supply:
sx_supply = fungible_asset::supply(meta)⇒ 0. - Calculates
ratio = bigdecimal::from_ratio_u128(unstake_amount, sx_supply)which triggersassert!(denominator != 0)→EDIVISION_BY_ZEROabort.
Because the burn happened in a prior committed transaction, every retry of process_*_unstake gets the same supply == 0 state and fails again, so the user’s INIT / LP is permanently locked and it makes a DoS for the final staker of that pool.
// Simplified logic from process_xinit_unstake
entry fun process_xinit_unstake(account: &signer, staker_addr: address, unstaking_type: u64, unstake_amount: u64) acquires ModuleStore, CabalStore, LockExempt {
// ... permission checks, reward compounding ...
let m_store = borrow_global_mut<ModuleStore>(@staking_addr);
let x_init_amount = m_store.staked_amounts[unstaking_type];
// --- VULNERABILITY ---
// 'unstake_amount' is the original amount burned (== total supply in this case).
// 'sx_init_amount' reads the supply *after* the burn in initiate_unstake, so it's 0.
let sx_init_amount = option::extract(&mut fungible_asset::supply(m_store.cabal_stake_token_metadata[unstaking_type])); // Returns 0
// This attempts bigdecimal::from_ratio_u128(S, 0) --> Division by Zero!
let ratio = bigdecimal::from_ratio_u128(unstake_amount as u128, sx_init_amount);
// Transaction reverts here.
// ... rest of function is unreachable ...
}
Impact:
If an address burns the last sxINIT / LPT in circulation, every call to process_*_unstake reverts with EDIVISION_BY_ZERO, so no UnbondingEntry is recorded and the underlying INIT / LP can never be claimed. The final staker’s funds are permanently locked and causes a pool‑level denial of service.
Recommended mitigation steps
In process_xinit_unstake and process_lp_unstake:
let pool_before = m_store.staked_amounts[pool];
let supply = fungible_asset::supply(meta);
let unbond = if supply == 0 {
// last holder – give them the entire pool
pool_before
} else {
let r = bigdecimal::from_ratio_u128(unstake_amount, supply);
bigdecimal::mul_by_u64_truncate(r, pool_before)
};
- Guard against
supply == 0. - If it’s the final unstake, transfer the whole remaining pool; otherwise keep the original ratio logic.
Proof of Concept
// Assume pool index 1 is an LP‑staking pool
let pool_idx: u64 = 1;
// ── step 1: mint exactly 1 Cabal‑LPT to Alice ───────────────────────────
let mint_cap = &ModuleStore.cabal_stake_token_caps[pool_idx].mint_cap;
cabal_token::mint_to(mint_cap, @alice, 1); // total supply = 1
// ── step 2: Alice initiates unstake of the ENTIRE supply ────────────────
cabal::initiate_unstake(&signer(@alice), pool_idx, 1);
/*
* inside initiate_unstake:
* • cabal_token::burn(1) → total supply becomes 0
* • schedules process_lp_unstake() (async)
*/
// ── step 3: worker executes queued call ──────────────────────────────────
cabal::process_lp_unstake(&assets_signer, @alice, pool_idx, 1);
/*
* inside process_lp_unstake:
*
* let sx_supply = fungible_asset::supply(lp_metadata); // == 0
* let ratio = bigdecimal::from_ratio_u128(1, sx_supply);
* └────── divide‑by‑zero → abort
*
* transaction reverts with EZeroDenominator
*/
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 processing function reads the token supply after the initiating transaction has already burned the entire supply, then uses that zero value as a divisor without a guard.
Impact
The final staker's underlying INIT or LP tokens are permanently locked and the pool suffers a denial of service, because every retry of the processing step fails on the same zero-supply state.
What the attacker needed
Hold the entire supply of the LST; ability to call initiate_unstake
The fix
The processing functions should check whether the supply is zero and, if so, transfer the entire remaining pool to the last holder instead of performing the ratio calculation.
How it was found
- Mint or hold the entire supply of the liquid staking token.
- Call initiate_unstake for the full amount, which burns all tokens and queues a processing call.
- The queued process function runs in a later transaction and reads the now-zero supply.
- The ratio calculation divides by zero and the transaction aborts, leaving funds locked.
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 liquid staking token represents a share of a pool. When you unstake, the system burns your tokens and later calculates your share of the pool by dividing by the total number of tokens still in existence. If you are the last person holding any tokens, that total becomes zero, and dividing by zero makes the program crash, so your original deposit is stuck.
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.