Skip to content
Business logic Audit finding Intermediate

Griefing an account from getting votes delegate

The VotingEscrow contract limits the number of delegates a destination address can have to 1024. An attacker can create many small locks and delegate each to a victim, filling the limit so that legitimate users cannot delegate votes to that victim.

Shahen Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

30704 - [SC - Medium] Griefing an account from getting votes delegate...

Submitted on May 5th 2024 at 09:56:52 UTC by @Shahen for Boost | Alchemix

Report ID: #30704

Report type: Smart Contract

Report severity: Medium

Target: https://github.com/alchemix-finance/alchemix-v2-dao/blob/main/src/VotingEscrow.sol

Impacts:

  • Griefing (e.g. no profit motive for an attacker, but damage to the users or the protocol)

Description

Brief/Intro

Assume there's three addresse's (Bob,Alex and Maya). Maya got 1e18 of bpt tokens which she locked in VotingEscrow contract and received a tokenId of the created veALCX. Maya is hoping to delegate her votes to Alex now. But Bob is a malicious actor, He locks 0.0000001 ether of bpt in the VotingEscrow contract 1024 times.Therefore bob recieves 1024 tokenId's for a total of 0.0001024 ether of bpt locked.

Now bob delegates his votes from each of his tokenId's to Alex,So alex got votes from 1024 tokenId's. So what bob have done here is a grief, If you look at line 1110 under _moveAllDelegates() internal function. There's a require condition that checks the total number of delegates the destioation(dst) has and if its <= MAX_DELEGATES which is 1024. So since bob delegated votes from 1024 tokenId's to Alex, When Maya tries to delegate votes from her tokenId that she received from locking 1e18, The delegation will revert as the require statement fails. So this is how bob griefed Alex from getting votes delegated to him. Basically bob used his 0.0001024*10**18 bpt total locked deposit to grief Alex, But bob can use any amount less than 0.0001024*10**18 bpt,I just used that in the test. Ofcourse Alex would be able to delegate and clear out the unworthy votes sent by bob,But Bob can do the griefing again.

Please refer to the below Foundry POC demonstrating the explained scenario.

Vulnerability Details

Same as the Brief/Intro

Impact Details

A malicious actor can grief another address from getting votes delegated to it by maxing out the MAX_DELEGATES limit.

References

https://github.com/alchemix-finance/alchemix-v2-dao/blob/main/src/VotingEscrow.sol

Proof of Concept

Paste the below testfile under src/test and run.

// SPDX-License-Identifier: GPL-3
pragma solidity ^0.8.15;

import "./BaseTest.sol";

contract VotingEscrowGriefTest is BaseTest {
    uint256 internal constant THREE_WEEKS = 3 weeks;
    address bob = address(0x1); // Griefer
    address alex = address(0x2); // victim
    address maya = address(0x3);

    function setUp() public {
        setupContracts(block.timestamp);
    }

    
   
    
    function test_delegate_grief() public {

// 1.) Bob has 0.0001024 bpt.

        hevm.startPrank(bob);
        deal(bpt,bob,0.0001024 ether);
        IERC20(bpt).approve(address(veALCX), 0.0001024 ether);
        
// 2.) Bob aquires multiple tokenId's by locking 0.0000001 bpt * 1024 times, So in total bob got <1024 tokenId's. 
// 3.) Since bob now has greater than or equal to 1024 tokenId's,Bob delegates votes from all of his tokenId's to Alex.    
        
        
        for (uint i = 0; i < 1024; i++) {
            uint256 tokenId = veALCX.createLock(0.0000001 ether, THREE_WEEKS, false);
            assertEq(veALCX.ownerOf(tokenId), bob);
            veALCX.delegate(alex);

        }

        
    

        hevm.stopPrank();
// 4.) Now Maya who locked 1e18 worth of bpt tries to delegate vote to alex.
// 5.) But the delegation revert as there's a limit of 1024 max delegates per dst account.
// 6.) Basically Bob delegated votes to Alex from 1024 different tokenId's, And since theres a max delagate limit of 1024,No one would be able to delegate votes to alex.
// 7.) This way Bob griefed Alex by getting votes delegated to him.
        hevm.startPrank(maya);
        deal(bpt,maya,1e18);
        IERC20(bpt).approve(address(veALCX), 1e18);
        uint256 tokenId = veALCX.createLock(1e18, THREE_WEEKS, false);
        assertEq(veALCX.ownerOf(tokenId), maya);
        hevm.expectRevert(abi.encodePacked("dst would have too many tokenIds"));
        veALCX.delegate(alex);
        hevm.stopPrank();
        

        
    }

    
}

The original report as published on Immunefi, by Shahen. Images and videos are our own copies; raw HTML is shown as text. View it on Immunefi.

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

Root cause

Likely the contract enforces a hard cap on the number of delegates per destination without any cost or rate limit, allowing an attacker to fill the cap with many cheap locks.

Impact

A malicious actor can prevent any address from receiving new vote delegations by filling its delegate limit, though the victim can clear the unwanted delegations and the attacker can repeat the griefing.

What the attacker needed

Attacker has a small amount of tokens; victim address is known

The fix

The contract should be changed to avoid a hard cap that can be filled cheaply, for example by allowing the destination to remove delegates or by making the cap costly to reach.

How it was found

  1. The attacker locks a very small amount of tokens many times to create 1024 token IDs.
  2. The attacker delegates votes from each of those token IDs to the victim address.
  3. A legitimate user locks a large amount of tokens and tries to delegate votes to the same victim.
  4. The delegation reverts because the victim already has the maximum number of delegates.

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.

A smart contract lets people lock tokens and receive voting power. That voting power can be assigned to someone else, called a delegate. The contract only allows a delegate to receive votes from 1024 different token holders. An attacker can create 1024 tiny token locks and assign all of them to the same person, filling the limit so that no one else can assign votes to that person.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by Shahen

View all

3 more disclosed reports, best first.

More from Alchemix

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.