Skip to content
Business logic Audit finding Advanced

calculate Loss is vulnerable to flashloan attack

The LP token valuation formula in VaderPool can be manipulated via a flash loan to inflate the value of a small LP position, allowing an attacker to claim excessive impermanent loss compensation and drain reserves. The report claims this is a high-risk issue.

jonah1005 Follow

Originally disclosed on Code4rena

Submitted by jonah1005

Impact

The VaderPool would compensate users’ IL. The formula it uses to calculate lp value is vulnerable to manipulation.

The formula to calculate the lp value is similar to warp finance which is known to be unsafe. warpfinance-incident-root-cause-analysis (Please to refer to the POC section)

The Attacker can purchase an old lp position, manipulate price, take IL compensation and drain the reserve. I consider this is a high-risk issue.

Proof of Concept

VaderMath.sol#L69-L93

The lp value is calculated as [(A0 * P1) + V0] and // [(A1 * P1) + V1]. Assume that there’s an ETH pool and there’s 100 ETH and 100 Vader in the pool.

  1. Attacker deposit 1 ETH and 1 Vader and own 1% of the liquidity.
  2. Wait 1 year
  3. Start flash loan and buy a lot ETH with 99900 Vader.
  4. There’s 0.1 ETH 100,000 Vader in the pool.
  5. Burn 1 % lp at the price 1 ETH = 1,000,000 Vader.
  6. A0 * P1 + V0 = 1 (eth) * 1,000,000 (price) + 100 (vader)
  7. A1 * P1 + V1 = 0.001 (eth) * 1,000,000 (price) + 10,000 (vader)
  8. IL compensation would be around 9891000.

Tools Used

None

Recommended Mitigation Steps

Please use the fair lp pricing formula from alpha finance instead. fair-lp-token-pricing

SamSteinGG (Vader) disputed:

The described attack scenario can not be executed as the pool would actually consume the flash loan. The CLP model follows a non-linear curve that actually diminishes in value as the trade size increases, meaning that at most 25% of the total assets in the pool can be drained at a given iteration. This, on top with the fees of each transaction render this attack vector impossible. Please request a tangible attack test from the warden if this is meant to be accepted as valid.

alcueca (judge) commented:

The CLP model isn’t mentioned in the readme or the whitepaper. The issue is valid according to the materials supplied.

SamSteinGG (Vader) commented:

@alcueca As the grading guidelines of C4 state, a documentation issue cannot constitute more than a low risk finding. We advise the severity to be lowered.

The original report as published on Code4rena, by jonah1005. 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 LP token value is calculated using the current pool balances and price, which can be manipulated within a single transaction via a flash loan.

Impact

An attacker could drain the pool's reserves by taking excessive IL compensation, though the project disputed that the attack is feasible due to the pool's non-linear curve and fees.

What the attacker needed

A small initial LP position; flash loan availability; waiting period (e.g., 1 year)

The fix

The report recommends using the fair LP pricing formula from Alpha Finance.

How it was found

  1. Attacker deposits a small amount of liquidity (1 ETH and 1 Vader) to own 1% of the pool.
  2. Wait one year.
  3. Start a flash loan and buy a large amount of ETH with Vader tokens.
  4. The pool now has very skewed reserves (0.1 ETH and 100,000 Vader).
  5. Burn the 1% LP at the manipulated price.
  6. The calculated IL compensation is around 9,891,000.

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 lets people deposit two tokens and get LP tokens representing their share. The pool also promises to compensate for impermanent loss, which is the loss compared to just holding the tokens. The report says the formula for valuing LP tokens can be tricked by temporarily swapping a large amount of tokens via a flash loan (a loan that must be repaid in the same transaction), making a tiny LP position appear very valuable and letting the attacker take more compensation than they should.

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 jonah1005

View all

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