# Hack Analysis: Beanstalk Governance Attack, April 2022

Beanstalk's emergencyCommit let a flashloan-funded supermajority vote and execute a malicious BIP in one transaction, draining ~$181M.

- Payout: Real-world hack
- Severity: critical
- Program: Beanstalk
- Credited: Immunefi
- Disclosed: 2023-01-09
- Write-up quality: 9/10
- Original: https://immunefi.com/blog/bug-fix-reviews/hack-analysis-beanstalk-governance-attack-april-2022/
- Library page: https://bugbountylibrary.com/r/blog%3Aimmunefi-com-blog-bug-fix-reviews-hack-analysis-beanstalk-governance-attack-april-2022
- Tags: domain:web3 impact:funds-loss kind:incident platform:immunefi sev:critical tech:evm tech:solidity technique:chained technique:source-review vuln:business-logic vuln:flash-loan vuln:governance

**Target:** GovernanceFacet emergencyCommit / Diamond proxy (EIP-2535) on Ethereum
**Root cause:** emergencyCommit executes an active proposal with >=2/3 voting power in the same transaction votes are counted, and _execute delegatecalls attacker-supplied _init/_calldata, so flashloaned deposits grant instant supermajority and arbitrary code execution in protocol context.
**Steps:**
1. Swap ~70 ETH for BEAN via Uniswap V2 router and depositBeans to meet proposal threshold.
2. Call propose([], attackerContract, abi.encodeWithSelector(getProposalProfit.selector), 3) to create Bip18; wait 1 day.
3. Flashloan 350M DAI + 500M USDC + 150M USDT from Aave.
4. add_liquidity into Curve 3pool to get 3Crv; add_liquidity into BEAN3CRV-f pool to get BEAN3CRV-f.
5. deposit(crvbean, balance) into Beanstalk to inflate voting power.
6. Call emergencyCommit(18); _execute delegatecalls Attacker.getProposalProfit which transfers all BEAN3CRV-f to attacker.
7. remove_liquidity_one_coin from BEAN3CRV-f, remove_liquidity_imbalance from 3pool to repay Aave principal+premium, convert remainder to USDC profit.
**How found:** Code review of GovernanceFacet: noticed emergencyCommit lacks a post-voting delay and executes via delegatecall to proposal-supplied _init/_calldata, unlike commit which requires an ended proposal; realized flashloaned deposits could satisfy the 2/3 threshold and execute in one tx.
**Exploitation:** Attacker flashloaned >$1B stablecoins from Aave/Uniswap/SushiSwap, converted to BEAN3CRV-f, deposited into Beanstalk to reach 2/3 voting power, then called emergencyCommit on a pre-staged malicious BIP whose _init delegatecall transferred protocol BEAN3CRV-f to the attacker; loan repaid within the same transaction, netting ~$77M in non-Bean assets.
**Escalation:** Chained flashloans across Aave, Uniswap and SushiSwap to reach >$1B, then routed through Curve 3pool and BEAN3CRV-f to convert stablecoins into governance voting power, all atomically.
**Insight:** When auditing DAO governance, check whether vote-weight snapshot and execution can occur in the same block/transaction; any execute path that delegatecalls proposal-supplied targets turns flashloanable voting power into arbitrary code execution.
