Skip to content
Business logic Audit finding Intermediate

Cannot remove delegation from a token to another token

The removeDelegation function in a vote-escrow contract removes the token from its own list of delegators instead of from the delegatee's list, so a user cannot undo a delegation. The delegatee permanently keeps the voting power, which could enable governance attacks.

Bahurum Follow

Originally disclosed on Code4rena

Submitted by Bahurum, also found by 0x52, 0xA5DF, 0xsanson, berndartmueller, cccz, CertoraInc, dipp, GalloDaSballo, GimelSec, Green, IllIllI, kenzo, MEP, panprog, and scaraven

VoteEscrowDelegation.sol#L213

A user who has delegated the vote of a veGolom token (that he/she owns) to another veGolom token cannot remove the delegation, so the delegatee token will permanently hold the voting power of the delegator token.

Proof of Concept

A user tries to remove the delegation from tokenId he/she owns to the delegated token, calling removeDelegation(uint256 tokenId). The delegation should be removed at the lines:

        Checkpoint storage checkpoint = checkpoints[tokenId][nCheckpoints - 1];
        removeElement(checkpoint.delegatedTokenIds, tokenId);

but the array checkpoint.delegatedTokenIds is the list of delegators to tokenId itself. So, unless the delegation was from the token to itself, removeDelegation does nothing.

Recommended Mitigation Steps

Two fixes are proposed:

  1. Add the delegatee as an argument to removeDelegation and remove tokenId from its list of delegators:
-   function removeDelegation(uint256 tokenId) external {
+   function removeDelegation(uint256 tokenId, uint256 toTokenId) external {
        require(ownerOf(tokenId) == msg.sender, 'VEDelegation: Not allowed');
        uint256 nCheckpoints = numCheckpoints[tokenId];
-       Checkpoint storage checkpoint = checkpoints[tokenId][nCheckpoints - 1];
+       Checkpoint storage checkpoint = checkpoints[toTokenId][nCheckpoints - 1];
        removeElement(checkpoint.delegatedTokenIds, tokenId);
        _writeCheckpoint(tokenId, nCheckpoints, checkpoint.delegatedTokenIds);
    }

or

  1. Load the delegatee from the mapping delegates which maps each delegator to its current delegatee:
    function removeDelegation(uint256 tokenId) external {
        require(ownerOf(tokenId) == msg.sender, 'VEDelegation: Not allowed');
+       uint256 toTokenId = delegates[tokenId];
        uint256 nCheckpoints = numCheckpoints[tokenId];
-       Checkpoint storage checkpoint = checkpoints[tokenId][nCheckpoints - 1];
+       Checkpoint storage checkpoint = checkpoints[toTokenId][nCheckpoints - 1];
        removeElement(checkpoint.delegatedTokenIds, tokenId);
        _writeCheckpoint(tokenId, nCheckpoints, checkpoint.delegatedTokenIds);
    }

kenzo (warden) commented:

Note that in the mitigation, nCheckpoints should access toTokenId instead of tokenId.

zeroexdead (Golom) confirmed

zeroexdead (Golom) commented:

Fixed. https://github.com/golom-protocol/contracts/commit/4b19fce83ad53bc56b1bad058e1e88d90acda444

0xsaruman (Golom) resolved

LSDan (judge) increased severity to High and commented:

I agree with the other wardens who rated this high risk. It has a direct impact on the functioning of the protocol and allows for a myriad of governance attacks.


The original report as published on Code4rena, by Bahurum. 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 function reads the checkpoint for the delegator token instead of the delegatee token, so it removes the token from its own delegator list rather than the delegatee's.

Impact

The delegatee token permanently holds the voting power of the delegator token, which could enable governance attacks.

What the attacker needed

Own a veGolom token; have delegated its vote to another token

The fix

The issue was fixed by loading the delegatee token ID and using its checkpoint when removing the delegation.

How it was found

  1. A user owns a veGolom token and delegates its vote to another veGolom token.
  2. The user calls removeDelegation with their token ID.
  3. The function loads the checkpoint for the user's own token, not the delegatee.
  4. It removes the token from its own delegator list, which does not contain it, so nothing changes.

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 system, a token holder can lend their voting power to another token. The function meant to take that power back looks in the wrong place, so the loan never ends. The borrower keeps the votes forever, which could let them control decisions.

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 Bahurum

View all

10 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.