Skip to content
Access control Audit finding Intermediate

function changeController() has rug potential as admin can unilaterally withdraw all user funds from both risk and insure vaults

The admin can change the controller address of any vault at any time, and the new controller can call sendTokens to transfer all assets out of the vault. This allows the admin to withdraw all user funds from both risk and insure vaults.

yixxas Follow

Originally disclosed on Code4rena

Submitted by yixxas

https://github.com/code-423n4/2022-09-y2k-finance/blob/2175c044af98509261e4147edeb48e1036773771/src/Vault.sol#L295

https://github.com/code-423n4/2022-09-y2k-finance/blob/2175c044af98509261e4147edeb48e1036773771/src/Vault.sol#L360-L366

Impact

Admin can rug all user funds in every vault deployed by changing the controller address.

Proof of Concept

Controller can be changed by admin anytime without any warning to users.

Vault.sol#L295

    function changeController(address _controller) public onlyFactory {
        if(_controller == address(0))
            revert AddressZero();
        controller = _controller;
    }

Tokens in the vaults can then be called by the malicious contract to be transferred to their own address with sendTokens().

Vault.sol#L360-L366

    function sendTokens(uint256 id, address _counterparty)
        public
        onlyController
        marketExists(id)
    {
        asset.transfer(_counterparty, idFinalTVL[id]);
    }

Recommended Mitigation Steps

Allow the change of controller address only in the VaultFactory(). This way, markets that have been created cannot have a different controller address, so users can be made aware of the change before choosing to make deposit of assets.

MiguelBits (Y2K Finance) marked as duplicate and commented:

Implemented timelock as issued in another finding.

HickupHH3 (judge) decreased severity to QA and commented:

Admin privilege finding, rationale for QA explained here

yixxas (warden) commented:

Hi @HickupHH3. Would like to seek clarifications on why this was downgraded to QA. In the rationale given, “Those that explained the impact and vulnerability in detail will be grouped together with medium severity “.

I believe the way a compromised admin can rug is clear in this report. changeController() can be used to change controller to any address. This address can then be used to call sendTokens() to steal all assets in every vault.

HickupHH3 (judge) increased severity to Medium and commented:

Took another look at this.

I disagree with the recommended fix. The purpose for having the controller changeable in the deployed instances is well intentioned for upgradeability purposes: perhaps new features are to be added to the controller, and migration to a new controller for all existing vaults is required to incur less technical debt. Needing to maintain legacy controllers isn’t great from a devops POV.

That said, based on my rationale, the issue should stand as a medium severity issue until we have the introduction of centralisation reports. Kenzo said it well:

IMO most of these trusted-actor issues basically just describe general properties of the crypto/governance ecosystems, and do not reflect a novel problem in the design/implementation (which wardens are paid to discover). Because of this, and because of the circular logic, I believe we should change the rules and add a dedicated centralization report.


The original report as published on Code4rena, by yixxas. 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 changeController function allows the admin to set any address as controller without a timelock or restriction, and the controller has the power to transfer all vault assets.

What the attacker needed

Admin privileges

The fix

The change of controller address should be restricted to the VaultFactory so that existing markets cannot have a different controller, or a timelock should be added; the report states a timelock was implemented.

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 vault is a smart contract that holds user deposits. The admin can swap out the controller, which is the only address allowed to move funds, and the new controller can then send all tokens to itself. This means users cannot trust that their funds are safe from the admin.

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 yixxas

View all

13 more disclosed reports, best first.

More from Y2k 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.