Skip to content
Business logic Audit finding Intermediate

add liquidity is vulnerable to sandwich attack

The addLiquidity function in the VaderRouter and VaderRouterV2 contracts did not check a minimum liquidity amount, so a user's deposit could be sandwiched by an attacker who trades around it. An attacker could buy the token before the victim's transaction and sell back afterwards to profit from the price movement.

jonah1005 Follow

Originally disclosed on Code4rena

Submitted by jonah1005

add liquidity is vulnerable to MEV

Impact

addLiquidity in the VaderRouter and VaderRouterV2 contract does not check the minimum liquidity amount. This makes users’ funds vulnerable to sandwich attacks.

The team says a minimum amount is not required as the VaderPool supports imbalanced mint. However, imbalanced mint is a helper function of buying tokens and providing to lp. A sandwich attack would take over more than 50% of a transaction in an illiquid pool.

Given the current network environment, most transactions in the mempool would be sandwiched. However, users may avoid this attack if they only send tx through flashbot RPC. I consider this is a medium-risk issue.

Proof of Concept

VaderRouterV2.sol#L77-L96

That says a user wants to provide 1M ETH in the pool. Attackers can sandwich this trade as follows:

  1. Buy Vader with 10M ETH and makes ETH extremely cheap
  2. Put user’s tx here User’s tx would first buy a lot Vader and deposit to the pool.
  3. Since ETH becomes even cheaper in the pool. The MEV attacker buyback ETH and get profit.

Tools Used

None

Recommended Mitigation Steps

Always check how much liquidity a user received in a transaction. A tx would not be sandwiched if it’s not profitable.

We could learn a lot about MEV from Robert Miller’tweets.

SamSteinGG (Vader) disputed:

The design of the Thorchain CLP model is meant to prevent flash-loan based attacks as it allows a maximum trade size of 25% on a given iteration with a high-enough fee to render the attack unprofitable. Please request a tangible test case from the warden to consider this exhibit valid.

alcueca (judge) commented:

There is no documentation stating that the deployment of Vader is restricted to Thorchain. The issue is valid.

SamSteinGG (Vader) commented:

@alcueca The model itself is what has this trait, it does not relate to the blockchain implementation itself. It is intended functionality as with its parent implementation.

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 addLiquidity function accepted a deposit without a minimum-liquidity parameter, so the caller could not bound how many pool shares they received.

Impact

Users' deposits could be sandwiched and lose value, though the reporter rates it medium risk and notes users may avoid it by submitting transactions through a private RPC.

What the attacker needed

Victim submits an addLiquidity transaction; attacker can see and front-run the mempool; pool is illiquid enough to move the price

The fix

The router should always check how much liquidity a user received in a transaction so an unprofitable sandwich is rejected.

How it was found

  1. An attacker buys the pool token in large size, making the other asset very cheap in the pool.
  2. The victim's addLiquidity transaction executes and deposits at the skewed price.
  3. The attacker buys the other asset back and takes the profit.

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 trading pool, the amount of pool shares you get depends on the price at that moment. If someone trades just before and just after your deposit, they can shift the price so you get fewer shares and they keep the difference; this is called a sandwich attack. The report says the deposit function never checked a minimum amount, so nothing stopped this.

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.