Skip to content

Governance Voting Weight from Spot balanceOf

SAFE-0136 Governance Checked automatically by the scanner
1

What goes wrong

Voting power is read from a token's current balanceOf (or totalSupply) at execution time instead of a historical snapshot/checkpoint. An attacker flash-borrows the governance token, votes with the borrowed weight, and returns it in the same transaction.

2

The vulnerable pattern

proof of concept — how it is exploited
// 1. flashloan 1M GOV
// 2. governance.castVote(proposalId, FOR)  // weight = balanceOf now = 1M
// 3. repay flashloan  (all in one tx) -> proposal passes with borrowed votes
3

How to fix it

the pattern that is safe
// snapshot voting power at proposal creation (ERC20Votes / getPastVotes)
uint256 weight = token.getPastVotes(voter, proposal.startBlock);
Beanstalk hack. Use snapshot/checkpoint voting weight.
4

Where this has happened

Incidents this entry cites by name:

Check your own contract for this

The SaferICO scanner runs 201 detectors over your Solidity source, SAFE-0136 among them. Paste an address or the source itself — a small per-scan fee, shown before you sign, or unlimited on any plan.

Run the scanner See how it is attacked Read the docs