FraudCodex FraudCodex
Market Abuse Crypto & Digital Assets

Flash Loan Attacks

Borrowing large uncollateralized sums within a single transaction to manipulate prices or drain DeFi protocols.

Last reviewed

1 Introduction

A flash loan attack exploits a feature unique to decentralized finance: the ability to borrow a very large, uncollateralized sum that must be borrowed and repaid within a single atomic blockchain transaction. Because the loan only needs to be solvent at the end of the transaction, an attacker can command tens of millions of dollars for a few milliseconds. The attacker uses that temporary capital to skew the price in a thin automated market maker (AMM) pool or a price oracle, tricks a victim protocol into trusting the manipulated price, extracts value, and repays the loan in the same transaction. If any step fails, the entire transaction reverts and the attacker simply loses gas.

1 tx

Borrow, manipulate and repay in a single atomic transaction

$0

Collateral required to borrow the loan

Tens of millions

Drained from DeFi protocols in single transactions

2 Interactive Atomic Transaction Walkthrough

Phase: Loan Requested

Single Atomic Transaction

AMM Pool Price vs. True Market Price

Step 1 - Loan Requested: The attacker calls a lending pool and borrows $100M with no collateral. The pool releases the funds on the condition that they are returned before this same transaction ends. Nothing has been manipulated yet.

3 Detailed Analysis

Why Atomicity Is the Weapon

The Flash Loan

An uncollateralized loan that only has to be solvent at the end of one transaction. It grants an attacker enormous, risk-free capital for the duration of a few function calls, with no credit check and no down payment.

The Price Oracle

Protocols that read a price directly from a single AMM pool can be fooled. A large trade temporarily moves the spot price, and any contract that trusts that instantaneous figure values collateral incorrectly.

Legal & Regulatory Framework

Flash loans themselves are lawful; liability turns on what the borrowed capital is used for. In the US, the CFTC and DOJ have treated manipulating a DeFi protocol's price oracle to borrow against inflated collateral as commodities manipulation and fraud, as in the Mango Markets case below, and exploits can also be charged as wire fraud (18 U.S.C. §1343). In the EU, MiCA Art. 91 prohibits manipulating crypto-asset prices under MiCA's market-abuse title (Arts. 86-92), which has applied since 30 December 2024, but it applies to crypto-assets admitted to trading or for which admission has been requested, and MiCA leaves services provided in a fully decentralised manner outside its scope.

Detection Methodology

The flash-loan step lives inside one transaction, so traditional account-monitoring cannot stop it, although many DeFi exploits also involve preparatory or follow-on transactions that can be monitored. Defenders instead analyze transaction traces and mempool activity for the tell-tale shape: a large borrow from a lending pool, an immediate outsized swap against a low-liquidity pool, an interaction with a separate protocol at a skewed valuation, and a repayment, all in the same block. On-chain analytics also watch for instantaneous price deviations between an AMM spot price and time-weighted or external reference prices, since a healthy market does not move tens of percent and snap back within one transaction.

Notable Cases

bZx attacks (2020) - Academic analysis, Qin et al.

In February 2020 two attacks on the bZx lending protocol used flash loans to manipulate prices across DeFi venues, among the first widely studied flash-loan exploits. Researchers found both had returns on investment above 500,000%, and showed the parameters could have been tuned to earn about $829,500 and $1.1 million.

DeFi exploits warning (2022) - FBI IC3, United States

The FBI reported that about $1.3 billion in crypto was stolen in the first quarter of 2022, roughly 97% of it from DeFi platforms. Among its examples, one attacker used a flash loan to trigger a smart-contract flaw, costing about $3 million, and another manipulated a single price oracle to take about $35 million.

Mango Markets (2022) - CFTC / DOJ SDNY, United States

Avraham Eisenberg allegedly pushed the oracle-reported price of the MNGO token up more than 13-fold in 30 minutes, then borrowed against the inflated collateral and withdrew over $110 million, later returning about $67 million. It was the CFTC's first oracle-manipulation case; the attack used the attacker's own capital rather than a flash loan but exploited the same oracle weakness.

Red Flags

  • A large uncollateralized borrow and full repayment occurring within a single transaction
  • An AMM spot price deviating sharply from time-weighted or external reference prices, then reverting
  • A protocol pricing collateral from a single low-liquidity pool that is cheap to move
  • One transaction touching a lending pool, a thin AMM pool, and a victim protocol in rapid sequence

4 Sources & Further Reading

Links point to primary legislation, regulators, international bodies and official enforcement records. Always check the current version of a text before relying on it.

Related Fraud Types