Bible Network Crypto DeFi Onchain RWA AI Agent Stablecoin CryptoTax DeFAI Chain SAFU AGI Claude Me Claude Skill Claude Cowork
Independent Media
Not affiliated with any project
DeFi Protocol Mechanics, Decoded
defi-bible.com
LATEST
How Do Stablecoins Actually Stay Stable? Three Fundamentally Different Designs  ·  What Does a Smart Contract Audit Actually Check? What to Know Before Reading a Report  ·  How Liquidation Mechanism Design Determines Whether a Market Crash Becomes a Systemic Crisis  ·  The Real Return on Yield Farming: The Costs High APY Doesn't Show You  ·  What Is DeFi? Understanding Decentralized Finance Through One Simple Question  ·  How Does an AMM Know What Price to Charge? Pricing Without an Order Book
risk

How Flash Loan Attacks Work: A Multi-Million Dollar Heist in One Transaction

30-Second Version · For the impatient
Flash loan attacks need zero capital, just one transaction — the real vulnerability usually isn't the lending mechanism itself, but the price oracle that gets manipulated.

Full Explanation +
01 · Why did this happen?

Why don't protocols simply ban flash loans to prevent these attacks?

Because flash loans themselves are a neutral tool — arbitrageurs, liquidation bots, and everyday users all rely on flash loans for legitimate capital operations. Banning them would also shut down an important market-efficiency mechanism. Most protocols instead focus on making their own pricing mechanism resistant to single-transaction manipulation — for example, adopting a time-weighted average price (TWAP) instead of a spot quote, so that even if an attacker can spike the price within one block, the price the protocol actually uses still reflects an average over time, sharply raising the cost of manipulation.

In other words, the defensive focus has shifted from 'blocking the tool' to 'making the tool unprofitable to abuse.'

02 · What is the mechanism?

Are there concrete historical cases illustrating this attack pattern?

The 2020 Harvest Finance incident is an early textbook case: the attacker borrowed a large sum via flash loan, executed a massive trade in a Curve pool to briefly distort the pool's stablecoin exchange rate, then exploited the gap between this distorted price and Harvest's vault pricing mechanism to arbitrage a profit of over $24 million — all within a single transaction lasting just minutes.

Similar incidents have recurred across different protocols since then, following a highly consistent pattern: manipulate a relied-upon price source first, then exploit the resulting price gap to arbitrage on another protocol. The only variation is which protocol function gets exploited — liquidation, minting, or borrowing-limit calculations.

03 · How does it affect me?

How does a flash loan attack differ from a typical 'hack'?

The key difference is that flash loan attacks usually don't involve breaching a system, stealing private keys, or exploiting a code vulnerability to bypass permission checks — every function the attacker calls is one the protocol explicitly allows anyone to call. What's actually exploited isn't 'a broken system defense,' but 'multiple legitimate functions chained together to produce a combined effect the designers never anticipated.'

This is also why traditional security thinking — firewalls, access control, input validation — offers almost no defense against this kind of attack: the attacker uses legitimate keys, legitimate calls, and legitimate transactions from start to finish. The only flaw exploited sits at the economic-logic layer, not the access-control layer of the code.

04 · What should I do?

How can an everyday user — not a developer — judge whether a protocol they use is vulnerable to flash loan attacks?

You don't need to read code to get a rough sense. A few indirect signals help: first, check whether the protocol has published a complete third-party audit report, and whether the audit scope explicitly mentions testing for oracle manipulation or price manipulation. Second, look at how the protocol describes its pricing mechanism — if it only mentions a 'live quote' with no reference to time-weighting or multi-source verification, that's a red flag. Third, pay attention to the protocol's total value locked (TVL) and pool depth — a shallow pool is inherently easier for a single large trade to move, making it a preferred target for this kind of attack.

None of these are absolute guarantees, but checking them before depositing funds — rather than looking only at the advertised APY — significantly lowers the odds of stepping into a landmine.

Full Content +

Since 2020, DeFi protocols have collectively lost hundreds of millions of dollars to flash loan attacks, and these attacks share a common trait: the attacker needs no upfront capital, yet can borrow tens of millions of dollars, manipulate a market, and walk away with profit — all within a single transaction. Understanding how this happens starts with the mechanism behind the flash loan itself.

Why Flash Loans Require No Collateral

The core rule of a flash loan is simple: borrowing and repayment must both complete within the same blockchain transaction. If the borrower fails to repay the principal plus fees by the end of the transaction, the entire transaction is automatically reverted, as if it never happened. This all-or-nothing atomicity lets protocols lend out massive sums to anyone with confidence, without requiring collateral or credit checks — because the protocol's default risk is effectively zero.

For legitimate users, flash loans were originally designed for one-off capital operations like arbitrage, collateral swaps, and liquidations. But that same atomicity also allows attackers to mobilize far more capital than they actually own, for a brief moment, to disrupt a protocol's pricing or governance mechanisms.

The Three Steps of a Typical Attack

Most flash loan attacks follow a similar pattern. Step one: the attacker borrows a large sum from a protocol, often worth millions to tens of millions of dollars in tokens. Step two: the attacker uses this capital to manipulate the price oracle the target protocol relies on — for example, executing a massive trade in a thinly liquid pool to artificially push a token's on-chain price up or down. Step three: the attacker exploits this manipulated, incorrect price to execute a liquidation, over-borrow, or an unfair swap on another protocol relying on the same price feed, locking in the price discrepancy as profit, before repaying the flash loan principal and fee to close out the transaction.

What makes this attack pattern hard to prevent in advance is that each individual step is a normal operation the protocol permits — borrowing, trading, and liquidating are all legitimate functions. The problem arises when an attacker chains them together into a self-contained loop that completes within a single block.

Price Oracles Are the Most Common Weak Point

In most exploited cases, the root cause isn't a flaw in the flash loan mechanism itself — it's a design flaw in the target protocol's oracle. Protocols that read spot prices directly from a single DEX pool, without time-weighted averaging or cross-referencing multiple sources, are especially vulnerable to having their price instantly distorted by a single large trade. This is why most auditing firms now treat 'can the oracle be manipulated within a single transaction' as a mandatory check before a DeFi protocol launches.

What This Means for Your Money

If you're a DeFi user — a depositor, liquidity provider, or token holder — the direct impact of a flash loan attack usually shows up as: a drained protocol treasury, a sudden token price crash, or governance voting power briefly hijacked to pass a malicious proposal. Before depositing funds into any protocol, it's worth checking whether its price data comes from a single DEX's spot quote or a multi-source, time-weighted oracle — the latter is generally far more resistant to flash loan manipulation. It also helps to avoid concentrating most of your assets in a single protocol, which limits the damage any one exploit can do to your overall holdings.

Ask a Question
Please enter at least 10 characters
Related Articles
How Liquidation Mechanism Design Determines Whether a Market Crash Becomes a Systemic Crisis
risk · Jul 23
How Do Stablecoins Actually Stay Stable? Three Fundamentally Different Designs
fundamentals · Jul 23
What Does a Smart Contract Audit Actually Check? What to Know Before Reading a Report
developers · Jul 23
The Real Return on Yield Farming: The Costs High APY Doesn't Show You
strategies · Jul 23
More Related Topics