Skip to content
Business logic Audit finding Intermediate

Lack of update when modifying pool fee

The setPoolFee function changes a pool's fee without first syncing the pool, so the next sync applies the new fee to the period before the change. This can cause the protocol or users to pay or receive incorrect fees, especially when setPoolFeeBulk changes many pools.

0xCiphky Follow

Originally disclosed on Code4rena

Submitted by 0xCiphky

The FeeManager contract allows the master address to modify the pool fee. This can be done to a single pool using the setPoolFee function or multiple pools at once using the setPoolFeeBulk function. This fee is used in the the syncPool modifier, specifically the _updatePseudoTotalAmounts function which updates the interest amounts of the borrow and lending pools.

    function setPoolFee(
        address _poolToken,
        uint256 _newFee
    )
        external
        onlyMaster
    {
        _checkValue(
            _newFee
        );

        WISE_LENDING.setPoolFee(
            _poolToken,
            _newFee
        );

        emit PoolFeeChanged(
            _poolToken,
            _newFee,
            block.timestamp
        );
    }

The issue is that the setPoolFee function modifies the pool fee without invoking the syncPool modifier beforehand. Consequently, the next sync operation incorrectly applies the updated pool fee to the period between the previous call and the change in the pool fee. Although the impact of changing the fee for a single pool may be minimal, using the setPoolFeeBulk function to alter fees for multiple pools could have a bigger impact.

Impact

Depending on whether the pool fee is increased or decreased, the protocol or its users may end up paying additional fees or receiving reduced fees.

Likelihood: Low. This situation arises solely in instances where there is a change in the pool fee.

Recommendation

Add the following code to update fees accurately before implementing changes:

    function setPoolFee(
        address _poolToken,
        uint256 _newFee
    )
        external
        onlyMaster
    {
	WISE_LENDING.syncManually(_poolToken); //add here

        _checkValue(
            _newFee
        );

        WISE_LENDING.setPoolFee(
            _poolToken,
            _newFee
        );

        emit PoolFeeChanged(
            _poolToken,
            _newFee,
            block.timestamp
        );
    }

Assessed type

Context

vm06007 (Wise Lending) commented:

Admin can also call this manually (syncManually) directly on the contract after changing fee.

Trust (judge) commented:

@vm06007 - This is true; but for it to reduce severity, we would need to see indication that likelihood of this happening (ergo, that the issue is known) is high.

Foon256 (Wise Lending) commented:

@Trust - But this is clearly a centralization issue and is OOS. Or what do I miss here?

Trust (judge) commented:

Not every flaw in a privileged function can be viewed as a centralization issue. Warden demonstrated a plausible way where an HONEST admin interaction leads to incorrect fee allocation, which I consider to be in scope.

vm06007 (Wise Lending) commented:

@Trust - It seems “honest” is something caps-locked here so we better unfold this:

  • If admin decides not to call this, there is no issue.
  • If admin decides to call this and knows what to do then, there is no issue.
  • If admin decides to call this and does not know what to do only then it is an issue, so it falls under a category where it does not matter the intention of the admin (honest or dishonest can’t really be a thing here). It is more of a question will admin make a mistake when calling that function without follow up, or admin does not make a mistake and makes correct calls on sync as well.

Also it is in admins interest to make correct calls as expected. If admin makes a mistake then it is same topic of “admin error” no matter the intention.

Trust (judge) commented:

Post-Judging QA is over, so unfortunately, we cannot consider any more arguments (in this submission or any other). I don’t see how we can be confident admin knows to follow up this call correctly. If they are not aware of the issue in the report, that’s the meaning of an honest mistake in my mind.

Wise Lending commented:

Mitigated here.


The original report as published on Code4rena, by 0xCiphky. 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

Likely the setPoolFee function updates the fee without calling syncPool first, so the next sync applies the new fee to the period before the change.

Impact

Depending on whether the fee is increased or decreased, the protocol or users may pay extra fees or receive reduced fees; the likelihood is low and only occurs when the pool fee is changed.

What the attacker needed

Master address changes a pool fee

The fix

The setPoolFee function should call syncManually for the pool before changing the fee; the report notes this was mitigated in a later commit.

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 lending pool charges a fee that is used when interest is updated. If the fee is changed without first updating the pool, the new fee is applied to time that passed under the old fee. This can make the fee totals wrong for the protocol or its users.

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 0xCiphky

View all

11 more disclosed reports, best first.

More from Wise Lending

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.