Immunefi
Published in

Immunefi

Hack Analysis: Beanstalk Governance Attack, April 2022

Introduction

Background

Root Cause

Snippet 1: emergencyCommit function on GovernanceFacet
Snippet 2: commit function on GovernanceFacet

Proof of Concept

The Attack

Snippet 3: The start of our attack contract
Snippet 4: Swap ETH for BEAN and deposit it in Beanstalk
Snippet 5: Encode malicious proposal and submit it
Snippet 6: Approve various spendings
Snippet 7: Flashloan funds from Aave
Snippet 8: Convert funds and execute the proposal
Snippet 9: Swap BEAN3CRV-f back to stablecoins
Snippet 10: The high level code of the hack transaction
Snippet 11: Foundry unit test with 1 day warp between transactions

Conclusion

Snippet 12: All code

--

--

Immunefi is the premier bug bounty platform for smart contracts and DeFi projects, where security researchers review code, disclose vulnerabilities, get paid, and make crypto safer. Immunefi removes security risk through bug bounties and comprehensive security services.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Immunefi

Immunefi is the premier bug bounty platform for smart contracts, where hackers review code, disclose vulnerabilities, get paid, and make crypto safer.