What is a flash loan, and why can large sums be borrowed without any collateral?
Traditional lending requires collateral to guard against the risk of a borrower absconding. Flash loans fundamentally redesign this problem by exploiting smart contract atomicity: a transaction either executes completely or rolls back entirely — no in-between state exists.
A borrower can borrow millions of dollars within a single transaction, use the funds for arbitrage, liquidations, or other operations, then repay principal plus fees before that same transaction closes. If the repayment falls short, the smart contract causes the entire transaction to fail and revert — even the borrowing action itself is undone, so the lender's funds never truly left. There is therefore no credit risk whatsoever.
This design allows flash loans to provide massive liquidity without collateral, but requires the borrower to complete the entire capital cycle within a single transaction.
How do flash loan attacks work, and what are common attack patterns?
Flash loans are a neutral tool, but attackers can use them to amplify their capital scale within a single transaction, enabling operations impossible with small funds.
A typical attack flow: borrow tens of millions in assets → use those funds to manipulate a shallow market or oracle price → arbitrage or trigger unwarranted liquidations at the distorted prices → repay the loan and keep the profit, all within one transaction.
Common patterns include: (1) Oracle manipulation — using a massive buy order to inflate a DEX spot price, causing a lending protocol that relies on that price to misvalue collateral; (2) Governance attacks — instantly borrowing large amounts of governance tokens, passing a malicious proposal, then immediately repaying; (3) Reentrancy combinations — using flash loans to amplify capital, combined with reentrancy vulnerabilities to withdraw repeatedly.
Are flash loans inherently dangerous, or do they have legitimate uses?
Flash loans are fundamentally a frictionless short-term capital tool — whether they're dangerous depends entirely on how they're used.
Legitimate uses include: (1) No-capital arbitrage — when price gaps exist between different DEXs, flash loans enable arbitrage that eliminates those gaps, contributing to market pricing efficiency; (2) Costless position management — users with borrowing positions can borrow funds to repay old loans, swap collateral, and re-borrow, all without needing additional capital; (3) Liquidations — liquidators can borrow funds to complete large liquidations, then repay from the liquidation bonus.
The problem is that flash loans give attackers "temporary possession" of enormous capital, amplifying attacks against protocols with design flaws. Flash loans are not the vulnerability — the poorly-designed protocol is the real problem.
How do protocols defend against flash loan attacks?
Core defensive strategies focus on two directions: eliminating the profit margin for attacks, and invalidating the preconditions attacks rely on.
Main defenses: (1) Time-weighted average price (TWAP) oracles — flash loans complete within a single block; TWAP calculates average prices across multiple blocks, making it impossible for attackers to distort the pricing baseline with a single manipulation; (2) Decentralized oracles like Chainlink — obtaining prices from independent off-chain data sources rather than relying on manipulable DEX pools; (3) Timelocks in governance contracts — after a proposal passes, a delay must elapse before execution, defeating governance attacks that borrow and execute immediately; (4) Strict reentrancy locks — preventing repeated contract calls within the same transaction.
The 2020 bZx attack was one of the earliest well-known flash loan attacks. In a single transaction, an attacker borrowed 10,000 ETH, used part of it to open a short ETH position on bZx, then used the remaining funds to heavily buy WBTC — inflating its price relative to ETH in the oracle. bZx then underestimated the losses on the short position, netting the attacker roughly $350,000. The entire attack was completed within a single transaction in seconds.
Flash loans lower the capital barrier for arbitrage and liquidations, enabling people without large capital to perform operations that benefit market efficiency. But they simultaneously allow attackers to temporarily amplify their capital scale at near-zero cost, creating highly leveraged threats against protocols with design flaws. These are two sides of the same feature — it's impossible to keep only the benefits while eliminating the downsides. The protocol response is to fix their own design flaws, not to combat flash loans themselves.