Skip to content
Business logic Audit finding Beginner

Improper Upper Bound Definition on the Fee

The fee parameters equilibriumFee and maxFee had no upper or lower bounds, so the owner could set them to extreme values. This could cause critical functions to revert or cause liquidity providers to lose all funds when paying the fee.

defsec Follow

Originally disclosed on Code4rena

Submitted by defsec, also found by catchup, danb, Dravee, gzeon, hickuphh3, hubble, peritoflores, Ruhum, and throttle

The equilibriumFee and maxFee does not have any upper or lower bounds. Values that are too large will lead to reversions in several critical functions or the LP user will lost all funds when paying the fee.

Proof of Concept

  1. Navigate to the following contract.

TokenManager.sol#L52

  1. Owner can identify fee amount. That directly affect to LP management. LiquidityPool.sol#L352
  2. Here you can see there is no upper bound has been defined.
    function changeFee(
        address tokenAddress,
        uint256 _equilibriumFee,
        uint256 _maxFee
    ) external override onlyOwner whenNotPaused {
        require(_equilibriumFee != 0, "Equilibrium Fee cannot be 0");
        require(_maxFee != 0, "Max Fee cannot be 0");
        tokensInfo[tokenAddress].equilibriumFee = _equilibriumFee;
        tokensInfo[tokenAddress].maxFee = _maxFee;
        emit FeeChanged(tokenAddress, tokensInfo[tokenAddress].equilibriumFee, tokensInfo[tokenAddress].maxFee);
    }

Recommended Mitigation Steps

Consider defining upper and lower bounds on the equilibriumFee and maxFee.

ankurdubey521 (Biconomy) confirmed and commented:

HP-25: C4 Audit Fixes, Dynamic Fee Changes bcnmy/hyphen-contract#42

pauliax (judge) commented:

Valid concern. I am grouping all the issues related to the validation of fee variables together and making this the primary one as it contains the most comprehensive description.


The original report as published on Code4rena, by defsec. 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 changeFee function only checked that the fee values were not zero, but did not enforce any upper or lower limits.

What the attacker needed

Owner privileges

The fix

The project should define upper and lower bounds on the equilibriumFee and maxFee parameters.

How it was found

  1. Navigate to the TokenManager contract.
  2. The owner calls changeFee with arbitrary equilibriumFee and maxFee values.
  3. The function only checks that the values are not zero, so any large value is accepted.

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 lets an owner change fees, but it did not check how big those fees could be. If the owner sets a huge fee, the contract might stop working or users could lose all their money.

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 defsec

View all

16 more disclosed reports, best first.

More from Biconomy - Smart Contract Wallet contest

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.