Vast Mahogany Fox
High
Reliance on Uniswap V3's slot0 value instead of TWAP for price calculations will cause significant price manipulation vulnerabilities for protocol users as attackers can manipulate spot prices through flash loans and large trades.
The use of Uniswap V3's slot0 value for price calculations is a mistake as it appears in three critical functions:
- In
NumaOracle.sol:164
functiongetV3SpotPrice
uses slot0 directly for price calculations - In
NumaOracle.sol:257
functiongetV3SqrtLowestPrice
uses slot0 for price boundaries - In
NumaOracle.sol:329
functiongetV3SqrtHighestPrice
uses slot0 for price boundaries
In all these cases, the contract relies on the current spot price from slot0 instead of using time-weighted average prices (TWAP), making it vulnerable to price manipulation.
- The contract must be actively using one of the three vulnerable functions for price calculations
- The contract must have sufficient liquidity to make price manipulation profitable
- Uniswap V3 pool must have enough liquidity to allow for significant price movement
- Flash loan providers must be available to provide capital for manipulation
- Gas prices must be low enough to make the attack profitable
- Attacker identifies opportunity to manipulate price through one of the vulnerable functions
- Attacker takes out a flash loan for significant capital
- Attacker executes large trades on the Uniswap V3 pool to manipulate the spot price
- During the same transaction, attacker interacts with the protocol while prices are manipulated
- Attacker repays flash loan and keeps profits from the manipulation
The protocol users suffer potential losses due to price manipulation, with impact varying based on which function is exploited:
- For
getV3SpotPrice
: Direct price manipulation affecting all spot price-based calculations - For
getV3SqrtLowestPrice
: Manipulation of price boundaries affecting minimum price calculations - For
getV3SqrtHighestPrice
: Manipulation of price boundaries affecting maximum price calculations
The attacker can potentially gain significant profits by exploiting the price differences between manipulated spot prices and actual market prices, while protocol users face losses from incorrect pricing.
No response
Mitigation requires replacing all slot0 usage with TWAP calculations to provide manipulation resistance:
- Replace
getV3SpotPrice
with TWAP-based calculations - Modify price boundary calculations in
getV3SqrtLowestPrice
andgetV3SqrtHighestPrice
to use short-interval TWAP instead of spot prices