Skip to content
Access control Audit finding Intermediate

Centralisation risk: admin role of TokenManagerEth can rug pull all Eth from the bridge

The admin role of TokenManagerEth can change the ERC20 token address to an arbitrary contract, then call exitToMain to drain the entire ETH balance from the DepositBox on the main Ethereum chain. This allows a rug pull by the admin.

kirk-baird Follow

Originally disclosed on Code4rena

Submitted by kirk-baird

There is a Centralisation risk of the bridge where the DEFAULT_ADMIN_ROLE of TokenManagerEth.sol is able to modify the ERC20 token on the SChain to any arbitrary address. This would allow the admin role to change the address to one where they have infinite supply, they could then call exitToMain(amount) equal to the balance of the DepositBox in the main Ethereum chain. After the message is process on the main Ethereum chain they will receive the entire Eth balance of that contract.

The rug pull attack occurs because there is a DEFAULT_ADMIN_ROLE which is set in the intiialisation to the msg.sender as seen in initializeTokenManager() below.

The DEFAULT_ADMIN_ROLE may then call setEthErc20Address(IEthErc20 newEthErc20Address) setting newEthErc20Address to any arbitrary contract they control.

Proof of Concept

    function setEthErc20Address(IEthErc20 newEthErc20Address) external override {
        require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "Not authorized caller");
        require(ethErc20 != newEthErc20Address, "Must be new address");
        ethErc20 = newEthErc20Address;
    }
    function initializeTokenManager(
        string memory newSchainName,
        IMessageProxyForSchain newMessageProxy,
        ITokenManagerLinker newIMALinker,
        ICommunityLocker newCommunityLocker,
        address newDepositBox
    )
        public
        virtual
        initializer
    {
        require(newDepositBox != address(0), "DepositBox address has to be set");

        AccessControlEnumerableUpgradeable.__AccessControlEnumerable_init();
        _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
        _setupRole(AUTOMATIC_DEPLOY_ROLE, msg.sender);
        _setupRole(TOKEN_REGISTRAR_ROLE, msg.sender);

        schainHash = keccak256(abi.encodePacked(newSchainName));
        messageProxy = newMessageProxy;
        tokenManagerLinker = newIMALinker;
        communityLocker = newCommunityLocker;
        depositBox = newDepositBox;

        emit DepositBoxWasChanged(address(0), newDepositBox);
    }

Recommended Mitigation Steps

Consider removing the function setEthErc20Address() as ethErc20 is set in the initialize() function and does not need to be changed.

DimaStebaev (SKALE) disagreed with severity and commented:

Acknowledged, and this can be done only by SKALE chain owner.

GalloDaSballo (judge) commented:

Agree that the admin has the ability to rug users and agree with Med Severity


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 contract grants a DEFAULT_ADMIN_ROLE that can change the ERC20 token address after initialisation, without any restriction or timelock.

Impact

The admin could drain the entire ETH balance of the DepositBox, but the SKALE team notes this can only be done by the SKALE chain owner.

What the attacker needed

Admin role (SKALE chain owner)

The fix

The function setEthErc20Address should be removed because ethErc20 is set during initialisation and does not need to change.

How it was found

  1. The admin calls setEthErc20Address to point to a malicious ERC20 contract they control.
  2. The admin calls exitToMain with an amount equal to the DepositBox balance.
  3. The message is processed on the main Ethereum chain and the admin receives the entire ETH balance.

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 privileged admin account can swap the token contract used by a bridge to one they control, then withdraw all the real money held by the bridge. This is a centralisation risk because the admin 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 SKALE 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.