Securityadvancedarticle30 min read

Beanstalk Farms Hack: $182M Flash Loan Governance Takeover | VCC

On April 17, 2022, the beanstalk farms hack rewrote the playbook for DeFi exploits. An attacker did not break cryptography, did not find a reentrancy bug, and did not exploit a price oracle. Instead, they used a flash loan to buy governance power, proposed a malicious upgrade, and executed i

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

On April 17, 2022, the beanstalk farms hack rewrote the playbook for DeFi exploits. An attacker did not break cryptography, did not find a reentrancy bug, and did not exploit a price oracle. Instead, they used a flash loan to buy governance power, proposed a malicious upgrade, and executed it instantly via an emergencyCommit function that bypassed the standard 24-hour timelock. The result: $182 million drained from Beanstalk Farms in minutes — the first major flash loan governance attack in DeFi history.


TL;DR

  • What happened: Attacker used $1B flash loan to acquire Stalk (governance tokens), proposed malicious BIP-18, executed via emergencyCommit (bypassing 24h timelock), drained $182M
  • When: April 17, 2022 (exploit executed in ~20 minutes)
  • Root cause: BIP-18 emergencyCommit allowed instant execution with 2/3 Stalk majority; no timelock, no flash loan resistance on Stalk
  • Attribution: Unknown attacker (sophisticated, deep Ethereum/Beanstalk knowledge); no nation-state link
  • Impact: ~$182M drained across Bean, Uniswap v2 pools; protocol paused; Halborn audit commissioned
  • Fix: Governance redesign — timelocks on upgrades, Stalk vesting, flash loan resistance, multi-sig on upgrades

The Protocol: Beanstalk — Credit-Based Stablecoin

Before the exploit, Beanstalk was a credit-based stablecoin protocol on Ethereum. Unlike overcollateralized stablecoins (DAI, USDC), Beanstalk maintained its $1 peg through credit dynamics — users lent BEAN to the protocol (Silo), earning Stalk (governance tokens) and Seeds (yield).

Key components:

  • Bean: Stablecoin targeting $1 peg
  • Silo: Staking module — deposit BEAN/LP tokens, earn Stalk (governance) + Seeds (yield)
  • Field: Lending module — lend BEAN to protocol, earn Pods (future BEAN claim)
  • Barn: Fundraising module — raise capital during peg deviations
  • Diamond (Proxy): Upgradeable contract — facets for Silo, Field, Barn, Governance
  • Governance (BIPs): Bean Improvement Proposals — Stalk holders vote on upgrades

Stalk (governance token): Earned by depositing BEAN/LP in Silo. 1 Stalk = 1 vote. No lockup, no vesting, instant liquidity — this was the critical flaw.


Diagram - Beanstalk Protocol Architecture: Diamond Proxy -> Facets (Silo, Field, Barn) -> Governance; emergencyCommit = vulnerability

The Vulnerability: emergencyCommit in BIP-18

Beanstalk governance used Bean Improvement Proposals (BIPs). Standard BIPs had a 24-hour timelock after reaching quorum. But BIP-18 introduced emergencyCommit:

`solidity // Simplified BIP-18 emergencyCommit (conceptual) function emergencyCommit(uint256 bipId) external { require(stalkBalance[msg.sender] >= totalStalk * 2 / 3, "Need 2/3 Stalk"); // NO TIMELOCK! _executeBip(bipId); // IMMEDIATE EXECUTION } `

The bug: emergencyCommit allowed instant execution with 2/3 Stalk majority — no 24-hour timelock. The assumption: "no one can get 2/3 Stalk." Flash loans broke this assumption.


The Attack: Flash Loan Governance Takeover

April 17, 2022, ~18:00 UTC — Attacker borrows ~$1B flash loan from Aave v2: 24,830 ETH + 35M BEAN.

18:05 UTC — Attacker swaps ETH for BEAN on Uniswap, deposits BEAN into Silo → receives massive Stalk (governance power).

18:10 UTC — Attacker proposes BIP-18 with malicious upgrade contract (drains all protocol funds).

18:15 UTC — Attacker calls emergencyCommit on BIP-18. 2/3 Stalk threshold met instantly (attacker controls majority via flash loan). No timelock — immediate execution.

18:20 UTC — BIP-18 executes: upgrades Diamond facet to malicious contract → drains ~$182M from Bean, Uniswap v2 BEAN/ETH, BEAN/3CRV pools.

18:25 UTC — Attacker repays Aave flash loan (+ fees), keeps ~$80M profit.


The Numbers: $182M Drained in Minutes

Diagram - Beanstalk Hack Timeline: Apr 17, 2022 exploit to drain in 20 minutes
MetricValue
Total Drained~$182 million
Attacker Profit~$80 million
Protocol Loss~$102 million
Chains AffectedEthereum Mainnet
Time Window~20 minutes
Flash Loan Size~$1B (24,830 ETH + 35M BEAN)
Stalk Acquired>2/3 total supply (via flash loan)
Attackers1 (single actor)

This was a "governance takeover" — not a bug in math or cryptography, but a flaw in governance design. The attacker used the protocol's own governance mechanism against it.


Root Cause Deep Dive: The emergencyCommit Flaw

The Governance Design

Beanstalk used Stalk (earned by staking BEAN) as governance power. 1 Stalk = 1 vote. BIPs required:

  1. Proposal submitted
  2. 24-hour voting period
  3. Quorum + majority → queued for 24h timelock
  4. Execution after timelock

BIP-18 added emergencyCommit for "urgent" fixes. It allowed instant execution with 2/3 Stalk majority — no timelock.

The Missing Checks

`solidity // Missing in emergencyCommit: require(block.timestamp >= proposal.timestamp + 24 hours, "Timelock required"); require(stalkNotFromFlashLoan(msg.sender), "Flash loan Stalk not allowed"); `

Neither check existed. The protocol assumed 2/3 Stalk was impossible to acquire — flash loans proved this wrong.

Exploit Construction

  1. Borrow $1B from Aave (24,830 ETH + 35M BEAN)
  2. Swap ETH → BEAN on Uniswap (slippage managed)
  3. Deposit 35M BEAN into Silo → receive massive Stalk (governance tokens)
  4. Propose BIP-18 with malicious Diamond facet upgrade
  5. Call emergencyCommit — 2/3 Stalk threshold met → instant execution
  6. Malicious facet drains all protocol funds
  7. Repay Aave flash loan, keep ~$80M profit
Diagram - Flash Loan Governance Attack Flow

The Flash Loan Governance Playbook

This was the first major flash loan governance attack. The playbook:

  1. Identify governance token with no lockup (Stalk from Silo)
  2. Flash loan to acquire governance power (borrow assets → deposit → mint governance tokens)
  3. Propose malicious upgrade (drain funds, change parameters)
  4. Use emergency/shortcut path (bypass timelock)
  5. Execute, drain, repay flash loan, profit

Why it worked on Beanstalk:

  • Stalk had no lockup, no vesting, instant minting from Silo deposits
  • emergencyCommit had no timelock — instant execution
  • No flash loan resistance on Stalk minting
  • No anomaly detection on governance power accumulation

The Aftermath: Protocol Paused, Audit Commissioned

April 17, 2022, ~18:25 UTC — Attack complete. Beanstalk team pauses protocol (emergency pause).

April 18 — Community calls for recovery. Halborn engaged for full audit.

April 2022 - Present — Beanstalk v2 development: redesigned governance with timelocks, Stalk vesting, flash loan resistance, multi-sig on upgrades.

Losses: ~$182M total drained. No user funds recovered (protocol paused, no insurance). Attacker kept ~$80M profit.


Diagram - Attack Flow & Fund Flow

Lessons: What Would Have Prevented This


1. Governance timelocks are non-negotiable. No "emergency" path should bypass timelock. If emergency upgrades needed, use multi-sig + 48h delay minimum.

2. Governance tokens need lockup/vesting. Stalk should have had a vesting period (e.g., 30 days) or lockup before voting power activates. Flash loan Stalk = instant power = broken.

3. Flash loan resistance on governance tokens. Stalk should not be mintable from flash-loaned assets. Silo should check block.timestamp > depositTimestamp + lockupPeriod.

4. Diamond/proxy upgrades need multi-sig + timelock. Facet upgrades are the most powerful operation — they should require multi-sig + 48h timelock, not simple majority vote.

5. Anomaly detection on governance power. Circuit breaker that pauses governance when >X% of voting power acquired in Y blocks.

6. Formal verification of governance code. The emergencyCommit function was ~20 lines of critical code. It should have been formally verified (Certora, Coq).


Diagram - Defense Checklist 5 Lessons

Frequently Asked Questions


How much was stolen in the Beanstalk hack? ~$182 million drained from protocol (Bean, Uniswap v2 pools). Attacker profit ~$80M after flash loan repayment.

Was this a smart contract bug? Not a traditional bug (reentrancy, overflow). It was a governance design flaw: emergencyCommit allowed instant execution with flash-loaned governance power. The code worked as written — the design was flawed.

Who hacked Beanstalk? Unknown. The attacker demonstrated deep Ethereum/Beanstalk knowledge (flash loan mechanics, BIP-18, Diamond proxy). No public nation-state attribution.

Did users lose money? Yes — users with funds in Beanstalk (Bean holders, Silo depositors, Field lenders) lost ~$182M. Protocol paused; no recovery yet.

Why could the attacker get 2/3 Stalk so easily? Stalk was minted instantly by depositing BEAN into Silo. The attacker flash-loaned BEAN, deposited it, got instant Stalk majority. No lockup, no vesting, no delay.

What is emergencyCommit and why was it dangerous? emergencyCommit allowed instant BIP execution with 2/3 Stalk, bypassing the 24h timelock. It assumed 2/3 Stalk was unobtainable — flash loans broke this.

Has Beanstalk fixed the governance? Yes. Beanstalk v2 redesign includes: governance timelocks (48h+), Stalk vesting (30 days), flash loan resistance (deposit lockup), multi-sig on upgrades, anomaly detection.

What bridges/protocols are vulnerable to similar attacks? Any protocol where: governance token has no lockup, emergency upgrade path exists, flash loan can acquire governance power, upgrade power is not multi-sig protected.


Technical Appendix: Correct Governance Flow with Safeguards

For developers, here's the correct governance flow that Beanstalk missed:

`

  1. Propose BIP (upgrade, parameter change, etc.)
  2. Voting period (min 48h)
  3. CHECK: quorum reached + majority
  4. CHECK: proposer Stalk not from flash loan (lockup > 30 days)
  5. Queue for execution (timelock 48h+)
  6. TIMELOCK: wait 48h
  7. CHECK: no anomaly detected (TVL outflow, governance power spike)
  8. Execute (multi-sig required for facet upgrades)
  9. Post-execution: verify state, monitor TVL

`

The missing checks at steps 4, 6, 7, and 8 cost $182M.


This article is part of the DeFi Hacks series. For more deep-dives on governance exploits, see our analyses of the Compound Finance hack, Cream Finance flash loan, and Mango Markets oracle manipulation.

Tags:

beanstalk farms hackbeanstalk 182 millionflash loan governance attackdao governance exploitbeanstalk hack analysis