ve-lock-governance
Skill36 starsChanged 5 months agoMITView on GitHub
Detect vote-escrow (ve) governance manipulation — Curve veCRV, Velodrome/Aerodrome veNFT, Balancer veBAL, and gauge/bribe markets. Activate whenever code reads voting power from a lock balance, computes gauge weights, distributes bribes/incentives, snapshots votes, or lets locks be created/extended/merged/split/transferred — especially when vote weight is read live rather than at proposal-creation block.
In this repository44 other files it gives its agents.
- access-controlSkill
- approval-issuesSkill
- caching-and-incrementalSkill
- centralization-riskSkill
- confidence-scoringSkill
- cosmwasmSkill
- cross-chain-messagingSkill
- cross-contract-stateSkill
- delegatecall-risksSkill
- diamond-eip2535Skill
- dos-vectorsSkill
- erc1271-contract-signaturesSkill
- erc4337-account-abstractionSkill
- erc4626-inflationSkill
- false-positive-feedback-loopSkill
- fee-on-transferSkill
- flash-loan-attacksSkill
- initializationSkill
- inline-assemblySkill
- integer-issuesSkill
- intents-erc7683Skill
- known-good-comparisonSkill
- liquidation-cascadeSkill
- mev-frontrunningSkill
- mev-pbsSkill
- multi-pass-self-critiqueSkill
- oracle-manipulationSkill
- oracle-redundancySkill
- permit2-patternsSkill
- pragma-and-addressesSkill
- progress-and-streamingSkill
- reentrancySkill
- restaking-eigenlayerSkill
- selfdestruct-eip6780Skill
- signature-malleabilitySkill
- signature-replaySkill
- solana-anchorSkill
- storage-layoutSkill
- stylus-rustSkill
- token-compatibilitySkill
- tx-context-misuseSkill
- unchecked-callsSkill
- vyper-specificSkill
- zk-verifier-bugsSkill
The file
Files
Vote-escrow lock governance detection
When this applies
Trigger on any of:
- Locking tokens for time-decayed voting power (
create_lock,increase_amount,increase_unlock_time) - Reading
balanceOf/balanceOfNFT/votingPowerfrom a ve contract during a vote or weight calc - Gauge-weight voting, gauge controller
vote_for_gauge_weights, emission direction - Bribe / incentive markets (Votium, Hidden Hand, Velodrome
BribeVotingReward) - veNFT transfer,
merge,split,withdraw,delegate - Proposal systems that read voting power without a snapshot block
Detection patterns
Live vote weight, no snapshot (HIGH / CRITICAL)
function castVote(uint256 proposalId, bool support) external {
uint256 weight = ve.balanceOf(msg.sender); // ← read NOW, not at proposal start
proposals[proposalId].votes[support] += weight;
}Signal: voting power read at vote time enables flash-lock: borrow, lock, vote, then exit if withdraw allowed same block, or vote with freshly minted power. Snapshot at proposal-creation block (getPastVotes).
Gauge-weight manipulation (HIGH)
Last-block vote stuffing before the weekly checkpoint redirects emissions. If gauge weights are read at the instant of checkpoint_gauge with no time-weighting, a single-block max vote captures a full epoch of emissions (Curve gauge-war griefing class).
Signal: emission direction determined by instantaneous weight, not a bias-weighted moving average.
veNFT merge / split double-vote (HIGH)
function merge(uint256 from, uint256 to) external { ... } // does it clear `voted[from]`?Signal: Velodrome-class finding — split/merge not resetting the per-NFT voted flag or per-epoch vote accounting lets one underlying balance vote twice in an epoch. Also check transferFrom mid-epoch carrying voting power to a non-voted recipient.
Lock-decay / max-lock precision (MEDIUM)
Linear-decay bias - slope * (t - t0) underflowing past expiry, or assuming MAXTIME lock when unlock_time was rounded down to the week. Off-by-one-week rounding inflates or deflates power at epoch boundaries.
Bribe-market timing (MEDIUM)
Claiming bribes for an epoch you voted in, then re-voting next epoch with the same balance, or claiming on a transferred veNFT — verify bribe accounting is keyed to (tokenId, epoch) and frozen at the vote.
Severity rubric
| Pattern | Severity | Notes |
| Flash-lock vote with same-block exit | Critical | Direct governance capture |
| Live (un-snapshotted) vote weight | High | Borrowed-power voting |
| merge/split/transfer double-vote | High | Velodrome-class veNFT bug |
| Last-block gauge stuffing | High | Emission theft per epoch |
| Decay/rounding precision at week boundary | Medium | Bounded mis-weighting |
| Bribe claim re-use across epochs | Medium | Incentive leakage |
Remediation patterns
- Snapshot voting power at proposal-creation block via
ERC20Votes.getPastVotes/ checkpoint history — neverbalanceOfat vote time. - Time-bias gauge weights (Curve's
points_weightslope/bias with future-epoch bias) so a single block cannot dominate an epoch. - Reset per-NFT vote state on
merge/split/transferand forbid transfer of a veNFT that has voted in the current epoch (Velodromevotedlock). - Key bribe accounting to (tokenId, epoch) and freeze the balance used at vote time.
- Disallow withdraw before unlock and round
unlock_timeconsistently (floor to week) everywhere.
False-positive notes
- Snapshot-based systems (
ERC20Votes, CompoundgetPriorVotes) that already pin to a past block are safe — don't flag livebalanceOfused only for display. - A non-transferable, non-mergeable ve lock with no early withdraw materially narrows the surface; note but don't escalate.
Related
- [[flash-loan-attacks]] — flash-borrowed capital funds the flash-lock vote
- [[signature-replay]] — delegated/gasless vote signatures need nonce + epoch binding
- [[centralization-risk]] — gauge controller / emission admin keys
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

