---
title: "Governance takeover"
url: https://dontgetrekt.today/dev/governance-attack
section: "Who can call it?"
---

# Governance takeover

An attacker gets enough votes, often with borrowed tokens, and passes a proposal that sends the treasury to them. With no timelock, nobody can stop it.

## How the attack works

1. Voting power is the token balance at the time of the vote, not at an earlier block.
2. The attacker takes a flash loan of the governance token, or buys it cheaply in a low-liquidity market.
3. The attacker creates and votes on a proposal that transfers the treasury or upgrades a contract.
4. With no timelock and no quorum guard, the proposal executes before anyone reacts.

## Vulnerable code

```solidity
function vote(uint256 id) external {
    votes[id] += token.balanceOf(msg.sender);  // flash-loaned balance counts
}

function execute(uint256 id) external {
    require(votes[id] > quorum);
    proposals[id].target.call(proposals[id].data); // runs at once
}
```

## Fixed code

```solidity
// OpenZeppelin Governor + ERC20Votes + TimelockController
function _getVotes(address a, uint256 timepoint, bytes memory)
    internal view override returns (uint256)
{
    return token.getPastVotes(a, timepoint);  // snapshot before the proposal
}
// votingDelay > 0, votingPeriod of days, and a timelock of 2+ days on execution.
```

## Review checklist

- Count votes from a snapshot taken before the proposal (ERC20Votes `getPastVotes`).
- Use a voting delay, a voting period of several days and a timelock on execution.
- Give a guardian or security council the power to cancel a malicious proposal.
- Watch new proposals with a bot. A proposal that moves the treasury must alert the team.

## How to test for it

- In a test, flash-mint governance tokens and vote in the same block. The vote must count zero.

## Real exploits (14)

- 2022-04-17 Beanstalk ($181.0M): Beanstalk lost about $181M when an attacker used flash-loaned funds to gain a governance supermajority and instantly executed a malicious emergency proposal (BIP-18) that sent all protocol assets to them. [rekt.news](https://rekt.news/beanstalk-rekt) [PoC](https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2022-04/Beanstalk_exp.sol)
- 2024-07-28 Compound Finance ($24.0M): Whale Humpy pushed Compound Proposal 289 through a low-turnout vote to move 499,000 COMP (about $24M) into a vault controlled by the Golden Boys multisig; the proposal was cancelled before funds were lost. [rekt.news](https://rekt.news/the-humpy-dance)
- 2026-07-06 BonkDAO ($19.3M): BonkDAO lost about $19.3M of BONK treasury when an attacker spent $4.4M buying enough tokens to pass a malicious proposal under a weak governance config. [rekt.news](https://rekt.news/bonkdao-rekt)
- 2024-03-23 Curio ($16.0M): Curio lost about $16M on Ethereum when an attacker used a small amount of CGT to gain voting power in its MakerDAO-style governance and minted huge amounts of CGT. [rekt.news](https://rekt.news/curio-rekt)
- 2026-08-23 Term Labs (Term Finance Meta Vaults) ($8.5M): Term Labs lost about $8.5M from its Meta Vaults when an attacker bought a near-total share of thin voting supply and passed a proposal that disabled the timelock and drained the vaults. [rekt.news](https://rekt.news/term-labs-rekt) [PoC](https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2026-08/TermFinance_exp.sol)
- 2026-10-24 X100 Senate ($4.7M): X100 Senate treasury lost about 4.75M USDT when an attacker used flash-loaned funds to take 2 of 3 senate seats and pass a treasury swap in one transaction, because the governance has no snapshot and no timelock. [PoC](https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2026-10/X100Senate_exp.sol)
- 2023-06-10 Atlantis Loans ($2.5M): Abandoned BSC lender Atlantis Loans lost about $2.5M after an attacker passed a malicious governance proposal that took control of its token contracts. [rekt.news](https://rekt.news/atlantis-loans-rekt)
- 2023-05-20 Tornado Cash Governance ($750K): Tornado Cash governance was taken over via a malicious metamorphic proposal contract (CREATE/CREATE2 plus selfDestruct) that granted the attacker 1.2M votes, and the attacker made about $750k by selling TORN. [rekt.news](https://rekt.news/tornado-gov-rekt)
- 2022-02-14 Build Finance ($470K): Build Finance lost about $470k when an attacker passed a malicious proposal in its DAO governance, which approved the attacker to drain the governance contract's BUILD tokens. [PoC](https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2022-02/BuildF_exp.sol)
- 2026-09-12 Yam Finance ($121K): Yam Finance lost about $121K (48 WETH + 763 UMA) when an attacker bought ~3.3% of YAM and passed a proposal in a dormant DAO, taking over the Timelock and draining legacy UMA farming contracts. [PoC](https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2026-09/YamFinance_exp.sol)

## References

- [OpenZeppelin: Governor](https://docs.openzeppelin.com/contracts/5.x/governance)
- [OpenZeppelin: ERC20Votes](https://docs.openzeppelin.com/contracts/5.x/api/token/erc20#ERC20Votes)
