Skip to content
Access control Audit finding Intermediate

VoteEscrowDelegation._transferFrom can only be executed by the token owner

The internal transfer routine calls a delegation-removal function that only accepts the token owner as caller, so transfers initiated by an approved operator or approved address revert. As a result, only the token owner can move a delegated token, breaking the expected approval-based transfer flow.

GimelSec Follow

Originally disclosed on Code4rena

Submitted by GimelSec, also found by GalloDaSballo, kebabsec, and kenzo

VoteEscrowDelegation._transferFrom should be successfully executed if msg.sender is the current owner, an authorized operator, or the approved address. removeDelegation is called in _transferFrom. removeDelegation only accepts the token owner. Thus, _transferFrom can only be executed by the token owner.

Proof of Concept

removeDelegation is called in _transferFrom https://github.com/code-423n4/2022-07-golom/blob/main/contracts/vote-escrow/VoteEscrowDelegation.sol#L242

    function _transferFrom(
        address _from,
        address _to,
        uint256 _tokenId,
        address _sender
    ) internal override {
        require(attachments[_tokenId] == 0 && !voted[_tokenId], 'attached');

        // remove the delegation
        this.removeDelegation(_tokenId);

        // Check requirements
        require(_isApprovedOrOwner(_sender, _tokenId));
        …
    }

However, removeDelegation only accept the token owner https://github.com/code-423n4/2022-07-golom/blob/main/contracts/vote-escrow/VoteEscrowDelegation.sol#L211

    function removeDelegation(uint256 tokenId) external {
        require(ownerOf(tokenId) == msg.sender, 'VEDelegation: Not allowed');
        uint256 nCheckpoints = numCheckpoints[tokenId];
        Checkpoint storage checkpoint = checkpoints[tokenId][nCheckpoints - 1];
        removeElement(checkpoint.delegatedTokenIds, tokenId);
        _writeCheckpoint(tokenId, nCheckpoints, checkpoint.delegatedTokenIds);
    }

Recommended Mitigation Steps

Fix the permission control in removeDelegation.

zeroexdead (Golom) confirmed

zeroexdead (Golom) commented:

Changed the external function to public. Users address will be passed as msg.sender now. https://github.com/golom-protocol/contracts/commit/10ec920765a5ee2afc2fe269d32ea9138d1156b6

0xsaruman (Golom) resolved


The original report as published on Code4rena, by GimelSec. 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 delegation-removal function checks the caller against the token owner instead of accepting the sender passed through the transfer path, so approved operators cannot complete a transfer.

Impact

Approved operators and approved addresses cannot transfer delegated tokens, so the approval mechanism is effectively broken for those tokens.

What the attacker needed

A delegated token; an approved operator or address

The fix

The permission check in the delegation-removal function was changed so the sender is passed in, and the function was made public; the project confirmed and resolved it.

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 token owner can normally let someone else move their token by approving them. Here the transfer code first calls a cleanup function that insists the caller is the owner, so anyone acting on the owner's behalf is rejected and the transfer fails.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

More by GimelSec

View all

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

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.