Skip to content
Access control Audit finding Intermediate

Centralisation RIsk: VoterProxy owner may set the operate to an address they own and drain all token balances

The owner of VoterProxy can change the operator to an address they control, then use privileged functions to withdraw all token balances from gauges and the contract. This allows a malicious or compromised owner to drain protocol funds.

kirk-baird Follow

Originally disclosed on Code4rena

Submitted by kirk-baird

https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VoterProxy.sol#L274-L285

https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VoterProxy.sol#L123-L143

Impact

The owner of VoterProxy is able to call setOperator() (if the previous operator is shutdown). This allows them to then call execute(), withdraw() or withdrawAll().

Execute makes a call to any arbitrary contract with arbitrary data. This may therefore call any ERC20 token, and gauge or the VoterEscrow account and withdraw protocol funds.

The functions withdraw() and withdrawAll() can also be abused to take all funds deposited in the gauges and transfer them to the owner’s malicious address.

This poses a significant centralisation risk if the owner private key is compromised or the owner decides to rug pull.

Proof of Concept

After the owner has updated the operator via setOperator() they are able to call VoterProxy.execute() to execute any call to any smart contract.

    function execute(
        address _to,
        uint256 _value,
        bytes calldata _data
    ) external returns (bool, bytes memory) {
        require(msg.sender == operator, "!auth");

        (bool success, bytes memory result) = _to.call{value: _value}(_data);
        require(success, "!success");

        return (success, result);
    }

Similarly, for withdraw() and withdrawAll()

    function withdraw(
        address _token,
        address _gauge,
        uint256 _amount
    ) public returns (bool) {
        require(msg.sender == operator, "!auth");
        uint256 _balance = IERC20(_token).balanceOf(address(this));
        if (_balance < _amount) {
            _amount = _withdrawSome(_gauge, _amount.sub(_balance));
            _amount = _amount.add(_balance);
        }
        IERC20(_token).safeTransfer(msg.sender, _amount);
        return true;
    }

    function withdrawAll(address _token, address _gauge) external returns (bool) {
        require(msg.sender == operator, "!auth");
        uint256 amount = balanceOfPool(_gauge).add(IERC20(_token).balanceOf(address(this)));
        withdraw(_token, _gauge, amount);
        return true;
    }

Recommended Mitigation Steps

This issue may be mitigated removing the ability for the owner to change the operator in VoterProxy.

If the functionality is require ensure it is behind a time lock and multisig / dao.

jetbrain10 (veToken Finance) acknowledged, but disagreed with severity and commented:

Admin will be controlled by DAO and muti-sig wallet.

Alex the Entreprenerd (judge) commented:

The warden has shown how, due to a couple of permissioned functions, funds may be swept out of the VoterProxy.

Because this is contingent on a malicious admin, I believe Medium severity to be appropriate.

For end users I highly recommend making sure that not only the multi-sig is strong (high threshold), but also that is behind a time-lock to ensure you have time to react in case of emergency.


The original report as published on Code4rena, by kirk-baird. 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 owner has the ability to change the operator without any delay or multi-signature requirement, and the operator can then call functions that transfer all funds.

Impact

If the owner's private key is compromised or the owner decides to rug pull, all funds deposited in the gauges and held by the contract could be stolen.

What the attacker needed

Owner is malicious or key compromised; previous operator is shutdown

How it was found

  1. The owner calls setOperator() to set the operator to an address they control, provided the previous operator is shutdown.
  2. The owner (now operator) calls execute() with arbitrary data to make the contract call any ERC20 token or gauge and withdraw funds.
  3. Alternatively, the owner calls withdraw() or withdrawAll() to transfer all tokens from gauges to their own address.

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 called VoterProxy holds user funds and has an owner who can change who is allowed to operate it. If that owner is malicious or their key is stolen, they can switch the operator to themselves and then use special functions to take all the money. This is a centralisation risk because one person has too much power.

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 kirk-baird

View all

32 more disclosed reports, best first.

More from veToken Finance 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.