first liquidity provider can manipulate price of share and steal funds from future liquidity providers #151
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#L63-L99
https://github.com/code-423n4/2022-12-caviar/blob/main/src/Pair.sol#L417-L428
Vulnerability details
Impact
The first liquidity provider can manipulate price of share by having 1 share only and sending in baseTokens and fractionalTokens to manipulate the price of the share. Future liquidity providers will then lose out on precision loss which will be gained by the first liquidity provider.
Proof of Concept
Place this in
NftAdd.sol
, babe that started out with 1e18 baseTokens is able to gain 2e17 baseTokens from victim after the attack.Tools Used
Foundry
Recommended Mitigation Steps
Set a minimum amount of share that must be left in the pool when withdrawing and also burn away some shares from first liquidity provider to ensure that the price is more robust against such attacks.
The text was updated successfully, but these errors were encountered: