Flash Loan Attack Simulator
Simulate the Attack
Enter parameters to see how a flash loan attack manipulates prices and steals funds.
Attack Visualization
Watch how the attack manipulates prices and exploits protocol vulnerabilities.
Enter parameters and click simulate to see results
Flash loan attacks arenât science fiction. Theyâre real, they happen every month, and theyâve stolen over flash loan attacks $1.7 billion from DeFi protocols in 2025 alone. You donât need a billion-dollar bank account to pull one off-just a few hundred dollars in gas fees and a basic understanding of how smart contracts work. Thatâs the scary part. These attacks exploit the very design of decentralized finance: speed, openness, and automation. And theyâre getting smarter.
What Exactly Is a Flash Loan?
A flash loan is a loan with no collateral. No credit check. No waiting. You borrow $10 million in ETH or USDC, do whatever you want with it, and pay it back-all within one blockchain transaction. If you fail to repay, the whole thing vanishes like it never happened. Itâs like borrowing a car, driving it into a wall, and returning it undamaged before the owner even notices you took it. This isnât magic. Itâs code. The smart contract that powers the flash loan checks: Did the borrower send back the exact amount plus fees? If yes, the transaction succeeds. If no, the entire transaction is rolled back. No one loses money. The attacker loses gas. And the system moves on. But hereâs the catch: while the loan itself is safe, the actions you take with that borrowed money arenât monitored. Thatâs where the attack begins.How a Flash Loan Attack Unfolds
Hereâs how a typical attack works in four steps:- Borrow: The attacker takes a huge amount of Token A from a flash loan provider like AAVE or dYdX.
- Manipulate: They swap Token A for Token B on a decentralized exchange (DEX) like Uniswap. By dumping a massive amount of Token A, they crash its price. Then they use that cheap Token A to buy up Token B, inflating its price.
- Exploit: They deposit the inflated Token B as collateral on a lending protocol that uses that same DEX as its only price feed. Because the price looks high, the protocol lets them borrow way more Token A than they should be allowed to.
- Repaid and Gone: They use the newly borrowed Token A to pay back the original flash loan. The transaction closes. The attacker walks away with free Token A, and the protocol is left with worthless collateral.
Real Attacks, Real Losses
These arenât theoretical. Theyâve cost millions-and sometimes hundreds of millions. In April 2022, an attacker borrowed $1 billion from AAVE and used it to take over Beanstalk Farmsâ governance. They changed the rules to mint new tokens, drained the treasury, and walked away with $182 million. The attack didnât even need to manipulate prices-it manipulated trust. PancakeBunny lost $200 million in 2021 when attackers used flash loans to flood its liquidity pools, then pulled out their tokens before anyone noticed. The BUNNY token dropped 90% in hours. Even in March 2025, KiloEx lost $7 million because its price oracle relied on a single DEX. Attackers swapped small amounts of a low-volume token to distort its value, then borrowed against it. The fix? Simple: stop trusting one exchange for price data.
Why These Attacks Keep Working
Three reasons:- Oracles are single points of failure. Most DeFi protocols get price data from one or two DEXs. If you can move the price on one, you control the whole system.
- Smart contracts arenât audited well enough. Many protocols launch with minimal testing. Reentrancy bugs, missing access controls, and unchecked inputs are still common.
- Thereâs no delay. Transactions execute instantly. No human review. No time to react.
How to Prevent Flash Loan Attacks
Protocols that survive these attacks use three proven strategies:- Use multiple oracles. Donât rely on Uniswap alone. Pull prices from Chainlink, Pyth, or several DEXs. Average them. If one feed is manipulated, the rest keep things stable.
- Implement TWAP (Time-Weighted Average Price). Instead of using the current price, use the average price over the last 5, 10, or 30 minutes. A flash loan canât move the average in one block.
- Code like your life depends on it. Use the checks-effects-interactions pattern. Add access controls. Test every edge case. Use tools like Slither and MythX to scan for bugs before deployment. Audits arenât optional-theyâre your last line of defense.
What Users Should Do
If youâre providing liquidity or staking tokens:- Avoid protocols that use a single price feed.
- Check if the project has been audited by a reputable firm like CertiK, Trail of Bits, or OpenZeppelin.
- Look for TWAP or multi-oracle setups in their documentation.
- Donât assume âbig nameâ means safe. Even AAVE has been targeted.
The Bigger Picture
Flash loan attacks are a symptom of a larger problem: DeFi is still too trusting. It assumes that because something is automated, itâs secure. But automation doesnât mean safety-it means scale. As attacks get more complex, so do defenses. Insurance protocols like Nexus Mutual and Cover Protocol are now offering coverage for flash loan exploits. Some DeFi teams are hiring former hackers to test their systems. Academic papers from MIT and Stanford are proposing new oracle architectures that use zero-knowledge proofs to verify prices without revealing data. The future wonât be free of attacks. But it can be harder to exploit.Whatâs Next?
The next big attack vector? Cross-chain flash loans. Imagine borrowing on Ethereum, manipulating a price on Solana, and repaying on Polygon-all in one atomic operation. The tech exists. The attacks are coming. Protocols that donât adapt will lose. Users who donât learn will lose more. The lesson isnât that DeFi is broken. Itâs that itâs still young. And like any young system, itâs being tested-hard.Can flash loans be used for legitimate purposes?
Yes. Flash loans are used legitimately for arbitrage, collateral swaps, and refinancing. For example, a user might borrow ETH to repay a loan on one platform, then use the freed-up collateral to borrow more on another. These are legal, profitable, and common. The problem isnât the flash loan-itâs when itâs used to manipulate prices or exploit bugs.
Why donât DeFi protocols just block large flash loans?
Because that defeats the purpose. Flash loans are designed to be permissionless. Limiting loan sizes would make them less useful for legitimate users and push activity to less regulated platforms. The goal isnât to restrict access-itâs to make manipulation impossible, even with large loans.
Are flash loan attacks illegal?
Legally, itâs a gray area. Since blockchain transactions are immutable and anonymous, prosecuting attackers is extremely difficult. No government has successfully convicted someone for a flash loan attack yet. But regulators in the U.S., EU, and Singapore are starting to classify these as market manipulation, which could change enforcement in the future.
Can I protect myself if Iâm just holding DeFi tokens?
You canât stop an attack, but you can avoid risky protocols. Stick to platforms with transparent audits, multi-oracle price feeds, and public incident response plans. If a project doesnât talk about security, assume itâs vulnerable. Also, avoid staking in protocols that rely on obscure or low-liquidity tokens-theyâre easier to manipulate.
Why are flash loan attacks increasing in 2025?
Because the tools are easier to use now. Attackers use pre-built exploit scripts, automated bots, and AI to scan for vulnerable contracts. The cost of launching an attack has dropped. At the same time, DeFi TVL (total value locked) has grown to over $120 billion-making it a bigger target. More money, easier tools, and slow defenses = more attacks.