Frontrunning the first deposit may unbalance the pair #341
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
upgraded by judge
Original issue severity upgraded from QA/Gas by judge
Lines of code
https://github.com/code-423n4/2022-12-caviar/blob/0212f9dc3b6a418803dbfacda0e340e059b8aae2/src/Pair.sol#L63
Vulnerability details
Impact
Creating the pool and making the first deposit are two separate actions. When the pool is first created, before the owner provides the first assets in a reasonable ratio, an attacker/griefer can attack the pool with an absurd ratio which will cause an imbalance between the assets in the pool.
Such an attack may cause two issues:
Proof of Concept
Consider this scenario:
Tools Used
Recommended Mitigation Steps
Perform the first deposit to pool when it is first created, calling nftAdd() from the constructor.
The text was updated successfully, but these errors were encountered: