AI-assisted summary, reviewed by NullTX editors.

A lending protocol asks one pool a single question: what is ETH worth right now? The pool answers with whatever its reserves say this second. If an attacker can change the reserves in the same block, the protocol believes the new answer.

According to recent reports, this guide follows What Is a Stablecoin Depeg? How the Redemption Math Breaks a $1 Peg, another case where one price number decides whether money is safe. Below is a spot-price attack worked out in dollars, then what a 30-minute time-weighted average price (TWAP) costs to move.

A lending protocol needs to know what collateral is worth. Some read the price straight from an on-chain exchange pool. In a constant-product pool, that price is just the ratio of the two reserves. OWASP lists price oracle manipulation as SC02 in its 2025 Smart Contract Top 10, and warns it can lead to unauthorized withdrawals, excess leverage or drained pools.

ETH reserve times USDC reserve stays at 3,000,000,000.

Reads this pool's spot price, lends 80% of collateral value.

Owns 100 ETH ($300,000) and can take a flash loan.

It has been revealed that 1. Borrow with a flash loan. The attacker borrows 464,100 USDC with no collateral. It must be repaid inside the same transaction.

2. Push the price. Swapping that USDC into the pool leaves it with about 866.03 ETH and 3,464,100 USDC. The reserve ratio now reads $4,000, up 33%. The attacker receives about 133.97 ETH.

3. Borrow against the fake price. The attacker deposits their own 100 ETH. The lender values it at $400,000 and lends 80%, or $320,000 USDC. At the true price it would lend only $240,000.

4. Put the price back. The attacker sells the 133.97 ETH into the pool. Reserves return to 1,000 ETH and 3,000,000 USDC, and the attacker gets back about 464,100 USDC.

5. Repay and leave. The flash loan is repaid. The attacker keeps $320,000 and abandons the loan.

The lender now holds 100 ETH worth $300,000 against $320,000 of debt. That is $20,000 of bad debt, 6.25% of the loan. Pool fees at 0.3% cost the attacker about $2,400 on the round trip, plus about $230 for an assumed 0.05% flash-loan fee. The attacker nets about $17,350 with no capital at risk. All five steps happen in one transaction, so no one can step in between them.

A TWAP reads the pool twice, at the start and end of a window, and divides the change in a running price total by the time. Uniswap V2 records the price standing at the end of the previous block. A swap and its reversal inside one block never enters the average.

To drag a 30-minute TWAP to $4,000, the attacker must hold the price there across about 150 blocks, since Ethereum blocks arrive roughly every 12 seconds. Flash loans can't span blocks. Arbitrage bots also push the price back each block, and the attacker pays that loss every time. The paper's formula for one block is the reserve times (√(1+Ξ΅) + 1/√(1+Ξ΅) βˆ’ 2), where Ξ΅ is the price rise. Here Ξ΅ is one third and the USDC reserve is $3,000,000.

$62,200 lost per block, 150 blocks.

One block at $153,000, 51 times the price.

Sources indicate that the held TWAP costs about 3,500 times more than the spot attack. For this exploit to pay, the lender would need about $149 million of borrowable liquidity, because $9.33 million divided by the 6.25% bad debt is $149 million. My arithmetic, not the paper's.

Sources indicate that the paper's cost model assumes arbitrageurs fix the price every block. It also found that for large price moves, one massive spike costs less than holding the price, and its cost grows with the square root of the window, not in proportion to it. For a 135-block window the two routes cost the same at a price rise of about 57%, and above that the spike is cheaper.

It has been revealed that the worst case is an attacker who controls two blocks in a row, since no arbitrage bot can intervene. In the paper's own example, doubling a 30-minute TWAP on a $2 million pool cost about $16.2 million held, $9.75 million as a spike and about $160,000 with two controlled blocks. That last figure is a 2022 proof-of-work estimate, and the paper notes colluding proof-of-stake proposers could do the same. It cites a $15.6 million loss at Inverse Finance's Anchor lending protocol in 2022.

A longer window helps, but it makes the feed lag the real market.

1. Ask what it reads. A pool's spot price can be moved in one block. A TWAP or a signed feed takes more.

It has been revealed that 2. Check the pool's depth. Manipulation cost scales with reserves, so a thin pool is cheap to move.

Sources indicate that 3. Compare the cost to the prize. If the money the feed protects is far larger than the cost to move it, expect an attacker.

Recent findings suggest that off-chain oracle networks, liquidation attacks, and other chains. The pool, prices and loan are hypothetical. The paper's formula assumes no fees and perfect arbitrage every block, and my steps assume a 0.3% pool fee and a 0.05% flash-loan fee.

For another worked example in numbers, read NullTX on NEAR's inflation cut and the math behind a 5.27% to 3.37% staking yield.

One email a week unpacking one crypto or AI mechanism with the math shown.

More explainers and analysis from NullTX.

β†’ Read original article