The MultiHopOracle contract exhibits a critical vulnerability in its price calculation mechanism that creates potential overflow conditions within the _getData() function. At the core of this vulnerability lies a mathematical computation pattern that, despite Solidity >=0.8.0's checked arithmetic, remains susceptible to overflow:
The contract's mathematical architecture introduces a critical vulnerability point during intermediate calculations. When executing price computations, the multiplication step occurs before the scaling division, creating scenarios where intermediate results can exceed type boundaries. This flaw is particularly insidious as the int216 type constraints become insufficient for handling these intermediate values, especially during periods of high market volatility or when processing multi-hop oracle paths.
In QuantAMM's TFMM context, this vulnerability assumes heightened significance as it can cause the entire oracle system to become unavailable precisely when it's most needed. During periods of high market volatility where prices experience significant movements, these calculations will revert due to overflow, making price data completely inaccessible. This unavailability occurs at the exact moments when accurate price data is most crucial for the protocol's operation.
The impact manifests as a complete denial of service for price feeds during extreme market conditions. When price calculations revert due to overflow, pools depending on these oracle paths cannot:
Execute their regular weight adjustment strategies
Process user transactions requiring price data
Perform critical rebalancing operations
This creates a particularly dangerous scenario where the protocol becomes paralyzed during high volatility events, exactly when active management is most needed.
Consider this scenario:
Scenario:
Market conditions are normal with:
ETH price at $2,000
BTC price at $50,000
A major market event occurs causing extreme volatility:
ETH price spikes 100x to $200,000
BTC price spikes 50x to $2,500,000
Bob, a liquidity provider, tries to:
Remove liquidity from a pool during this volatility
The pool attempts to calculate current values using the oracle
The MultiHopOracle attempts price calculation:
First multiplication exceeds int216 bounds
Transaction reverts due to overflow
As a result:
Bob cannot withdraw his liquidity
The pool cannot execute weight updates
All operations requiring price data fail
The protocol becomes effectively frozen during this critical market period
Operations only resume once prices return to ranges that don't cause overflow
Several users like Bob remain trapped in their positions during the most volatile period
Implement safe math operations with wider types:
Add price range validation:
Please read the CodeHawks documentation to know which submissions are valid. If you disagree, provide a coded PoC and explain the real likelyhood and the detailed impact on the mainnet without any supposition (if, it could, etc) to prove your point.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.