VaderPoolV2.mintFungible exposes users to unlimited slippage
The mintFungible function in VaderPoolV2 allows users to provide liquidity without specifying a minimum number of LP tokens to receive. A frontrunner can manipulate the pool's reserves to cause the liquidity provider to receive fewer LP tokens than they should, extracting up to 100% of the provided value.
Originally disclosed on Code4rena
Submitted by TomFrenchBlockchain, also found by pauliax and robee
Frontrunners can extract up to 100% of the value provided by LPs to VaderPoolV2 as fungible liquidity.
Proof of Concept
Users can provide liquidity to VaderPoolV2 through the mintFungible function.
This allows users to provide tokens in any ratio and the pool will calculate what fraction of the value in the pool this makes up and mint the corresponding amount of liquidity units as an ERC20.
However there’s no way for users to specify the minimum number of liquidity units they will accept. As the number of liquidity units minted is calculated from the current reserves, this allows frontrunners to manipulate the pool’s reserves in such a way that the LP receives fewer liquidity units than they should. e.g. LP provides a lot of nativeAsset but very little foreignAsset, the frontrunner can then sell a lot of nativeAsset to the pool to devalue it.
Once this is done the attacker returns the pool’s reserves back to normal and pockets a fraction of the value which the LP meant to provide as liquidity.
Recommended Mitigation Steps
Add a user-specified minimum amount of LP tokens to mint.
SamSteinGG (Vader) acknowledged
Jack the Pug (judge) decreased severity to medium and commented:
I’m downgrading this [from
high] tomedand merging all the issues related to slippage control into this one.
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 mintFungible function lacks a user-specified minimum amount of LP tokens to mint, allowing frontrunners to manipulate reserves and reduce the LP tokens received.
What the attacker needed
LP provides liquidity via mintFungible; attacker can frontrun the transaction
The fix
Add a user-specified minimum amount of LP tokens to mint.
How it was found
- LP calls mintFungible to provide liquidity in a skewed ratio (e.g., a lot of nativeAsset but very little foreignAsset).
- Frontrunner sells a lot of nativeAsset to the pool to devalue it.
- LP's transaction executes, minting fewer liquidity units than they should.
- Attacker returns the pool's reserves back to normal and pockets a fraction of the value.
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 get pool tokens representing your share. This code lets you add money without saying the minimum pool tokens you'll accept. An attacker can quickly change the pool's balance before your transaction, so you get fewer pool tokens and lose value.
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.