Skip to content
DoS Audit finding Intermediate

getNewCurrentFees reverts when minFeePercentage > feeRatio

The getNewCurrentFees function reverts when the minimum withdrawal fee exceeds a user's fee ratio, which can happen after governance changes. This temporarily prevents depositors from transferring or redeeming their LP tokens.

shenwilly Follow

Originally disclosed on Code4rena

Submitted by shenwilly

LiquidityPool.sol#L694

Depositors won’t be able to transfer or redeem funds temporarily.

The problem is caused by the implementation of LiquidityPool.getNewCurrentFees:

function getNewCurrentFees(
    uint256 timeToWait,
    uint256 lastActionTimestamp,
    uint256 feeRatio
) public view returns (uint256) {
    uint256 timeElapsed = _getTime() - lastActionTimestamp;
    uint256 minFeePercentage = getMinWithdrawalFee();
    if (timeElapsed >= timeToWait) {
        return minFeePercentage;
    }
    uint256 elapsedShare = timeElapsed.scaledDiv(timeToWait);
    return feeRatio - (feeRatio - minFeePercentage).scaledMul(elapsedShare);
}

The last line requires the current feeRatio to be higher than minFeePercentage or the function will revert. When this condition is broken, some critical functions such as transferring tokens and redeeming will be unusable. Affected users need to wait until enough time has elapsed and getNewCurrentFees returns minFeePercentage on L691.

This could happen if governance changes the MinWithdrawalFee to be higher than a user’s feeRatio.

Proof of Concept

  • Initial MinWithdrawalFee is set to 0, MaxWithdrawalFee is set to 0.03e18.
  • Alice deposits fund and receives LP token. Alice’s feeRatio is now set to 0.03e18 (the current MaxWithdrawalFee).
  • Governance changes MaxWithdrawalFee to 0.05e18 and MinWithdrawalFee to 0.04e18.
  • minFeePercentage is now higher than Alice’s feeRatio and she can’t transfer nor redeem the LP token until timeElapsed >= timeToWait.

Recommended Mitigation Steps

Add a new condition in getNewCurrentFees L690 to account for this case:

if (timeElapsed >= timeToWait || minFeePercentage > feeRatio) {
    return minFeePercentage;
}

chase-manning (Backd) confirmed and resolved


The original report as published on Code4rena, by shenwilly. 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 subtraction in the fee calculation underflows when minFeePercentage is greater than feeRatio, causing a revert.

What the attacker needed

Governance changes MinWithdrawalFee above user's feeRatio

The fix

The function should return minFeePercentage when minFeePercentage is greater than feeRatio, and the issue was fixed.

How it was found

  1. Initial MinWithdrawalFee is set to 0, MaxWithdrawalFee is set to 0.03e18.
  2. Alice deposits fund and receives LP token. Alice’s feeRatio is now set to 0.03e18 (the current MaxWithdrawalFee).
  3. Governance changes MaxWithdrawalFee to 0.05e18 and MinWithdrawalFee to 0.04e18.
  4. minFeePercentage is now higher than Alice’s feeRatio and she can’t transfer nor redeem the LP token until timeElapsed >= timeToWait.

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 calculates a fee based on how long you've waited. If the minimum fee is set higher than your personal fee rate, the calculation underflows and the transaction fails, so you can't move your tokens until enough time passes.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More by shenwilly

View all

12 more disclosed reports, best first.

More from Backd Tokenomics contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.