Skip to content

DappsAtlas index · 14,224 dApps

DappsAtlas

Security and scams · Explainer

Flash Loan Attacks in DeFi: What Happened and How to Protect Funds

A flash loan attack uses an uncollateralized loan that is borrowed and repaid in one transaction to move prices or exploit a contract bug. This guide explains how these attacks work, what the loss data shows through 2024, and what users and protocols can do about them.

By the DappsAtlas editorial team · Updated

Illustration for Flash Loan Attacks in DeFi: What Happened and How to Protect Funds

What is a flash loan?

A flash loan is an uncollateralized loan on a DeFi protocol. The borrower takes funds and must repay them, with any fee, before the transaction ends. If repayment does not happen, the whole transaction is reversed as if it never took place. Because the lender is protected by this rule, no collateral is needed.

Flash loans are mainly offered on Ethereum-based lending protocols. Aave V3 is one well-known example of a lending market that has offered flash loans. Developers use them for legitimate purposes such as arbitrage between exchanges, refinancing a debt position in one step, or swapping collateral without first holding the full amount.

The important point is that a flash loan gives anyone access to a large amount of capital for a few seconds, without needing to own that capital or pledge anything. That property is useful for efficient markets. It also lowers the cost of attacking a protocol that has a weakness, because an attacker can temporarily control a large sum at almost no upfront cost.

A flash loan is not an exploit on its own. The attack happens when the capital is used to trigger a flaw in the way a protocol values assets, processes calls or records balances.

How does a flash loan attack work step by step?

Most flash loan attacks follow a similar sequence within one transaction:

  1. The attacker borrows a large amount of one or more tokens through a flash loan.
  2. The attacker uses those funds to move a price on a pool or exchange that another protocol relies on.
  3. The attacker interacts with the target protocol while the distorted price or inconsistent state is in place. This may mean borrowing more than the collateral should allow, minting tokens at a wrong rate or withdrawing more than deposited.
  4. The attacker restores the price or reverses the temporary position, then repays the flash loan with the fee.
  5. The attacker keeps the difference as profit, if the attack worked.

The whole process happens inside one block. Because the steps are atomic, the attacker does not face the risk that the market moves against them between steps. That is why these attacks can look like instant, perfectly timed trades when observed on a block explorer.

Attacks often combine a flash loan with several contract calls. Analysts who study them usually break the transaction into its internal calls to see which step gave the attacker the advantage.

What kinds of bugs do flash loan attacks exploit?

Research and post-mortems describe several recurring weaknesses that flash loans help exploit:

  • Oracle manipulation: A protocol reads a token price from a pool that a large trade can move in the same block. If the protocol trusts that spot price, the attacker can make an asset look more or less valuable than it is.
  • Reentrancy: A contract sends funds or makes an external call before updating its own records. The called contract can call back into the protocol and act on stale balances.
  • Donation or balance-accounting errors: A protocol assumes its balance changes only through its own functions. A direct transfer of tokens can change its internal calculations if the contract reads its raw balance.
  • Logic errors: A rule in the code does not match what the designers intended, such as a missing check on a parameter or an incorrect rounding path.

These categories overlap. A single incident can combine a price manipulation with a logic error, which makes the root cause harder to name in a summary headline.

For users, the practical lesson is that a protocol can be well known and still contain these issues. Reputation alone does not show whether a specific pool reads prices safely or handles external calls correctly.

Which flash loan attacks are the most cited examples?

Several incidents show the range of these attacks. In 2020, reporting on flash loan attacks against Curve Finance liquidity pools described attackers using borrowed funds to manipulate prices, and the protocol discussed changes to stop that pattern. Coverage at the time framed the combined losses from flash loan attacks across DeFi as roughly one hundred million dollars.

In May 2021, the DeFi protocol bEarn reported losses of about 11 million dollars from a flash loan attack. In April 2023, the protocol 0VIX reported losses of about 2 million dollars in a flash loan exploit, based on on-chain data at the time.

Recent analysis of larger incidents also points to case studies such as Cetus, Penpie, KyberSwap and UwU Lend, which were cited as examples of how flash loans amplify oracle, donation and reentrancy bugs into large losses.

These cases differ in scale and cause, but they share a pattern: a flash loan supplied the capital, and a flaw in price handling or contract logic supplied the opportunity. When reading about any single incident, look for the specific mechanism, the amount at risk and whether the affected funds were recovered.

What do the loss figures from recent research show?

A study published in the Journal of Financial Crime examined flash loan attacks from February 2020 to July 2024. Reporting on the study put total losses at about 1.2 billion dollars across 72 incidents. Coverage of the same research described the attacks as growing more sophisticated and less predictable over that period.

The same study found that logic exploits accounted for 55 percent of flash loan losses from February 2022 to July 2024, up from 28 percent in the earlier comparison window. In plain terms, a larger share of losses came from flaws in how protocol code behaved, rather than from price manipulation alone.

The shift matters for defense. Oracle protections address one class of problem, but they do not remove every logic error. Protocols need testing, review and monitoring of the full set of contract interactions, not only the price feed.

Readers should keep in mind that totals depend on how incidents are classified and valued. Some incidents involve tokens whose prices fell sharply after the attack, so dollar figures vary by method. Check the original study or a reputable summary for the exact methodology before quoting a number.

Why do flash loan attacks affect ordinary depositors?

Flash loan attacks rarely harm only the protocol that was attacked. Depositors in a lending market can see their funds drained or their positions mispriced if the bad debt is not covered. Liquidity providers in an exchange pool can lose value when the pool is rebalanced at a manipulated price. Token holders can see the price of a token collapse after an exploit.

The effects also spread through connected protocols. When one protocol uses another protocol's price as its own reference, a distorted price can cause losses in both places. This is why DeFi is often described as composable, meaning protocols are linked through shared assets and calls.

For a lender, a flash loan attack can create bad debt if collateral is valued too high when a loan is opened. For an exchange, it can allow a trader to buy or sell at a price that the pool should not have offered. For a vault or yield strategy, it can cause the strategy to act on false information.

The lesson for users is to think about dependencies. A position that looks safe in one protocol may depend on price data or collateral rules set somewhere else.

How do protocols defend against flash loan attacks?

Protocols use several defenses against flash loan attacks. Their effectiveness depends on how each is built and maintained:

  • Manipulation-resistant price sources: Using time-weighted average prices or independent oracle networks makes it harder for one transaction to move the reference price. Pyth Network is one example of a first-party oracle provider used by blockchain applications.
  • Reentrancy guards and checks-effects-interactions ordering: Updating internal balances before making external calls prevents a called contract from acting on stale data.
  • Balance and accounting checks: Protocols can track internal balances instead of reading raw token balances, which reduces the risk from direct transfers.
  • Collateral and borrow limits: Conservative loan-to-value settings and borrow caps limit how much damage a single distorted price can cause.
  • Audits, formal verification and bug bounties: Independent review and paid bug reporting catch logic errors before attackers do.
  • Pause mechanisms and monitoring: Some protocols can pause specific markets when unusual behavior appears. Governance and multisig processes determine how quickly this can happen.

No single defense covers every case. A strong protocol combines several of these measures and publishes how it handles risk. Read the protocol's documentation to see which controls it uses.

What practical steps can a DeFi user take?

Users cannot change a protocol's code, but they can reduce their exposure with a few habits:

  1. Check whether the protocol has been audited, and read the scope of each audit. An audit of one contract does not cover the whole system.
  2. Look for a documented oracle setup. If the documentation does not say where prices come from, treat that as a warning sign.
  3. Start with a small amount in any new or unfamiliar pool, and increase only after you understand how it works.
  4. Review and revoke token approvals you no longer use. Wallet and explorer tools can list active approvals for an address.
  5. Avoid pools that use a single thin market as their only price reference, especially for less liquid tokens.
  6. Keep records of your positions and watch for protocol announcements about pauses, incidents or governance proposals.
  7. Confirm that you are on the official site or app before connecting a wallet, since phishing pages often copy legitimate DeFi interfaces.

These steps do not remove risk. They help you avoid the most common mistakes and give you time to respond if something changes.

Where can I check the current status of an attack?

Flash loan attack coverage changes quickly, and the numbers and case details in news headlines can be revised. For current information, use these sources:

  • The affected protocol's incident post-mortem, which usually explains the root cause, the amount lost and any recovery plan.
  • Published audit reports for the protocol, including the scope and any issues that were fixed.
  • On-chain transaction records on a block explorer, which show the sequence of calls in a specific attack.
  • Peer-reviewed or institutional research on flash loan losses, which states its methodology and time window.
  • Official protocol governance forums and announcements, where teams explain changes to risk parameters.

When comparing sources, check the date, the time window, the token prices used and whether losses were counted before or after recoveries. Two accurate reports can give different totals if they measure different things.

For readers who want to follow DeFi security more broadly, the most useful habit is to read primary sources first and treat summary headlines as a starting point.

Frequently asked questions

Are flash loans themselves illegal or dangerous?

Not directly. A flash loan is a tool, and the attack comes from a flaw in how a protocol reads prices, handles calls or accounts for funds. Flash loans make it cheap to borrow the large sums needed to exploit that flaw within a single transaction.

How can a regular DeFi user reduce the risk of being affected?

Start by checking whether a protocol has been audited, whether its price data comes from a manipulation-resistant source, and how it has handled past incidents. Keep your exposure small in newer pools, and revoke token approvals you no longer need. Check local laws before using any DeFi service, since rules differ by country.

Who loses money in a flash loan attack?

Attackers usually profit from the protocol or from other users who hold positions in the affected pool. Depositors, liquidity providers and sometimes token holders can lose funds when a pool is drained or its assets are mispriced. Recovery depends on the protocol, its reserves and any governance decision.

Why do different sources report different totals for flash loan losses?

Loss totals depend on how incidents are counted and which tokens are valued at which prices. Published studies and news reports often give different figures for the same period. Check the original research or the protocol post-mortem for the method used, and treat headline totals as estimates.

Where can I check the latest details on a specific attack?

Post-mortems from the affected protocol, published audit reports and security write-ups from reputable research teams are the most useful. On-chain transaction records let you verify what happened in a specific incident. News headlines are useful for leads but often lack the mechanism details.

Mentioned in this guide

dApps in this guide

Flash Loans logoScore 6.0 out of 10

Flashloans.com is a web app for building flash-loan-funded DeFi trades, with analytics and optional FLASH-staking memberships.

Ethereum · BNB Chain
Aave V3 logo

Aave V3

Lending

Score 8.6 out of 10

Aave V3 is a non-custodial DeFi lending protocol on 21 chains where users earn interest on deposits or borrow against collateral.

TVL $15.1B+1.9%Ethereum · Base · Arbitrum +18

Curve

DEXes

Score 8.0 out of 10

Curve is a decentralized exchange on Ethereum built for low-slippage swaps of stablecoins and similar assets, with CRV governance and a crvUSD stablecoin.

Ethereum
Uniswap V3 logoScore 8.4 out of 10

Uniswap V3 is a non-custodial decentralized exchange protocol for token swaps and concentrated liquidity provision across 40+ chains.

TVL $1.51B−3.7%Ethereum · Base · Arbitrum +38
Uniswap V2 logoScore 8.0 out of 10

Uniswap V2 is a non-custodial automated market maker DEX on 17 chains for token swaps and liquidity provision, with about $938M TVL.

TVL $864M−4.1%Ethereum · Base · Polygon +14
Pyth Network logo

Pyth Network

Infrastructure

Score 8.0 out of 10

Pyth Network is a first-party price oracle and market data provider for blockchain apps, trading venues and institutions, with its own PYTH token.

TVL $0Solana
Compound V3 logoScore 8.0 out of 10

Compound V3 is a lending protocol on Ethereum and nine other chains where users supply a base asset for yield or borrow it against collateral.

TVL $1.25B−3.3%Ethereum · Arbitrum · Base +7
Euler V2 logo

Euler V2

Lending

Score 8.0 out of 10

Euler V2 is a modular DeFi lending protocol for lenders, borrowers and market curators, with about $268M TVL across 16 chains.

TVL $264M−1.8%Monad · Ethereum · Base +13
Score 6.8 out of 10

Curve Finance is an Ethereum decentralized exchange for swapping stablecoins and closely pegged assets, aimed at DeFi users who want low slippage.

Ethereum

Keep reading

Related guides

All security and scams guides

DeFi · Explainer

Compound Explained: Ethereum DeFi Lending Guide for 2026

Compound is one of the oldest and most studied lending markets on Ethereum, so learning how it works gives a clear view of the wider DeFi lending, borrowing and stablecoin landscape. This guide explains the mechanics, the risks and the related protocols to compare.

DeFi · Explainer

The 2020 DeFi Blueprint: What It Was and What Remains

The 2020 DeFi blueprint is the set of building blocks that decentralized finance settled on that year: automated exchanges, pooled lending, crypto-backed stablecoins and token incentives. This explainer covers what those pieces were, how they combined, and what readers should understand about them today.

dApp basics · How-to

How to Integrate the Open DeFi Notification Protocol in 2026

The Open DeFi Notification Protocol is a way to send wallet and on-chain event alerts to users. The public results reviewed for this guide do not include a full integration reference, so this guide covers a sound integration method and shows how to verify the current interface before you build.

DeFi · Explainer

Is Wrapped Bitcoin Driving DeFi Growth in 2026?

Wrapped bitcoin is one of the main ways BTC gets into Ethereum-style DeFi, but no single metric proves it drives sector growth. This guide explains what it does, what public sources show, and how to check current figures yourself.