Skip to content
Business logic Audit finding Intermediate

FraxlendPair.changeFee() doesn’t update interest before changing fee.

The changeFee() function updates the protocol fee without first accruing interest, so when interest is later calculated, the new fee is applied retroactively to the period before the change. This can cause the protocol to receive an incorrect fee amount, potentially higher than intended.

auditor0517 Follow

Originally disclosed on Code4rena

Submitted by auditor0517

This function is changing the protocol fee that is used during interest calculation here.

But it doesn’t update interest before changing the fee so the _feesAmount will be calculated wrongly.

Proof of Concept

As we can see during pause() and unpause(), _addInterest() must be called before any changes.

But with the changeFee(), it doesn’t update interest and the _feesAmount might be calculated wrongly.

Recommended Mitigation Steps

Recommend modifying changeFee() like below.

function changeFee(uint32 _newFee) external whenNotPaused {
    if (msg.sender != TIME_LOCK_ADDRESS) revert OnlyTimeLock();
    if (_newFee > MAX_PROTOCOL_FEE) {
        revert BadProtocolFee();
    }

    _addInterest(); //+++++++++++++++++++++++++++++++++

    currentRateInfo.feeToProtocolRate = _newFee;
    emit ChangeFee(_newFee);
}

DrakeEvans (Frax) confirmed, but disagreed with severity and commented:

Disagree with severity as it can be mitigated by calling addInterest() beforehand by admin or regular user. But we will address it anyway for convenience. We assume admins are not malicious.

0xA5DF (warden) commented:

Admins might not be malicious, but without knowing about the issue (i.e. if the warden hasn’t reported this) they wouldn’t call addInterest() beforehand, leading to higher interest than intended.

gititGoro (judge) commented:

Maintaining severity as it is a potential leakage.


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

Impact

The protocol fee amount could be calculated incorrectly, potentially leading to higher fees than intended for the period before the fee change.

What the attacker needed

Admin changes fee; interest not accrued beforehand

The fix

The changeFee() function should call _addInterest() before updating the fee rate.

How it was found

  1. At time T1, the protocol fee rate is F1.
  2. At time T2, the owner changes the fee to F2 using changeFee().
  3. At time T3, _addInterest() is called during deposit() or another function.
  4. The interest calculation applies F2 to the entire period from T1 to T3, instead of F1 from T1 to T2 and F2 from T2 to T3.

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.

In a lending contract, interest is calculated periodically. The protocol takes a cut of that interest, called a fee. If you change the fee percentage without first calculating the interest owed up to that moment, the new fee gets applied to past interest too, which is unfair. This report points out that the function to change the fee skips that important step.

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 auditor0517

View all

11 more disclosed reports, best first.

More from Frax Ether Liquid Staking 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.