A smart contract is deterministic: every node must reach the same result from the same inputs, so a contract cannot call an external service. Anything from outside the chain — a price, an interest rate, a match result, a shipment confirmation — has to be written in by someone. That someone is an oracle, and everything the contract does with the value inherits the oracle's trustworthiness.
This is the oracle problem, and it is not solved by decentralising the contract. A lending protocol may be flawless and still be drained if it prices collateral from a source an attacker can move. The security of the system is the minimum of the code's security and the data's, and for several years the data was the weaker half.
The naive design reads a price from an on-chain automated market maker at the moment of the transaction — a spot price. Spot prices from a single pool are cheap to move, and flash loans made moving them nearly free: borrow a large sum within one transaction, push a shallow pool's price to an arbitrary level, take out a loan against collateral now valued at that price, and repay the flash loan, all atomically. A series of protocols were emptied this way in 2020 and 2021. No key was stolen and no contract was buggy in the ordinary sense; the price was simply wrong for one block.
The defences follow from that. Time-weighted average prices make manipulation expensive by requiring the attacker to hold the wrong price across many blocks rather than one, at the cost of lagging genuine moves. Aggregating across venues weighted by liquidity means a shallow pool cannot dominate the answer. Decentralised oracle networks have independent operators submit signed observations that are aggregated on-chain, with staking and reputation behind them, so corrupting the feed means corrupting many parties. And circuit breakers reject values that deviate implausibly from the last accepted one, which turns a manipulation attempt into a pause rather than a loss.
Each defence introduces its own problem. An averaged price is stale, and staleness is dangerous in the opposite direction: during a genuine crash, collateral valued at yesterday's price is not liquidated in time and the protocol takes the loss. Deviation thresholds that suppress updates in calm markets can leave a feed unchanged for long periods. And an aggregated feed still has an update cadence, so there is always a window in which the contract's view of the world is out of date. Choosing between these is a risk-management decision, not a technical one.
For a reader assessing a protocol, the oracle is one of the first things to look at and one of the least discussed. Which feed does it use, how often does it update, what is the deviation threshold, who operates it, and what happens if it stops? A protocol that cannot answer those questions in its documentation has not thought about the most common way its peers have lost money.