Skip to content
Business logic Audit finding Intermediate

Malicious Lenders can Increase the Interest owed by Borrowers Due to Wrong `UtilizationRate` Calculation

The utilization rate calculation in a Fraxlend pair was wrong, using borrowed tokens divided by available (unborrowed) tokens instead of borrowed divided by total assets. A malicious lender could repeatedly call the interest update function to inflate the interest owed by borrowers by more than 10% per day.

Honour Follow with X77, future2_22 and 3 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2025-01-peapods-finance-judging/issues/331

Found by

Honour, X77, future2_22, octopus_testjjj, prosper, uuzall

Summary

The UtilizationRate is used to calculate the percentage of utilization of a specific Fraxlend Pair. This utilization is then used to calculate interest rates which are charged to the borrowers of the platform. Since the formula to calculate one of the utilization rates is wrong, it triggers the _addInterest function when it is not supposed to, causing malicious lenders to keep calling the function to inflate the interest of borrowers.

The protocol team confirmed that the utilization rate needs to be the ratio of total borrowed tokens to the total borrowed + un-borrowed tokens in the contract.

Currently, one of the utilization rate is calculated as the ratio between the total borrowed tokens to the total un-borrowed tokens.

A malicious lender can increase the interest of a borrower by more than 10% every single day by doing this.

Root Cause

In the _addInterest function the calculation for the utilization rate of the Fraxlend Pair is wrong due to the following reason:

The utilization rate is calculated as shown below:

Solidity
uint256 _totalAssetsAvailable = _totalAssetAvailable(totalAsset, totalBorrow, true);
_prevUtilizationRate = _totalAssetsAvailable == 0 ? 0 : (UTIL_PREC * totalBorrow.amount) / _totalAssetsAvailable;

The first line gets the _totalAssetsAvailable from the following function shown below:

Solidity
function _totalAssetAvailable(VaultAccount memory _totalAsset, VaultAccount memory _totalBorrow, bool _includeVault)
  internal
  view
  returns (uint256)
  {
    if (_includeVault) {
    return _totalAsset.totalAmount(address(externalAssetVault)) - _totalBorrow.amount;
  }
        ...

Here, the total asset in the contract plus the ones in the vault is subtracted by the total amount that is borrowed from the contract.

If we take this into consideration, the formula for the Utilization Rate becomes:

$$UtilizationRate = \frac{totalBorrow.amount}{totalAmountOfAssets - totalAssetsBorrowed}$$

Hence, the utilization rate becomes the ratio between total borrowed amount to total assets that are currently available in the contract to be lent out. This was communicated with the protocol and they agree that this is the wrong formula.

The correct equation should be the ratio between total borrowed amount to the total borrowed + un-borrowed amount in the pair.

Let's look at an example to understand this better,

Let's take a Pair of tokens X asset, and Y collateral.

  • We have 100 X assets, and 100 Y collateral.
  • 50 X assets have been borrowed by Alice.
  • Now the pair has 50 X assets, and 100 Y collateral.

Let's calculate the utilization rate:

Current Formula:

$$UtilizationRate = \frac{totalBorrow.amount}{totalAmountOfAssets - totalAssetsBorrowed} = \frac{50}{100-50} = 1.0$$

This gives a 100% utilization rate.

Corrected Formula:

$$UtilizationRate = \frac{totalBorrow.amount}{totalAmountOfAssets} = \frac{50}{100} = 0.5$$

This gives a 50% utilization rate.

In this example, the rate change is 100-50 = 50%, so it can trigger interest accrual even when it is not required. To understand the full impact of this error, we need to know the different types of interest a user can create for their Pairs of token.

  1. Linear Interest Rate: This interest is a simple linear interest following the equation y = mx + c, it has a vertex utilization after which the interest rate increases more rapidly.
  2. Variable Interest Rate: This interest is a more complicated interest rate that changes the vertex and max interest dynamically with the utilization.

The problem occurs because if you call the addInterest function and update the interest rates when it is not required, you can steal more interest from the borrowers than necessary. This is shown in the Attack Path section below.

Internal Pre-conditions

A Fraxlend Pair is created.

External Pre-conditions

A user calls the addInterest function to update the interest states.

Attack Path

  1. A FraxLend Pair is created with a variable interest rate with 60 MIN_TARGET_UTIL, and 70 MAX_TARGET_UTIL. Interest rate of 1% minimum, 2% vertex, and 15% maximum.
  2. 100 assets are deposited and 50 are loaned out to borrowers.
  3. Nothing changes, and the user calls addInterest to update interest rates. This can be called every block.

From this point forward, lets look at the current method and the correct method to check state changes:

Current: Everyday the function is called with no change in utilization: The function calculates the current full utilization rate by:

Solidity
function getFullUtilizationInterest(uint256 _deltaTime, uint256 _utilization, uint64 _fullUtilizationInterest)
        ...
        if (_utilization < MIN_TARGET_UTIL) {
            // 18 decimals
            uint256 _deltaUtilization = ((MIN_TARGET_UTIL - _utilization) * 1e18) / MIN_TARGET_UTIL;
            // 36 decimals
            uint256 _decayGrowth = (RATE_HALF_LIFE * 1e36) + (_deltaUtilization * _deltaUtilization * _deltaTime);
            // 18 decimals
            _newFullUtilizationInterest = uint64((_fullUtilizationInterest * (RATE_HALF_LIFE * 1e36)) / _decayGrowth);
        }

For our situation, we will get _newFullUtilizationInterest = 0.14210526315789473.

And using this they calculate the _newRatePerSec:

Solidity
uint256 _vertexInterest =
            (((_newFullUtilizationInterest - ZERO_UTIL_RATE) * VERTEX_RATE_PERCENT) / RATE_PREC) + ZERO_UTIL_RATE;
        if (_utilization < VERTEX_UTILIZATION) {
            // 18 decimals
            _newRatePerSec =
                uint64(ZERO_UTIL_RATE + (_utilization * (_vertexInterest - ZERO_UTIL_RATE)) / VERTEX_UTILIZATION);

Which will give us _newRatePerSec = 0.02048454469507101. This will be used to calculate the interest for each borrower and the interest is charged.

If you call this daily for 30 days, the _newRatePerSec will decrease slowly as shown below:

Bash
0.02048454469507101
0.019890955458822496
...
0.011688161515964891
0.011557539815458803

On average, a person will pay 0.014938491983740592 or 1.4938% interest.

Correct: In the correct implementation of this hypothetical situation, the borrowers will only need to pay interest once in the 30 days at the end if utilization changes, giving them quite a lot less interest of 0.013670634920634922 or 1.367%.

In this example alone, the borrower had to pay 0.1268% interest more than they are required.

Another situation can be created for a utilization rate that is greater than the vertex utilization rate. When that is done, the interest rate increases from 12.250% to 22.89% in a single day. This can negatively affect the borrowers too, even though there is no change in utilization. Ideally, the utilization will decrease and the interest rate will decrease sequentially, but that will not happen if the utilization remains the same even for a block because the addInterest function can be called every block.

Impact

This wrong calculation is only used in the calculation of _prevUtilizationRate. This variable is only used in the addInterest function to calculate whether the interest needs to be updated or not:

Solidity
uint256 _currentUtilizationRate = _prevUtilizationRate;
uint256 _totalAssetsAvailable = totalAsset.totalAmount(address(externalAssetVault));
uint256 _newUtilizationRate =
    _totalAssetsAvailable == 0 ? 0 : (UTIL_PREC * totalBorrow.amount) / _totalAssetsAvailable;
@> uint256 _rateChange = _newUtilizationRate > _currentUtilizationRate
    ? _newUtilizationRate - _currentUtilizationRate
    : _currentUtilizationRate - _newUtilizationRate;
if (
    _currentUtilizationRate != 0
        && _rateChange < _currentUtilizationRate * minURChangeForExternalAddInterest / UTIL_PREC
) {
    emit SkipAddingInterest(_rateChange);
} else {
    (, _interestEarned, _feesAmount, _feesShare, _currentRateInfo) = _addInterest();
}

Due to this, lender can maliciously call the addInterest function to increase the amount of interest the borrowers have to pay. They can call the function every block and increase the interest.

PoC

No response

Mitigation

No response

The original report as published on Sherlock, by Honour. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

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

Likely the utilization rate was computed as borrowed amount divided by available (unborrowed) assets, rather than borrowed divided by total assets, so the rate was overstated and triggered unnecessary interest updates.

Impact

A malicious lender could increase the interest owed by borrowers by more than 10% per day, and in some cases the interest rate could jump from 12.25% to 22.89% in a single day, even without any change in utilization.

What the attacker needed

A Fraxlend pair exists; Attacker is a lender in the pair; Attacker can call addInterest frequently

The fix

The utilization rate should be calculated as the ratio of total borrowed tokens to the total of borrowed plus unborrowed tokens, as confirmed by the protocol team.

How it was found

  1. Create a Fraxlend pair with a variable interest rate and specific target utilization parameters.
  2. Deposit assets and loan out a portion to borrowers.
  3. Call the addInterest function repeatedly (every block) even when utilization has not changed.
  4. Observe that the interest rate and borrower interest increase due to the incorrect utilization calculation.

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 pool, the interest rate depends on how much of the pool is borrowed (utilization). The code calculated this percentage incorrectly, making it look higher than it really was. Because of that, someone could keep triggering an interest update even when nothing changed, causing borrowers to pay more interest than they should.

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 Honour

View all

6 more disclosed reports, best first.

More from Peapods

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.