Oracle risk
how price feed manipulation enables flash loan attacks
Oracles are the bridge between on-chain contracts and off-chain prices. Protocols that use prices for liquidations or collateral calculations are entirely dependent on that data being accurate and manipulation-resistant. Flash loan-funded oracle attacks have been responsible for hundreds of millions in losses.
Analyse a protocolOracle dependency detection · EVM
Every scan is powered by the XemaS Semantic Intelligence Platform · answers carry their evidence and coverage state
The price your protocol reads determines what an attacker can take
DeFi protocols that calculate loan collateral, trigger liquidations, or determine payouts based on asset prices cannot operate without external price data. Smart contracts have no native access to market prices - they must read them from an oracle. The quality and manipulation-resistance of that oracle is a direct determinant of protocol security.
A spot AMM price - the current ratio of two tokens in a liquidity pool - can be moved in a single transaction by anyone with enough capital. Flash loans provide that capital with no collateral requirement, making manipulation cheap and fast. A protocol that reads a spot AMM price for liquidation decisions is structurally exposed to this attack class.
The oracle type a protocol uses is not always disclosed prominently. It is typically visible in the contract's source code or technical documentation. This guide covers how to identify it and what each type means for security.
Five oracle types and their manipulation resistance
| Oracle type | How it works | Manipulation resistance | Best use |
|---|---|---|---|
| Spot AMM price | Reads the current ratio of two tokens in an AMM pool | Very low - manipulable in a single transaction | Should not be used for loan pricing |
| Time-weighted average price (TWAP) | Averages price over a time window (e.g. 30 minutes) | Moderate - cost of manipulation scales with window length | Short TWAP windows still vulnerable to sustained price attacks |
| Decentralised price feed | Aggregates reports from multiple independent node operators | High - requires corrupting multiple independent parties | Loan pricing, liquidations, derivatives |
| Centralised price feed | Single entity provides the price | Low - single point of failure | Internal metrics only, not liquidation logic |
| Hybrid with circuit breakers | Uses decentralised feed with deviation thresholds that pause the protocol | High | Production use where maximum safety is required |
How a flash loan oracle attack works
A flash loan provides an attacker with a large amount of capital for a single transaction with no collateral requirement. The attacker uses that capital to temporarily move the price in an AMM pool.
The protocol reads that manipulated price and takes an action based on it - typically allowing the attacker to borrow against inflated collateral, or triggering a liquidation at a manipulated price that benefits the attacker.
At the end of the same transaction, the flash loan is repaid. The attack costs only the gas fee and whatever it costs to move the price in the pool. The profit is the difference between the manipulated price and the real market price.
A TWAP oracle requires this manipulation to be sustained over minutes or hours, which makes it economically prohibitive for many targets - but not impossible for protocols with sufficient TVL to justify the sustained capital exposure.
Five-step oracle risk assessment
Identify the oracle type
Is the protocol reading a spot AMM price, a TWAP, or a decentralised price feed? This is usually documented in the protocol's technical documentation or visible in the contract's source code.
Check the TWAP window length if applicable
A 30-second TWAP is nearly as manipulable as a spot price. A 30-minute TWAP provides meaningful resistance. Check what window the protocol uses for price-sensitive functions like liquidations.
Verify the number of independent price sources
A decentralised price feed is only as good as the number of truly independent node operators reporting to it. Check how many operators are reporting and whether they have different infrastructure providers.
Check for circuit breakers and deviation bounds
Well-designed protocols pause liquidations or borrowing if the oracle price deviates more than a threshold (typically 5-10%) from a reference price. This limits the damage from a manipulated or stale oracle reading.
Review what actions use oracle prices
Not all oracle use is equally risky. Using a spot price to display a UI figure is low-risk. Using a spot price to calculate liquidation thresholds is critical risk. Identify which protocol functions depend on oracle prices and how those functions are secured.
Free · No sign-up required
What analysts get wrong about oracle risk
Treating decentralised oracle as fully trustless
Even decentralised price feeds have governance mechanisms, operator sets that can change, and moments of price volatility where feeds lag actual market conditions.
Ignoring oracle dependencies in composable protocols
A protocol that borrows from another protocol is exposed to that protocol's oracle risk. The dependency chain matters.
Assuming TWAP eliminates oracle risk
A long TWAP window raises the cost of manipulation but does not eliminate it. Sustained price manipulation over hours is economically feasible for large enough targets.
Not checking what the protocol does when the oracle is stale
If the oracle stops reporting (node outage, network congestion), does the protocol pause gracefully or continue using the last known price indefinitely?