Skip to content
DoS Audit finding Intermediate

Owner’s delegates should be decreased in _burn()

The _burn() function does not remove the burned token from the owner's delegate list, so the list can grow until it hits the maximum allowed. An attacker can deposit tiny amounts to fill a victim's delegate list, preventing them from depositing more tokens.

WatchPug Follow

Originally disclosed on Code4rena

Submitted by WatchPug

VotingEscrow.sol#L517-L528

function _burn(uint _tokenId) internal {
    require(_isApprovedOrOwner(msg.sender, _tokenId), "caller is not owner nor approved");

    address owner = ownerOf(_tokenId);

    // Clear approval
    approve(address(0), _tokenId);
    // TODO add delegates
    // Remove token
    _removeTokenFrom(msg.sender, _tokenId);
    emit Transfer(owner, address(0), _tokenId);
}

VotingEscrow.sol#L1244-L1248

// All the same plus _tokenId
require(
    dstRepOld.length + 1 <= MAX_DELEGATES,
    "dstRep would have too many tokenIds"
);

When _moveTokenDelegates(), dstRep must not have more than MAX_DELEGATES.

However, in _burn(), dstRep array wont get decreased. This opens a griefing attack vector, in which the attacker can deposit 1 wei of token for the victim, repeated for MAX_DELEGATES times, and the victim can no longer deposit, even if they try to merge or burn their tokenIds.

Even for a normal active user, this can be a problem as the dstRep array will continuously grow and cant decrease, one day the user won’t be able to deposit anymore as they have reached the MAX_DELEGATES cap.

Recommendation

Change to:

function _burn(uint _tokenId) internal {
    require(_isApprovedOrOwner(msg.sender, _tokenId), "caller is not owner nor approved");

    address owner = ownerOf(_tokenId);

    // Clear approval
    approve(address(0), _tokenId);
    // remove delegates
    _moveTokenDelegates(delegates(_to), address(0), _tokenId);
    // Remove token
    _removeTokenFrom(msg.sender, _tokenId);
    emit Transfer(owner, address(0), _tokenId);
}

pooltypes (Velodrome) acknowledged

Alex the Entreprenerd (judge) commented:

The warden has shown how, in lack of _moveTokenDelegates(delegates(_to), address(0), _tokenId); an attacker could deny the ability to deposit tokens in the protocol.

Because a user could always roll a new address, I agree with Medium Severity.


The original report as published on Code4rena, by WatchPug. 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

Likely the _burn() function fails to call _moveTokenDelegates to remove the token from the owner's delegate list, so the list is never decreased.

Impact

An attacker could prevent a victim from depositing tokens by filling their delegate list, though the victim could use a new address to work around it.

What the attacker needed

Attacker can deposit tokens; victim has a delegate list

The fix

The _burn() function should call _moveTokenDelegates to remove the token from the owner's delegate list.

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 delegate list tracks which tokens a user has deposited. The code never removes tokens from this list when they are burned, so the list only grows. An attacker can add many tiny deposits to a victim's list until it is full, blocking the victim from depositing more.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More by WatchPug

View all

197 more disclosed reports, best first.

More from Velodrome Finance contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.