The following functions uses the UniV3Pool.slot0 to get price of tokens instead of a TWAP price. Given the price stored in slot0 is determined by the ratio of assets in the pool, it can easily be manipulated by buying/selling in the pool, such as utilizing a flashloan to manipulate prices of tokens and arbritrage, causing loss to Good Entry protocol.
Lines of code
https://github.com/code-423n4/2023-08-goodentry/blob/main/contracts/GeVault.sol#L368 https://github.com/code-423n4/2023-08-goodentry/blob/main/contracts/TokenisableRange.sol#L239 https://github.com/code-423n4/2023-08-goodentry/blob/main/contracts/TokenisableRange.sol#L370
Vulnerability details
Impact
The following functions uses the
UniV3Pool.slot0
to get price of tokens instead of aTWAP
price. Given the price stored in slot0 is determined by the ratio of assets in the pool, it can easily be manipulated by buying/selling in the pool, such as utilizing a flashloan to manipulate prices of tokens and arbritrage, causing loss to Good Entry protocol.Tools Used
Manual review
Recommended Mitigation Steps
Use a
TWAP
price instead of directly usingslot0
to retrieve token prices for calculation of token amount and liquidity.Assessed type
Uniswap