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.
Submitted by shenwilly
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
MinWithdrawalFeeis set to 0,MaxWithdrawalFeeis set to 0.03e18. - Alice deposits fund and receives LP token. Alice’s
feeRatiois now set to 0.03e18 (the currentMaxWithdrawalFee). - Governance changes
MaxWithdrawalFeeto0.05e18andMinWithdrawalFeeto0.04e18. minFeePercentageis now higher than Alice’sfeeRatioand she can’t transfer nor redeem the LP token untiltimeElapsed >= 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
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
- 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.
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.