The price of fractionalToken can be manipulated such that the future liquidity providers loose their baseTokens #242
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
duplicate-442
satisfactory
satisfies C4 submission criteria; eligible for awards
Lines of code
https://github.com/code-423n4/2022-12-caviar/blob/main/src/Pair.sol#L417
Vulnerability details
On first creating a new Pair, the user can define the amount of baseTokens and nfts they want to transfer to the contract. This is also true with an already initialized Pair, any user can select the amount of baseTokens and the amount of nfts they want to transfer in the contract.
An attacker can use this to manipulate price and steal from future liquidityProviders.
Vulnerability details
https://github.com/code-423n4/2022-12-caviar/blob/main/src/Pair.sol#L417
Proof Of Concept
Another attack vector would look like this:
Altough there is a slippage check
minLpTokenAmount
which prevents it from happening, it would only be used when the user specifically puts the minimum LP amount they want to recieve. An unknowing user who is unaware of the price of LP token can be scammed by the attacker.This is a issue similar to : https://code4rena.com/reports/2022-01-elasticswap/#m-01-the-value-of-lp-token-can-be-manipulated-by-the-first-minister-which-allows-the-attacker-to-dilute-future-liquidity-providers-shares and
TOB-YEARN-003
( https://docs.yearn.finance/security/ : trail of bits )Recommendations:
I suggest using the same mechanism in uniswap v2 to prevent such attack by locking first few liquidity tokens.
The text was updated successfully, but these errors were encountered: