Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ulysses omnichain - addbridgeagentfactory in rootPort is not functional #372

Open
code423n4 opened this issue Jun 29, 2023 · 5 comments
Open
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working edited-by-warden M-28 primary issue Highest quality submission among a set of duplicates satisfactory satisfies C4 submission criteria; eligible for awards selected for report This submission will be included/highlighted in the audit report sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")

Comments

@code423n4
Copy link
Contributor

code423n4 commented Jun 29, 2023

Lines of code

https://github.com/code-423n4/2023-05-maia/blob/78e49c651fd119b85bb79296620d5cb39efa7cdd/src/ulysses-omnichain/RootPort.sol#L406-L410

Vulnerability details

Impact

the addbridgeagentfactory function is responsible for adding a new bridge agent factory to the root port.

However the current implementation is faulty. the faulty logic is in the following line:

bridgeAgentFactories[bridgeAgentsLenght++] = _bridgeAgentFactory;

a couple of problems here, the function is attempting to access an index that does not yet exist in the bridgeAgentFactories array, this should return an out of bounds error. the function also does not update the isBridgeAgentFactory mapping. once a a new bridge agent factory is added, a new dict item with key equal to address of new bridge agent factory and value of true. this mapping is then used to enable toggling the factory, ie enabling or disabling it via the toggleBridgeAgentFactory function.

Impact: the code hints that this is a key governance action. it does not work at the moment however with regards to impact, at this moment it is unclear from the code what the overall impact would be to the functioning of the protocol, that is why it is rated as medium rather than high. feedback from sponsors is welcome to determine severity.

Proof of Concept

    function testAddRootBridgeAgentFactoryBricked() public {
    //Get some gas
    hevm.deal(address(this), 1 ether);

    RootBridgeAgentFactory newBridgeAgentFactory = new RootBridgeAgentFactory(
        ftmChainId,
        WETH9(ftmWrappedNativeToken),
        localAnyCallAddress,
        address(ftmPort),
        dao
    );

    rootPort.addBridgeAgentFactory(address(newBridgeAgentFactory));
    
    require(rootPort.bridgeAgentFactories(0)==address(bridgeAgentFactory), "Initial Factory not in factory list");
    require(rootPort.bridgeAgentFactories(1)==address(newBridgeAgentFactory), "New Factory not in factory list");

}

the above POC demonstrates this, it attempts to call the function in question, and returns an "Index out of bounds" error.

Tools Used

Recommended Mitigation Steps

    function addBridgeAgentFactory(address _bridgeAgentFactory) external onlyOwner {
    // @audit this function is broken
    // should by implemented as so
    isBridgeAgentFactory[_bridgeAgentFactory] = true;
    bridgeAgentFactories.push(_bridgeAgentFactory);
    bridgeAgentFactoriesLenght++;

    emit BridgeAgentFactoryAdded(_bridgeAgentFactory);
}

the correct implementation is above, this is also identical to how the branch ports implement this functionality.

Assessed type

Governance

@code423n4 code423n4 added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working labels Jun 29, 2023
code423n4 added a commit that referenced this issue Jun 29, 2023
@code423n4 code423n4 changed the title addbridgeagentfactory in rootPort is not functional Ulysses omnichain - addbridgeagentfactory in rootPort is not functional Jun 29, 2023
@c4-judge c4-judge added the primary issue Highest quality submission among a set of duplicates label Jul 10, 2023
@c4-judge
Copy link
Contributor

trust1995 marked the issue as primary issue

@c4-judge
Copy link
Contributor

trust1995 marked the issue as satisfactory

@c4-sponsor
Copy link

0xBugsy marked the issue as sponsor confirmed

@c4-sponsor c4-sponsor added the sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") label Jul 12, 2023
@c4-judge
Copy link
Contributor

trust1995 marked the issue as selected for report

@c4-judge c4-judge added the selected for report This submission will be included/highlighted in the audit report label Jul 25, 2023
@C4-Staff C4-Staff added the M-28 label Jul 31, 2023
@0xLightt
Copy link

0xLightt commented Sep 6, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working edited-by-warden M-28 primary issue Highest quality submission among a set of duplicates satisfactory satisfies C4 submission criteria; eligible for awards selected for report This submission will be included/highlighted in the audit report sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Projects
None yet
Development

No branches or pull requests

5 participants