Closed c4-bot-10 closed 8 months ago
Picodes marked the issue as duplicate of #527
Picodes marked the issue as partial-25
This report doesn't discuss the slippage parameter
Picodes marked the issue as not a duplicate
Picodes marked the issue as duplicate of #937
Picodes marked the issue as unsatisfactory: Invalid
Picodes marked the issue as unsatisfactory: Invalid
Picodes marked the issue as unsatisfactory: Invalid
Lines of code
https://github.com/code-423n4/2024-01-salty/blob/53516c2cdfdfacb662cdea6417c52f23c94d5b5b/src/pools/Pools.sol#L140
Vulnerability details
Impact
When LP providers provide liquidity into a pool, the actual liquidity provided is calculated based on the current existing liquidity. Only 2 scenarios are possible here:
In the case that the pool is empty, an LP expects that his liquidity will be absorbed in full, therefore the pool will henceforth use that ratio from the provided token amounts, thus Pools:Ln97-105:
If the pool already has liquidity provided, the protocol needs to calculate how much of both tokens will be deposited, thus Pools:Ln97-105:
However, there's a possibility for an attacker to front-run a pool initial deposit that ends up with a favorable ratio for him to borrow/swap at low rates.
Proof of Concept
Attack scenario:
Tools Used
Manual review
Recommended Mitigation Steps
Tp prevent initial pool deposit frontrun, the initial pool deposit should be included as part of the contract creation code.
Assessed type
MEV