Skip to content
Access control Audit finding Intermediate

onlyCentrifugeChainOrigin() can’t require msg.sender equal axelarGateway

The onlyCentrifugeChainOrigin modifier required msg.sender to be the Axelar gateway, but the gateway never calls the router's execute method, so cross-chain commands could not be executed. This could leave user deposits stuck if the router was the only ward.

bin2chen Follow with maanas, nobody2018 and 3 others

Originally disclosed on Code4rena

Submitted by bin2chen, also found by maanas, nobody2018, castle_chain, mert_eren, and merlin

In AxelarRouter.sol, we need to ensure the legitimacy of the execute() method execution, mainly through two methods:

  1. axelarGateway.validateContractCall () to validate if the command is approved or not.
  2. onlyCentrifugeChainOrigin() is used to validate that sourceChain sourceAddress is legal.

Let’s look at the implementation of onlyCentrifugeChainOrigin():

    modifier onlyCentrifugeChainOrigin(string calldata sourceChain, string calldata sourceAddress) {
@>      require(msg.sender == address(axelarGateway), "AxelarRouter/invalid-origin");
        require(
            keccak256(bytes(axelarCentrifugeChainId)) == keccak256(bytes(sourceChain)),
            "AxelarRouter/invalid-source-chain"
        );
        require(
            keccak256(bytes(axelarCentrifugeChainAddress)) == keccak256(bytes(sourceAddress)),
            "AxelarRouter/invalid-source-address"
        );
        _;
    }

The problem is that this restriction msg.sender == address(axelarGateway).

When we look at the official axelarGateway.sol contract, it doesn’t provide any call external contract ‘sexecute() method.

So msg.sender cannot be axelarGateway, and the official example does not restrict msg.sender.

The security of the command can be guaranteed by axelarGateway.validateContractCall(), sourceChain, sourceAddress.

There is no need to restrict msg.sender.

axelarGateway code address https://github.com/axelarnetwork/axelar-cgp-solidity/blob/main/contracts/AxelarGateway.sol

Can’t find anything that calls router.execute().

Impact

router.execute() cannot be executed properly, resulting in commands from other chains not being executed, protocol not working properly.

Recommended Mitigation

Remove msg.sender restriction

    modifier onlyCentrifugeChainOrigin(string calldata sourceChain, string calldata sourceAddress) {
-       require(msg.sender == address(axelarGateway), "AxelarRouter/invalid-origin");
        require(
            keccak256(bytes(axelarCentrifugeChainId)) == keccak256(bytes(sourceChain)),
            "AxelarRouter/invalid-source-chain"
        );
        require(
            keccak256(bytes(axelarCentrifugeChainAddress)) == keccak256(bytes(sourceAddress)),
            "AxelarRouter/invalid-source-address"
        );
        _;
    }

Assessed type

Context

hieronx (Centrifuge) confirmed

gzeon (judge) increased severity to High and commented:

This seems High risk to me since the Axelar bridge is a centerpiece of this protocol, and when deployed in a certain way where the AxelarRouter is the only ward, it might cause user deposits to be stuck forever.

gzeon (judge) decreased severity to Medium and commented:

Reconsidering severity to Medium here since the expected setup would have DelayedAdmin able to unstuck the system.

hieronx (Centrifuge) commented:

Mitigated in https://github.com/centrifuge/liquidity-pools/pull/168


The original report as published on Code4rena, by bin2chen. 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 modifier required msg.sender to equal the Axelar gateway address, but the gateway does not call the router's execute function, so the check always failed.

Impact

Cross-chain commands could not be executed, potentially causing user deposits to be stuck forever if the router was the only ward, though the expected setup with a DelayedAdmin could unstuck the system.

What the attacker needed

Router is the only ward

The fix

The msg.sender restriction was removed, and the issue was mitigated in a pull request.

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 on one blockchain wanted to accept instructions from another blockchain through a bridge. It added a check that the instruction must come directly from the bridge contract, but the bridge never sends messages that way, so every instruction was rejected. The fix is to remove that check and rely on the bridge's own validation of the message.

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 bin2chen

View all

139 more disclosed reports, best first.

More from Centrifuge

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.