Securityintermediatearticle30 min read

DeFi Hacks 2021 Recap: The Year Flash Loans Exploded | VCC

The year 2021 was supposed to be DeFi's breakout moment. Total value locked in decentralized finance protocols surged past $180 billion, and new lending platforms, yield aggregators, and cross-chain bridges launched almost weekly. Instead, 2021 became the year DeFi hacks 2021 dominated every hea

Vietcardano teamTeam

Đội ngũ biên tập VietCardanoCommunity — các chuyên gia blockchain và Cardano, cung cấp nội dung giáo dục và nghiên cứu chuyên sâu cho cộng đồng.

Published September 14, 2026

The year 2021 was supposed to be DeFi's breakout moment. Total value locked in decentralized finance protocols surged past $180 billion, and new lending platforms, yield aggregators, and cross-chain bridges launched almost weekly. Instead, 2021 became the year DeFi hacks 2021 dominated every headline — attackers drained roughly $1.3 billion from protocols across 44 separate incidents, a 160% jump from the year before. The single most dangerous weapon in their arsenal was the flash loan, a borrowing mechanism designed for arbitrage that attackers repurposed to manipulate prices at near-zero cost.

This recap walks through the biggest DeFi exploits of 2021, dissects the attack vectors that made them possible, and extracts the security lessons that still apply today. Whether you are a developer auditing a new protocol or an investor trying to read a risk disclosure, understanding how 2021 broke is the fastest way to understand what DeFi security actually requires.

2021 DeFi hack timeline and total losses overview

The Big Picture: How Much Was Actually Lost?

Loss figures for 2021 vary widely depending on who is counting and what they include. CertiK, a smart-contract security firm, recorded $1.3 billion lost across 44 DeFi hacks in 2021, up from roughly $500 million the prior year. Chainalysis put the figure at $2.2 billion, but that number bundles in rug pulls and exit scams alongside pure protocol exploits. Elliptic's $10.5 billion estimate goes further still, folding in the indirect losses caused by token prices collapsing after each hack.

For this recap, the most useful number is the conservative one: about $1.3 to $1.5 billion in direct smart-contract and protocol exploits. That is the damage attackers actually pulled out of vaults, liquidity pools, and reward contracts. The average hack size ballooned from $8.3 million in 2020 to roughly $36 million in 2021, and the number of incidents more than tripled, from 16 to 55. The single largest event, the Poly Network hack, accounted for $611 million on its own — nearly half the year's total.

Two forces drove that explosion. First, the total value locked in DeFi grew roughly tenfold, giving attackers a far bigger pool to drain. Second, flash loans eliminated the capital barrier to launching an attack, a shift we will examine in detail shortly.

The Dominant Attack Vector: Flash Loan Attacks 2021

A flash loan is a borrowing primitive unique to DeFi. You can borrow any amount — tens of millions of dollars — with no collateral, provided you repay it in the same transaction. If repayment fails, the entire transaction reverts as if it never happened. Flash loans were invented for legitimate purposes: arbitrage between exchanges, collateral swaps, and self-liquidation of loans. But in 2021 they became the signature tool of DeFi attackers.

The attack pattern is remarkably consistent across incidents. An attacker flash-borrows a massive sum, uses it to distort the price of an asset on an automated market maker (AMM) pool, then interacts with a target protocol that relies on that manipulated price as its oracle. Because the protocol believes the distorted price, it misvalues collateral, over-issues rewards, or lets the attacker withdraw more than they deposited. The attacker repays the flash loan and walks away with the profit. The whole sequence executes in a single block — often under a second.

How a flash loan attack works step by step

Before flash loans, manipulating an AMM pool required the attacker to already own a large position. Flash loans reduced that capital requirement to the cost of gas. That is why the biggest DeFi hacks 2021 produced were dominated by this vector: PancakeBunny, Belt Finance, Spartan Protocol, and Cream Finance all fell to variations of the same playbook.

The deeper problem was not the flash loan itself — flash loans are a neutral tool. The problem was that many protocols read their prices directly from a single AMM pool's spot price. A spot price on an AMM is just a function of the ratio of two token reserves, so anyone who can temporarily move that ratio can set the price to whatever they want. Protocols that trusted that spot price as an oracle were trusting a number an attacker could print on demand.

The fix that emerged from 2021 is the Time-Weighted Average Price (TWAP) oracle, which averages prices over a window of time so a single transaction cannot move it. Some protocols also adopted Chainlink-style external oracles that pull prices from off-chain data sources. But in 2021, far too many protocols were still reading raw spot prices, and attackers knew it.

The Five Biggest DeFi Hacks of 2021

1. Poly Network — $611 Million (August 10)

The Poly Network hack remains the largest single DeFi exploit in history by gross amount. Poly Network was a cross-chain bridge connecting Ethereum, BNB Chain, and Polygon. The attacker exploited a design flaw in the EthCrossChainManager contract, which was responsible for verifying and relaying cross-chain messages. That manager contract had been granted the ability to call any method on any contract on the destination chain — an excessive privilege that violated the principle of least authority.

The attacker sent a crafted cross-chain transaction from Ontology that replaced the keeper list stored in EthCrossChainData, installing themselves as the sole authorized keeper. Once they controlled the keeper role, they could approve withdrawals from Poly Network's vaults on all three chains. They drained approximately $611 million in ETH, BNB, and USDC.

Poly Network cross-chain keeper replacement attack flow

What happened next was unprecedented: the attacker returned nearly all the funds within 15 days, claiming to be a white-hat hacker. Tether froze $33 million in USDT, and the attacker converted USDC to DAI via Curve to avoid similar freezing. The return does not diminish the severity of the vulnerability, though. The root cause — a contract with unrestricted call privileges — would have allowed the attacker to drain the bridge again at any time. The "return" was likely driven by the impossibility of laundering $611 million under intense public scrutiny rather than altruism.

2. Compound Finance — Up to $147 Million (September 29)

The Compound hack was not a flash loan attack or an oracle manipulation. It was a governance-approved bug. Proposal 062, which the community voted on and passed, contained a single-character logic error: a greater-than operator (>) that should have been greater-than-or-equal (>=). That one character caused the distributeSupplierComp function to over-distribute COMP tokens, the protocol's governance reward token.

Up to 280,000 COMP tokens — worth roughly $147 to $162 million at the time — became claimable. No user deposits or loans were at risk; only reward tokens were affected. But the damage was compounded by a structural problem: there was no admin control to pause the distribution. Any fix required a full seven-day governance cycle. Proposal 63 served as a temporary patch, and Proposal 64 delivered the permanent fix, but by then roughly $27 million had already been claimed in a single early transaction.

The lesson here is that governance itself is an attack surface. A buggy proposal can pass with unanimous votes if no one audits the diff carefully. Code review matters for governance proposals just as much as it does for smart-contract deployments.

3. Cream Finance — $130 Million (October 27)

Cream Finance was the repeat victim of 2021. The lending protocol was hacked three separate times: $37.5 million in February, $18.8 million in August, and then $130 million in October — a combined $186 million lost in a single year. The October attack was the most sophisticated of the three.

The attacker flash-borrowed $500 million in DAI from MakerDAO, then manipulated the price of yUSD through a multi-asset liquidity pool. By inflating the value of their collateral, they were able to borrow against it from Cream's v1 markets and drain $130 million. The attack chain spanned multiple protocols — AAVE, Yearn, and Curve were all used as stepping stones — demonstrating how DeFi composability creates cascading vulnerabilities. Each protocol in the chain was individually audited, but the combination created an exploitable path no single audit had considered.

Yearn Finance later salvaged $9.42 million from the aftermath, but the broader pattern was clear: a protocol with one vulnerability often has systemic issues, and a single patch does not address the root cause of poor security practices.

4. Badger DAO — $120 Million (December 2)

The Badger DAO hack was striking because the protocol's smart contracts were completely safe. The attack happened entirely on the Web2 layer. An attacker obtained a compromised API key for Badger's Cloudflare Workers configuration and used it to inject malicious JavaScript into the protocol's front-end interface. That script, which began appearing as early as November 10 and ran at random intervals to avoid detection, prompted users for unlimited token spend approvals.

When users interacted with what looked like the normal Badger interface, they were unknowingly approving spend allowances to the attacker's address. Roughly 500 wallets created malicious approvals, and the attacker drained approximately $120 million — 2,100 BTC and 151 ETH. About $9 million was later deemed recoverable. Badger froze its vaults by pausing transferFrom, which limited further damage.

This attack mirrors the supply-chain and front-end approach seen in later incidents. The smart contracts were immutable and audited, but the website users trusted to interact with them was not. Front-end security is DeFi security, even though it lives outside the blockchain.

5. PancakeBunny — $45 Million (May 19)

PancakeBunny was a yield optimization protocol on BNB Chain. The attacker took out eight flash loans totaling more than $700 million, manipulating the USDT/BNB and BUNNY/BNB prices on PancakeSwap. The protocol used an AMM-based oracle to measure the value of LP tokens for reward calculations, and that oracle read the manipulated spot price.

The attacker called getReward() and received 6.97 million newly minted BUNNY tokens — valued at roughly $1 billion at face value. They then dumped those tokens, crashing the BUNNY price from about $145 to $20, and walked away with approximately $45 million in profit. No vaults were directly compromised; this was a pure economic exploit. Three forked projects — AutoShark, Merlin Labs, and PancakeHunny — were subsequently exploited with the same technique, illustrating the fork bug inheritance problem: forking a protocol does not inherit its security, only a false sense of it.

Loss Breakdown by Attack Category

Categorizing the year's losses by attack type reveals where the real damage concentrated. Cross-chain bridge exploits, led by Poly Network, accounted for the largest single chunk at roughly $611 million. Flash loan and oracle manipulation attacks — PancakeBunny, Cream, Belt, Spartan, and others — collectively caused over $400 million in losses. Smart-contract logic bugs, including the Compound governance bug and Uranium Finance's misplaced zero, added another $230 million. Front-end and Web2 infrastructure attacks, primarily Badger DAO, accounted for about $120 million. Key and access control compromises, including EasyFi's stolen mnemonic, contributed roughly $180 million.

DeFi hack losses in 2021 broken down by attack category

The takeaway is that no single defense covers all of these categories. Smart-contract audits catch logic bugs but not front-end compromises. TWAP oracles stop flash loan manipulation but not governance errors. The defenses are layer-specific, and a protocol that secures one layer while neglecting another remains exposed.

The Three Layers of DeFi Security

Looking across the 2021 incidents, the attacks fall into three distinct layers, each requiring fundamentally different defenses.

Layer 1 — Smart-contract logic. Uranium Finance, Spartan Protocol, and Compound all fell to bugs in the contract code itself. The defense here is formal verification, thorough auditing, and test coverage that includes edge cases like boundary conditions (the > versus >= error).

Layer 2 — Economic and oracle design. PancakeBunny, Cream, Belt, and Vee Finance were exploited through price manipulation and incentive misalignment. The contracts executed exactly as written; the design was the flaw. Defenses include TWAP oracles, multiple independent price sources, and economic modeling that accounts for flash-loan-scale capital.

Layer 3 — Operational and Web2 infrastructure. EasyFi, Badger DAO, and Poly Network were all compromised through keys, API access, or privileged roles — not contract logic. Defenses include multi-signature wallets, timelocks on admin actions, API key rotation, and content security policies on front-ends.

Most post-mortems in 2021 treated all hacks as "smart-contract bugs," but that framing hides the real lesson: each layer needs its own security model, and a protocol is only as strong as its weakest layer.

Defense Checklist: Lessons That Still Apply

The security measures that would have prevented most of 2021's losses are well understood today, yet protocols still ship without them. Here is the checklist that 2021 wrote in blood.

Defense checklist — security lessons from 2021 DeFi hacks
  1. Use TWAP or multi-source oracles. Never read a raw AMM spot price as your sole price feed. Average over time, or pull from external oracle networks, so a single transaction cannot move the price.
  2. Timelocks and multi-sig for admin keys. No single key should be able to drain a protocol. Admin actions should require multiple signatures and a public delay period so the community can react.
  3. Formal verification of critical contracts. Audits catch common patterns, but formal verification proves mathematical properties — like "this function can never over-issue rewards" — that no test suite can fully cover.
  4. Front-end security. Content Security Policy headers, API key rotation, and subresource integrity on scripts all prevent the Badger DAO pattern of injecting malicious code into a trusted interface.
  5. Emergency pause and circuit breakers. When something goes wrong, the protocol should be able to halt within minutes, not wait seven days for a governance vote. Compound's inability to pause distribution in real time turned a manageable bug into a $147 million exposure.

Frequently Asked Questions

How much money was lost to DeFi hacks in 2021?

The most widely cited figure is approximately $1.3 billion in direct protocol exploits across 44 incidents, per CertiK's State of DeFi Security report. Broader estimates from Chainalysis reach $2.2 billion when including rug pulls, and Elliptic's $10.5 billion figure incorporates indirect losses from token price collapses following each hack.

What was the biggest DeFi hack in 2021?

The Poly Network hack on August 10, 2021, was the largest at $611 million. The attacker exploited excessive privileges in the EthCrossChainManager contract to replace the keeper list and drain vaults across Ethereum, BNB Chain, and Polygon. The funds were largely returned within 15 days, but the vulnerability was severe.

Why were flash loans used in so many 2021 attacks?

Flash loans let attackers borrow enormous sums with no collateral, as long as the loan is repaid within the same transaction. This removed the capital barrier to price manipulation — previously an attacker needed to already hold large positions to move AMM pool prices. With flash loans, the only cost was gas fees, making attacks accessible to anyone who could write a smart contract.

Was the Poly Network hacker ever caught?

The identity of the Poly Network attacker was never publicly confirmed. The attacker communicated with the team via on-chain messages and returned the funds, claiming to be a white-hat hacker. Security researchers noted the return was likely motivated by the difficulty of laundering $611 million under global scrutiny rather than altruism.

How could the 2021 DeFi hacks have been prevented?

Most incidents were preventable with measures that are now standard: TWAP or multi-source oracles instead of raw AMM spot prices, multi-sig and timelocks on admin keys, formal verification of critical contract functions, front-end security controls, and emergency pause mechanisms. The Compound governance bug specifically highlights the need for rigorous code review of governance proposals before they go to a vote.

Did any DeFi protocol get hacked more than once in 2021?

Yes. Cream Finance was hacked three times in 2021 — losing $37.5 million in February, $18.8 million in August, and $130 million in October, for a combined $186 million. The pattern suggests that protocols with one vulnerability often have systemic security gaps that a single patch does not resolve.


Understanding the DeFi hacks of 2021 is not just an exercise in history. The attack vectors that defined that year — flash loan manipulation, oracle dependence, governance flaws, and front-end compromise — remain the primary threats to DeFi protocols today. The defenses are known. The question is whether protocols choose to implement them before or after they appear in a post-mortem.

Tags:

defi hacks 2021defi exploits 2021poly network hackflash loan attacks 2021defi security incidents 2021biggest defi hacks 2021