hats-finance / Origami-0x998f1b716a5022be026ca6b919c0ddf45ca31abd

GNU Affero General Public License v3.0
2 stars 0 forks source link

Use of slot0 to get sqrtPriceLimitX96 can lead to price manipulation. #823 #26

Open hats-bug-reporter[bot] opened 7 months ago

hats-bug-reporter[bot] commented 7 months ago

Github username: @hunter-w3b Twitter username: hunter_w3b Submission hash (on-chain): 0x3c89e4bc9a1dd40615ea10cd4e069cca84d92f7001f10f6da4a96ba7e61b7691 Severity: medium

Description: Description\ In the TokenPrices::univ3Price.sol the function's uses UniswapV3.slot0 to get the value of sqrtPriceX96 which it use to perform the swap, however the sqrtPriceX96 gotten from Uniswap.slot0 is the most recent data point and can be manipulated easily via MEV bots & Flashloans⚡️ with sandwich attacks can cause lose of funds when interact with the Uniswap.swap function.

Attack Scenario\ An Attacker can Simply manipulate the sqrtPriceX96 and if the Uniswap.swap function is called with the sqrtPriceX96 the token will be bought at a higher price, and The Attacker would back run the transaction to sell thereby making gain but causing loss to whoever called those functions.

Recommended Mitigation Steps\ Use The TWAP to get the value of sqrtPriceX96.

frontier159 commented 7 months ago

out of scope: https://github.com/TempleDAO/origami-public/blob/main/docs/contents/OrigamiHatsAuditComp.md#files-in-scope