Skip to content
Business logic Audit finding Intermediate

updatePoolAddress functions always revert when updating existing poolId

The updatePoolAddress function always reverts when trying to update an existing poolId because it calls verifyNewPool, which itself reverts if the poolId already exists. This makes it impossible to update the pool address for an existing poolId.

Aymen0909 Follow with trustOne, bin2chen and 1 other

Originally disclosed on Code4rena

Submitted by Aymen0909, also found by trustOne, bin2chen, and T1MOH

The purpose of the updatePoolAddress function is to update the pool address associated with an existing poolId. However, due to its internal invocation of the verifyNewPool function, the updatePoolAddress function always reverts. This occurs because the verifyNewPool function itself reverts when the specified poolId already exists. Consequently, it is not possible to update the pool address for an existing poolId.

Proof of Concept

The issue occurs in the updatePoolAddress function below :

File: PoolUtils.sol Line 55-65

function updatePoolAddress(
    uint8 _poolId,
    address _newPoolAddress
) external override onlyExistingPoolId(_poolId) onlyRole(DEFAULT_ADMIN_ROLE) {
    UtilLib.checkNonZeroAddress(_newPoolAddress);
    // @audit always revert on exsiting poolId
    verifyNewPool(_poolId, _newPoolAddress);
    poolAddressById[_poolId] = _newPoolAddress;
    emit PoolAddressUpdated(_poolId, _newPoolAddress);
}

As it can be seen from the code above, the updatePoolAddress function contains the onlyExistingPoolId modifier which means it can only be called for updating the pool address of an already exiting poolId.

Before updating the pool address, the updatePoolAddress function calls the verifyNewPool function below:

function verifyNewPool(uint8 _poolId, address _poolAddress) internal view {
    if (
        INodeRegistry(IStaderPoolBase(_poolAddress).getNodeRegistry()).POOL_ID() != _poolId ||
        isExistingPoolId(_poolId)
    ) {
        revert ExistingOrMismatchingPoolId();
    }
}

It’s clear that the function reverts when the poolId already exists meaning isExistingPoolId(_poolId) == true.

To summarize, the updatePoolAddress function reverts when the poolId does not exist and the verifyNewPool function reverts when the poolId exists. These two functions work on opposite conditions, which means when the verifyNewPool function is called inside the updatePoolAddress function it will automatically revert and the pool address of already existing poolId can never be updated.

Recommended Mitigation Steps

Remove the verifyNewPool call inside the updatePoolAddress function and replace it with the following:

function updatePoolAddress(
    uint8 _poolId,
    address _newPoolAddress
) external override onlyExistingPoolId(_poolId) onlyRole(DEFAULT_ADMIN_ROLE) {
    UtilLib.checkNonZeroAddress(_newPoolAddress);
    // @audit revert only when mismatch in poolId
    if (INodeRegistry(IStaderPoolBase(_poolAddress).getNodeRegistry()).POOL_ID() != _poolId) {
        revert MismatchingPoolId();
    }
    poolAddressById[_poolId] = _newPoolAddress;
    emit PoolAddressUpdated(_poolId, _newPoolAddress);
}

Assessed type

Error

Picodes (judge) decreased severity to Medium

manoj9april (Stader) confirmed and commented:

Thanks! We will fix this.

sanjay-staderlabs (Stader) commented:

This is fixed.


The original report as published on Code4rena, by Aymen0909. 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 updatePoolAddress function calls verifyNewPool, which reverts if the poolId already exists, but updatePoolAddress is only called for existing poolIds.

Impact

The pool address for an existing poolId cannot be updated, potentially preventing necessary maintenance or corrections.

What the attacker needed

Admin role required

The fix

The fix is to remove the verifyNewPool call and replace it with a check that only reverts on a poolId mismatch.

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 has a function meant to change the address associated with an existing pool ID. However, that function calls another function that only works for new pool IDs, so it always fails. As a result, the address can never be updated.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by Aymen0909

View all

22 more disclosed reports, best first.

More from Stader Labs

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.