Smart contract bugs / What does it trust?
Price oracle manipulation
The protocol reads a price that the attacker can move in the same transaction, usually the spot price of one AMM pool. The attacker borrows against a fake price.
OWASP SC03:2026 · 121 real exploits · $994.9M lost
How the attack works
- A lending market or vault reads the price of a token from the reserves of one DEX pool, or from
balanceOfof a contract. - The attacker takes a flash loan and makes a large swap in that pool. The price moves.
- In the same transaction, the attacker borrows, mints or liquidates at the wrong price.
- The attacker swaps back, repays the flash loan and keeps the difference. Variants: a stale Chainlink price, an LP token priced from its reserves, a donation that changes an exchange rate.
Vulnerable and fixed code
function price() public view returns (uint256) {
(uint112 r0, uint112 r1,) = pair.getReserves();
return uint256(r1) * 1e18 / r0; // spot price: one swap moves it
}function price() public view returns (uint256) {
(, int256 p,, uint256 updatedAt,) = feed.latestRoundData();
require(p > 0, "bad price");
require(block.timestamp - updatedAt <= MAX_DELAY, "stale price");
return uint256(p) * 1e10; // scale 8 decimals to 18
}
// If no feed exists: use a TWAP over a long window, and cap
// how much the price can change between two reads.Review checklist
- Never use a spot price (pool reserves,
balanceOf,getAmountsOut) as an oracle. - Use a decentralized feed (Chainlink, Pyth, Redstone). Check the answer is positive and fresh. Check the sequencer uptime feed on L2s.
- For a TWAP, use a window that costs too much to move (30 minutes or more), and a pool with deep liquidity.
- Price LP tokens with a fair-reserves formula, not with their reserves.
- Add a circuit breaker: pause when the price moves more than a limit between reads.
How to test for it
- Fork mainnet in Foundry. Swap a large amount in the pool, then call your function. The result must not change.
- Test with a stale feed answer and with a zero or negative answer.
Real exploits (121)
-
Cream Finance: Cream Finance lost about $130M when an attacker used flash loans to manipulate the yUSDVault price (pricePerShare) read by Cream's PriceOracleProxy, then borrowed against the inflated collateral.
Root cause and fix
Vulnerable code:
PriceOracleProxyCream's internal PriceOracleProxy priced yUSDVault tokens from the vault's pricePerShare, which is the vault's yUSD balance divided by its totalSupply. An attacker could move this value. The attacker flash-loaned 500M DAI from MakerDAO and $2B in ETH from Aave. Using two addresses, they looped deposits and borrows to build about $1.5B of crYUSD. They then redeemed about $500M of yUSDVault, which cut totalSupply to about $8M. They also deposited about $8M of yUSD, which roughly doubled the share price. Cream then counted the collateral as about $3B, so the attacker repaid the flash loans and drained about $130M of lending assets.
What would have stopped it: Do not price collateral from a manipulable on-chain ratio such as vault balance divided by totalSupply. Use a manipulation-resistant price source such as a TWAP or Chainlink, add sanity or deviation bounds on share price changes within one transaction, and set collateral caps for vault-share tokens.
-
Tectonic: Tectonic on Cronos lost $120.4M in nominal borrowing (about $9.19M unrecovered after a chain rollback) when an attacker pumped the thinly traded TONIC governance token and borrowed against it as collateral.
Root cause and fix
TONIC, a governance token with about $1.34M liquidity and about $11k daily volume, had a 20% collateral factor and was priced from a thin on-chain pool through Tectonic's internal price feed. The attacker bridged about $5M, posted it as collateral, borrowed the available TONIC and re-supplied it in a loop of 98 iterations in one transaction, which gave a collateral claim on about two-thirds of TONIC's supply. They then bought TONIC with borrowed funds, which pushed the reported price up about 195-fold. The inflated collateral let them borrow $120.4M across nine markets. The post-mortem names three missing controls: no cap tying TONIC collateral to market depth, no block on borrowing and re-supplying the same token in one transaction, and no check on how fast collateral prices could move.
What would have stopped it: Don't list thin-liquidity tokens as collateral, or give them a very low collateral factor and supply and borrow caps tied to market depth. Price them with a manipulation-resistant oracle (TWAP, deviation checks, multi-source). Also block same-transaction borrow-and-resupply loops of the same asset.
-
BonqDAO: BonqDAO on Polygon lost a reported $120M (attacker realised under $2M) because it used the instantly updatable Tellor price of WALBT, which anyone could set by staking 10 TRB.
Root cause and fix
Vulnerable code:
TellorPriceFeed · submitValueBonqDAO read the WALBT collateral price from a Tellor feed and used the latest submitted value at once, with no delay or dispute window. Anyone who staked 10 TRB (about $175) could call submitValue and set the price. The attacker set WALBT to an enormous price, created a trove with 0.1 WALBT and minted 100M BEUR. In a second transaction they set the price extremely low, which made other users' troves liquidatable, and they liquidated them for about 113M WALBT.
What would have stopped it: Do not use the newest value from a permissionless oracle. Use a time delay or TWAP, a deviation or sanity bound against a second source such as Chainlink, and a cap on how far the price can move in one update. Audit every contract that was changed after the audit, including the price feeds.
-
Mango Markets: Mango Markets on Solana lost about $115M after an attacker pumped the thinly traded MNGO price and borrowed against the unrealised profit on an MNGO-PERP position.
Root cause and fix
The protocol counted unrealised profit on a perpetual position as collateral, and valued that profit using the MNGO price, which came from a low-liquidity, low-volume market. The attacker funded an account with about $5M USDC, took a large long MNGO-PERP position, and traded against it from a second account. This pushed MNGO from $0.03 to $0.91. With the inflated collateral value, the attacker borrowed and drained all available lending pools, leaving $115M of bad debt. Mango said it was genuine price manipulation, not an oracle failure. The article also says a user raised the risk in Discord in March.
What would have stopped it: Cap or heavily discount collateral value from unrealised PnL and from illiquid tokens. Set borrow limits and open-interest limits for thin markets, and use price bands or TWAP-based valuation. Test the design against a Venus-style price-pump scenario, and take public risk warnings seriously.
-
Compound Finance: Compound Finance saw over $110m of loans liquidated after its single Coinbase price oracle reported DAI at about $1.3, whether through error or manipulation.
Root cause and fix
Vulnerable code:
Coinbase price oracle (Compound price feed)Compound relied on a single off-chain oracle, the Coinbase price feed, with no second source or deviation check. The feed showed DAI spiking to about $1.3 on a thin order book (300k depth, so roughly 100k DAI could move it). That pushed accounts into liquidation, including a leveraged farmer who lent and borrowed DAI and USDC. Liquidators then borrowed DAI from Uniswap, repaid the debt, took more DAI as collateral, and repaid Uniswap. The article says it is unclear whether this was manipulation or a technical fault, and no flash loans were used.
What would have stopped it: Aggregate several independent price sources, such as a median of Chainlink and a TWAP. Add deviation and sanity bounds, for example reject a stablecoin price far from $1 or cap how much it can change per update. Use a circuit breaker that pauses liquidations when the feed looks abnormal.
-
PancakeBunny: PancakeBunny lost about $45M on BNB Chain when an attacker used flash loans to skew PancakeSwap pool prices used to value LP tokens, so getReward() minted huge amounts of BUNNY.
Root cause and fix
Vulnerable code:
VaultFlipToFlip · getReward()The protocol valued PancakeSwap LP tokens (for example BNB-BUSDT) using spot prices read from PancakeSwap pools, which an attacker can move within one transaction. The attacker took 8 flash loans (seven from PancakeSwap pools, one from Fortube), added liquidity to the WBNB+BUSDT pool, and swapped a large amount of WBNB to skew the reserves. They then called getReward() on VaultFlipToFlip, which used the inflated LP valuation to mint about 697,000 BUNNY (the article also says 6.97M). The attacker sold the BUNNY, the price fell from $146 to $6, and the flash loans were repaid.
What would have stopped it: Do not value LP tokens or compute reward mints from manipulable spot reserves. Use a manipulation-resistant price, such as a TWAP or a fair-LP-price formula backed by a trusted oracle. Also cap how much can be minted per reward claim. Audit every upgraded contract, including the helper functions.
-
Vee Finance: Vee Finance on Avalanche lost about $34M when an attacker manipulated its single-source Pangolin pool price oracle, helped by missing decimal handling in price acquisition.
Root cause and fix
Vee Finance used a single price oracle for leveraged trading: asset prices read from Pangolin pools. The attacker created new trading pairs (e.g. QI/WETH.e, XAVA/LINK.e) and traded between them to move the prices Vee referenced. Price acquisition also did not handle token decimals, so transactions that should have failed the protocol's slippage check were approved. The attacker used this to drain funds and bridged them back to Ethereum.
What would have stopped it: Do not use spot prices from a single AMM pool as the oracle; use a manipulation-resistant source such as a Chainlink feed or a TWAP, and reject prices from newly created or low-liquidity pairs. Normalize token decimals in all price math and test it with tokens of different decimals.
-
Spartan Protocol: Spartan Protocol lost about $30.5M from its SPARTA/WBNB pool because calcLiquidityShare() used the manipulable current pool balance when LP tokens were burned.
Root cause and fix
Vulnerable code:
SPARTA/WBNB pool · calcLiquidityShare()The liquidity share calculation calcLiquidityShare() read the pool's current token balance, which an attacker can inflate. It should have used the cached balances (baseAmountPooled/tokenAmountPooled). The attacker took a 10K WBNB flash loan and swapped through the pool. They added liquidity to mint pool tokens, then transferred extra WBNB and SPARTA straight into the pool to inflate its balance. Burning the pool tokens then paid out far more assets than were deposited. They repeated this several times and then repaid the loan.
What would have stopped it: Compute withdrawal shares from internally tracked (cached) reserves, not from live balanceOf values that anyone can change with a direct transfer. Add tests that donate tokens to the pool before a burn and check that payouts do not exceed what was deposited.
-
Harvest Finance: Harvest Finance lost about $25M from its FARM_USDT and FARM_USDC vaults when an attacker used flash loans to skew Curve Y pool prices that the vaults used to price deposits and withdrawals.
Root cause and fix
Vulnerable code:
FARM_USDT and FARM_USDC vaults (FARM_USDT strategy) · deposit()The vault priced LP share deposits and withdrawals from the Curve Y pool's spot stablecoin prices, which can be moved within a single transaction. The arbitrage check had a default slippage tolerance of 3%, which was too high to catch the manipulation. The attacker took a flash loan, swapped USDC to USDT on Curve to push the USDT price up, deposited USDT into the vault, swapped back to push the price down, and withdrew more USDT than they put in. They repeated this 32 times, making about $0.5M per cycle.
What would have stopped it: Do not price vault shares from a manipulable spot price of an AMM pool. Use a manipulation-resistant source such as a TWAP or an external oracle. Also enforce a tight deviation limit, much lower than 3%, between deposit and withdrawal valuation. Test with flash-loan-funded fork simulations.
-
XToken: XToken lost about $24M from its xSNXa and xBNTa pools when a flash-loan attacker pushed the SNX price down on Uniswap and minted tokens almost for free.
Root cause and fix
Vulnerable code:
xSNXa and xBNTaThe protocol bought SNX through Kyber, which routed the swap through Uniswap v2 at a spot price. The attacker had crashed that price with flash-loaned funds, so a tiny deposit (0.12 ETH) minted 1.2B xSNXa. Inside the protocol the xSNXa price still looked normal, so the attacker swapped the cheaply minted tokens for ETH and sold the rest into a Balancer pool. The same method was used to mint xBNTa for 0.03 ETH. The article gives the steps but does not name the vulnerable function.
What would have stopped it: Do not price minting from a manipulable spot price. Use a time-weighted or independent oracle, and add slippage and deviation limits on the swaps the protocol makes. Test minting against a pool whose price has been moved within the same transaction.
111 more examples in the full guide.