A newly deployed pool can be DoS
A newly deployed liquidity pool can be permanently disabled by providing zero amounts of both tokens as the first liquidity provision. This leaves the pool with zero reserves but non-zero supply, causing all subsequent liquidity additions to fail with a division-by-zero error.
Source: https://github.com/sherlock-audit/2025-09-dango-dex-judging/issues/363
Found by
0x37, 0xAsen, 0xShoonya, 0xc0ffEE, 0xkmr_, Boy2000, Kirkeelee, LeFy, MissDida, OhmOudits, Synthrax, Yashar, ZeroEx, Ziusz, berndartmueller, calc1f4r, d33p, haxagon, heavyw8t, joicygiore, maigadoh, merlin, vangrim, vivekd, x15
Summary
A newly deployed pool can be DoS by just providing liquidity with zero amounts
Root Cause
The problem originates from the fact that it does not check if the provided coin amounts are 0, or the LP mint amount is 0 at the first liquidity provision when pool supply is 0. In case the provided amounts are 0, after the first mint, the pool reserves are still 0 (reserves value is 0) but the pool supply is non-zero which causes any further liquidity provisions unable to be executed because of arithmetic error (division by 0)
-
No zero amounts check at
execute.rs::provide_liquidity(),liquidity_pool.rs::add_liquidity()and also atxyk.rs::add_initial_liquidity()andgeometric.rs::add_initial_liquidity() -
After the first provision with zero amounts, the next provisions can not be executed because of the arithmetic error division by 0. As a result, the pool is unable to operate
// xyk.rs
pub fn add_subsequent_liquidity(
reserve: &mut CoinPair,
deposit: CoinPair,
) -> anyhow::Result<Price> {
let invariant_before = normalized_invariant(reserve)?;
// Add the used funds to the pool reserves.
reserve.merge(deposit)?;
// Compute the proportional increase in the invariant.
let invariant_after = normalized_invariant(reserve)?;
let invariant_ratio = Price::checked_from_ratio(invariant_after, invariant_before)?; // <<<<<<<<<<<< invariant_before = 0 here
// Compute the mint ratio from the invariant ratio based on the curve type.
// This ensures that an unbalances provision will be equivalent to a swap
// followed by a balancedliquidity provision.
Ok(invariant_ratio.checked_sub(Price::ONE)?)
}
// geometric.rs
pub fn add_subsequent_liquidity(
oracle_querier: &mut OracleQuerier,
reserve: &mut CoinPair,
deposit: CoinPair,
) -> anyhow::Result<Price> {
let deposit_value = oracle_value(oracle_querier, &deposit)?;
let reserve_value = oracle_value(oracle_querier, reserve)?;
reserve.merge(deposit)?;
Ok(deposit_value.checked_div(reserve_value)?) // <<<<<<<<<< reserve_value = 0 here
}
Internal Pre-conditions
NA
External Pre-conditions
NA
Attack Path
- A pair/pool is initiated
- The pool is provided with both quote amount = 0 and base amount = 0 (by arbitrary caller)
- An liquidity provider tries to provide liquidity but it fails
Impact
- Pool is completely DoS and it is unable to function
PoC
Update the test dango/testing/tests/dex.rs::provide_liquidity() as below:
fn provide_liquidity(
provision: Coins,
swap_fee: Udec128,
pool_type: PassiveLiquidity,
oracle_prices: Vec<(Denom, Udec128)>,
expected_lp_balance: Uint128,
) {
let (mut suite, mut accounts, _, contracts, _) = setup_test_naive(Default::default());
let lp_denom = Denom::try_from("dex/pool/dango/usdc").unwrap();
// Owner first provides some initial liquidity.
let initial_reserves = coins! {
- dango::DENOM.clone() => 100,
- usdc::DENOM.clone() => 100,
+ dango::DENOM.clone() => 0,
+ usdc::DENOM.clone() => 0,
};
Run the test with the test cases and it will throw error as below
expected success, got error: contract returned error! address: 0x8dd37b7e12d36bbe1c00ce9f0c341bfe1712e73f, method: execute, msg: division by zero: 200000000000000000000000000000000000000000000000000 / 0
Mitigation
Explicitly ensure if the first provision amount are not 0 and the first LP mint is not 0
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 code does not check that the initial liquidity amounts or the initial LP tokens minted are greater than zero, so a zero-value first deposit leaves reserves at zero while supply becomes non-zero.
Impact
The pool is completely denied service and unable to function, as all later liquidity provisions fail with a division-by-zero error.
What the attacker needed
Newly deployed pool with zero supply; attacker can call provide_liquidity
The fix
The code should explicitly ensure that the first provision amounts are not zero and that the first LP mint is not zero.
How it was found
- A pair/pool is initiated
- The pool is provided with both quote amount = 0 and base amount = 0 (by arbitrary caller)
- An liquidity provider tries to provide liquidity but it fails
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 liquidity pool is a shared pot of two tokens that people add to and trade against. The first person to add tokens sets the starting amounts, and the pool uses those numbers to work out how much of the pool each later person owns. If the first person adds nothing, the pool's maths breaks and nobody else can ever add tokens, so the pool 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.