Submitted by Yunaci, also found by Rhaydden, crypticdefense, Naresh, kodyvim, emmac002, erictee, WinSec, ZanyBonzy, Sparrow, julian_avantgarde, lightoasis, Bauchibred, and Sathish9098
The  Trade contract lacks any checks against the retrieved price. It doesnt utilize TWAP. Consequently, an attacker can manipulate the spot price (slot0) through a flash loan attack. This manipulation can lead to highly inaccurate trade results and potential loss of funds for the users.
The Trade contract  initiates the trading process by calling  Trade::trade(). This function sets the tradeResult.sqrtPrice by calling Trade::getSqrtPrice().
The Trade::getSqrtPrice() retrieves the sqrtPrice using the uniswapPool and the boolean  isQuoteZero as arguments.
Internally calls the UniHelper::getSqrtPrice() function with the relevant parameters and returns the sqrtPrice calculated directly using the spot price(slot0), which an attacker can manipulate, which can lead to highly inaccurate trade results and potential loss of funds for the users.
https://github.com/code-423n4/2024-05-predy/blob/main/src/libraries/Trade.sol#L112C5-L114C6
https://github.com/code-423n4/2024-05-predy/blob/main/src/libraries/UniHelper.sol#L13C4-L15C6
In order to run the test, go to test/pool and replace the content of Trade.t.sol with the one from the gist below. You can also delete the file and create a new one with its code.
https://gist.github.com/Vancelott/198c4e9133a7ee5d4d6900471a9717f7
Basic flow of the test:
Consider using the TWAP price instead of the spot price in order to prevent price manipulation.
syuhei176 (Predy) acknowledged and commented via duplicate Issue #74:
0xsomeone (judge) decreased severity to Medium
0xsomeone (judge) commented via duplicate Issue #74:
