A chain cannot see off-chain prices by itself. An oracle feeds external data in, so a lending market knows what your collateral is worth and a perp knows the index price.
Oracles are a favourite attack surface: feed a contract a wrong price and you can drain it. The quality and decentralisation of the oracle is part of a protocol's real risk.