Skip to content
Business logic Audit finding Advanced

Attacker can claim more IL by manipulating pool price then removeLiquidity

The Vader protocol reimburses impermanent loss (IL) immediately upon withdrawal, and the IL calculation uses the current pool balance, which an attacker can manipulate. An attacker who owns most of a pool could swap to skew the balance, remove liquidity to receive an inflated IL reimbursement, and then restore the balance, profiting at the protocol's expense.

gzeon Follow

Originally disclosed on Code4rena

Submitted by gzeon

Impact

Vader reimburse user IL immediately when user withdraw from the pool (VaderRouterV2.sol:L227), an attacker can therefore manipulate the pool balance causing a high IL, remove liquidity and restore the pool balance such that he will receive a larger IL reimbursement.

Proof of Concept

Let’s assume our attacker own 100% of FOO-VADER

  1. Attacker add 100 FOO and 100 VADER to the Pool

  2. wait some block, or 1 year for max IL protection

  3. In 1 transaction, attacker

    • Swap 9900 FOO to 99 Vader
    • Pool now have 10000 FOO and 1 VADER
    • By VaderMath.sol:L84 the loss is 100*1/10000+100-2 = 98.01 VADER
    • Remove liquidity and receive 10000 FOO and 99.01 VADER
    • Restore the pool balance
  4. Such that the attacker will gain 98.01 VADER without risk

The profit is constrained by gas cost, pool fee, % of pool controlled by the attacker and % of IL protection.

Recommended Mitigation Steps

Use twap price to determine P1 in VaderMath.sol:L84 when calculating IL to reduce risk of manipulation

SamSteinGG (Vader) commented:

Duplicate of #2

alcueca (judge) commented:

Doesn’t seem like a duplicate to me, @SamSteinGG?

SamSteinGG (Vader) commented:

@alcueca The stated trade cannot occur as trades are inherently limited by the CLP design of the protocol to one third of the available pair liquidity. As such, the illustrated pair would actually result in almost zero units retrieved back.

The original report as published on Code4rena, by gzeon. 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 IL reimbursement calculation uses the instantaneous pool balance rather than a time-weighted average price, allowing manipulation within a single transaction.

Impact

An attacker could gain tokens without risk, though the profit is limited by gas cost, pool fee, the share of the pool controlled, and the IL protection percentage; the protocol team also stated that trades are capped at one third of available liquidity, which would reduce the effect.

What the attacker needed

Own a large share of the pool; wait for IL protection period; pay gas and pool fees

How it was found

  1. Attacker adds liquidity to the pool.
  2. Attacker waits for the maximum IL protection period.
  3. Attacker swaps a large amount to skew the pool balance.
  4. Attacker removes liquidity and receives an inflated IL reimbursement.
  5. Attacker restores the pool balance.

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 you add money to a liquidity pool, you can suffer 'impermanent loss' if the price of the two tokens changes relative to each other. Vader promises to pay you back for that loss when you withdraw. The report says the payout is based on the pool's current balance, which an attacker can temporarily distort with a large trade, withdraw at a fake loss, and then undo the trade, leaving the protocol to cover a loss that never really happened.

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 gzeon

View all

46 more disclosed reports, best first.

More from Vader Protocol contest

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.