A flash loan attack uses flash loans — uncollateralized loans that must be borrowed and repaid within a single transaction — to exploit vulnerabilities in DeFi protocols. Attackers borrow massive amounts of capital with zero upfront investment, manipulate markets or prices, profit from the exploitation, and repay the loan, all atomically in one transaction.
How Flash Loan Attacks Work
The Attack Blueprint
Flash loans give anyone access to millions of dollars of capital instantly. Attackers use this firepower to exploit economic weaknesses in DeFi protocols.
1. Attacker borrows millions via flash loan (no collateral needed)
2. Uses borrowed funds to exploit a vulnerability
3. Profits from price manipulation, oracle exploits, or logic flaws
4. Repays the flash loan within the same transaction
5. Keeps the profit - zero personal capital at risk
The first major flash loan attack demonstrated the concept to the world. The attacker borrowed ETH via a flash loan, manipulated the Kyber Network oracle to inflate a token price, profited from the inflated price on bZx, and repaid the flash loan.
Protocol Defenses
Technical Mitigations
Time-weighted average prices (TWAP) - Use averaged prices over time instead of spot prices
Multiple oracle sources - Chainlink, Pyth, and other decentralized oracles with circuit breakers
Flash loan-resistant design - Delay critical operations or require multi-blockconfirmation
Economic bounds - Limit the maximum profit from a single transaction
Reentrancy guards - Prevent recursive calls combined with flash loan capital
Monitoring and Response
Real-time monitoring - Forta, OpenZeppelin Defender for anomaly detection
Circuit breakers - Auto-pause when unusual activity is detected
Insurance funds - Reserve capital to cover potential losses
Bug bounty programs - Incentivize white-hat researchers to find vulnerabilities first
Economic Security Considerations
Flash loan attacks highlight that DeFi security is not purely a code problem — it is an economic design problem. Protocols must be economically secure against actors who can temporarily command billions of dollars of capital. This requires game-theoretic analysis and economic modeling alongside traditional code audits.