Submitted by 0xSmartContract, also found by 0xDecorativePineapple, 0xmatt, 0xNazgul, berndartmueller, brgltd, catchup, ch13fd357r0y3r, cryptonue, Jeiwan, ladboy233, minhtrng, neko_nyaa, rbserver, rvierdiiev, s3cunda, and Trust
AlgebraPool.sol#L193-L206
The initialize function in AlgebraPool.sol#L193-L206 is a very important function and sets the liquidity price at the beginning of the pool.
Performs some checks (For example, if the price is not 0).
However it is unprotected against running from the front, and a bot listening to Mempool will run from the front and cause its pool to start at too high or too low of a price.
It is very important that this function is not enabled for FrontRunning operation.
1- Alice starts a new pool in Algebra and triggers the price determination transaction with initialize.
2- Bob listens to the mempool with the following code, which is a minimal example, and sees at what price the initialize function is triggered with the initialPrice argument, and starts the pool at the price he wants by pre-executing it and makes Alice deposit the wrong amount at the wrong price.
Add a modifier that ensures that only the authorized person, that is, the first liquidator to the pool, initiates the initialize function.
Or, divide the process of determining the price of the pool into parts, first print the price amounts to the state variable, and then make the initialize run before this price can be changed.
0xean (judge) decreased severity to Medium and commented:
sameepsi (QuickSwap & StellaSwap) disputed and commented:
0xean (judge) commented:
