Skip to content
Business logic Audit finding Intermediate

Griefer can minimize delegatee’s voting power

The delegate function allowed the same lock NFT to be delegated multiple times, so an attacker could fill a victim's delegated token array with worthless tokens up to the 500 limit, reducing the victim's voting power to zero. This could be used to grief a delegatee during a live proposal.

0xDjango Follow

Originally disclosed on Code4rena

Submitted by 0xDjango, also found by 0x52, 0xsanson, kenzo, MEP, and simon135

https://github.com/code-423n4/2022-07-golom/blob/e5efa8f9d6dda92a90b8b2c4902320acf0c26816/contracts/vote-escrow/VoteEscrowDelegation.sol#L99

https://github.com/code-423n4/2022-07-golom/blob/e5efa8f9d6dda92a90b8b2c4902320acf0c26816/contracts/vote-escrow/VoteEscrowDelegation.sol#L71-L89

Similar to a previous submission, there are no checks preventing against delegating the same lock NFT multiple times. This opens an avenue to an expensive but potentially profitable griefing attack where the malicious user fills the victim’s delegated token array with minimum voting power. The attacker can ensure that a delegatee has 0 voting power.

Proof of Concept

Taking a look at the delegate() function below, there are no checks that a lock NFT has not already been delegated. Therefore, an attacker can delegate their token with minimum voting power (threshold initialized with value 0) to the victim.

    function delegate(uint256 tokenId, uint256 toTokenId) external {
        require(ownerOf(tokenId) == msg.sender, 'VEDelegation: Not allowed');
        require(this.balanceOfNFT(tokenId) >= MIN_VOTING_POWER_REQUIRED, 'VEDelegation: Need more voting power');

        delegates[tokenId] = toTokenId;
        uint256 nCheckpoints = numCheckpoints[toTokenId];

        if (nCheckpoints > 0) {
            Checkpoint storage checkpoint = checkpoints[toTokenId][nCheckpoints - 1];
            checkpoint.delegatedTokenIds.push(tokenId);
            _writeCheckpoint(toTokenId, nCheckpoints, checkpoint.delegatedTokenIds);
        } else {
            uint256[] memory array = new uint256[](1);
            array[0] = tokenId;
            _writeCheckpoint(toTokenId, nCheckpoints, array);
        }

        emit DelegateChanged(tokenId, toTokenId, msg.sender);
    }

There is a limit of 500 delegated tokens per delegatee. Therefore, the attacker can ensure minimum voting power if they delegate a worthless token 500 times to the victim:

    function _writeCheckpoint(
        uint256 toTokenId,
        uint256 nCheckpoints,
        uint256[] memory _delegatedTokenIds
    ) internal {
        require(_delegatedTokenIds.length < 500, 'VVDelegation: Cannot stake more');

A more likely scenario would be as follows:

  • A proposal is live.
  • Users delegate their voting power to addresses of their choosing.
  • A and B are around the same voting power.
  • A and B both have 400 delegatees.
  • Malicious address A delegates minimum voting power 100 times to fill B’s array to 500.
  • Address A can self-delegate just a bit more to obtain more voting power.

Recommended Mitigation Steps

Firstly, removing the ability to delegate the same lock NFT would make this griefing attack much more expensive. Even if that is patched, a griefing attack is still possible by simply creating more locks and delegating them all once.

I believe that removing the 500 delegated token limit would prove to mitigate this issue.

zeroexdead (Golom) confirmed

zeroexdead (Golom) commented:

We plan to keep sufficiently high MIN_VOTING_POWER_REQUIRED to prevent spam.

zeroexdead (Golom) commented:

Removed the ability to delegate same NFT. If user is trying to delegate same NFT, the old delegation will be removed.

Reference: https://github.com/golom-protocol/contracts/commit/c74d95b4105eeb878d2781982178db5ca08a1a9b

LSDan (judge) commented:

I agree with the ranking of medium. This is a direct attack vector, but it’s unlikely to be used.


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

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

The delegate function lacked a check to prevent the same lock NFT from being delegated more than once, and the delegated token array had a hard limit of 500 entries.

Impact

The attacker could ensure that a delegatee has 0 voting power, but the attack is expensive and unlikely to be used.

What the attacker needed

Attacker owns a lock NFT with minimum voting power; victim has a delegated token array near the 500 limit; a proposal is live

The fix

The ability to delegate the same NFT was removed, so re-delegating replaces the old delegation.

How it was found

  1. A proposal is live and users delegate their voting power.
  2. Attacker A and victim B have similar voting power and both have 400 delegatees.
  3. Attacker A delegates a minimum-voting-power token 100 times to fill B's array to 500.
  4. Attacker A self-delegates a bit more to gain more voting power than B.

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.

In this voting system, people lock tokens and can delegate their voting power to someone else. The code did not stop someone from delegating the same locked token over and over. An attacker could spam a victim's list of delegated tokens with tiny amounts until it was full, so the victim's real voting power was ignored.

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 0xDjango

View all

23 more disclosed reports, best first.

More from Golom contest

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.