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.
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
- Navigate to the following contract.
- Owner can identify fee amount. That directly affect to LP management. LiquidityPool.sol#L352
- 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
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.
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
- Navigate to the TokenManager contract.
- The owner calls changeFee with arbitrary equilibriumFee and maxFee values.
- 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.