Users can get unlimited votes
The _burn function in VotingEscrow.sol does not move token delegates back to address(0), so after burning an NFT the delegation remains with the previous owner. An attacker can repeatedly deposit, lock, transfer, and burn tokens to accumulate voting power, gaining control over governance and undeserved rewards.
Submitted by IllIllI, also found by kenzo
Users can get unlimited votes which leads to them:
- gaining control over governance
- getting undeserved rewards
- having their pools favored due to gauge values
Proof of Concept
_mint() calls _moveTokenDelegates() to set up delegation…
File: contracts/contracts/VotingEscrow.sol #1
462 function _mint(address _to, uint _tokenId) internal returns (bool) {
463 // Throws if `_to` is zero address
464 assert(_to != address(0));
465 // TODO add delegates
466 // checkpoint for gov
467 _moveTokenDelegates(address(0), delegates(_to), _tokenId);
and _transferFrom() calls _moveTokenDelegates() to transfer delegates…
File: contracts/contracts/VotingEscrow.sol #2
301 function _transferFrom(
302 address _from,
303 address _to,
304 uint _tokenId,
305 address _sender
306 ) internal {
307 require(attachments[_tokenId] == 0 && !voted[_tokenId], "attached");
308 // Check requirements
309 require(_isApprovedOrOwner(_sender, _tokenId));
310 // Clear approval. Throws if `_from` is not the current owner
311 _clearApproval(_from, _tokenId);
312 // Remove NFT. Throws if `_tokenId` is not a valid NFT
313 _removeTokenFrom(_from, _tokenId);
314 // TODO delegates
315 // auto re-delegate
316 _moveTokenDelegates(delegates(_from), delegates(_to), _tokenId);
but _burn() does not transfer them back to address(0)
File: contracts/contracts/VotingEscrow.sol #3
517 function _burn(uint _tokenId) internal {
518 require(_isApprovedOrOwner(msg.sender, _tokenId), "caller is not owner nor approved");
519
520 address owner = ownerOf(_tokenId);
521
522 // Clear approval
523 approve(address(0), _tokenId);
524 // TODO add delegates
525 // Remove token
526 _removeTokenFrom(msg.sender, _tokenId);
527 emit Transfer(owner, address(0), _tokenId);
528 }
A user can deposit a token, lock it, wait for the lock to expire, transfer the token to another address, and repeat. During each iteration, a new NFT is minted and checkpointed. Calls to getPastVotes() will show the wrong values, since it will think the account still holds the delegation of the burnt NFT. Bribes and gauges also look at the checkpoints and will also have the wrong information
Recommended Mitigation Steps
Call _moveTokenDelegates(owner,address(0)) in _burn()
pooltypes (Velodrome) confirmed and commented:
Nice catch! We intended to fix this issue (see TODO), included in our mainnet deploy. Thanks for surfacing.
Alex the Entreprenerd (judge) commented:
The warden has shown an exploit that, leveraging the
_moveTokenDelegatesfunction, which is not present inburncan allow any attacker to inflate their votes.The sponsor has confirmed and they indeed have mitigated the issue in their deployed code.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Impact
An attacker could gain control over governance, receive undeserved rewards, and have their pools favored due to inflated gauge values.
What the attacker needed
A token to deposit and lock; ability to transfer tokens; wait for lock expiry
The fix
Call _moveTokenDelegates(owner, address(0)) inside _burn() to clear the delegation when a token is burned.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
This is a smart contract bug where burning a token (destroying it) does not remove the voting power it gave to its owner. So someone can create many tokens, burn them, and keep the votes, letting them unfairly influence decisions and earn extra rewards.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.