Skip to content
Business logic Audit finding Intermediate

`addInterest` will not update the interest acurately which would enable users to claim rewards for time that they weren't staked inside `LendingAssetVault`

The `addInterest` function in `LendingAssetVault` only updates interest when the utilisation rate changes by at least 0.1%, but it uses stale total asset and borrow values, so interest is often not accrued. An attacker can deposit after a period of inactivity, then trigger an update to capture interest earned before their deposit, effectively claiming rewards for time they were not staked.

JohnTPark24 Follow with TessKimy, X77 and 1 other

Originally disclosed on Sherlock

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

Found by

JohnTPark24, TessKimy, X77, pkqs90

Summary

Users would be able to deposit into LendingAssetVault and earn interest on the frax lend pair that was generated before they deposited, i.e. claiming rewards for time that they weren't there. This can be further exploited by MEV bots.

This is due to _updateInterestAndMdInAllVaults updating on rate changes, rather than share value ones.

Root Cause

Notice that there is a difference between the original frax code and the one we have. The difference is that interest is not always added, which would later lead to the issue described bellow:

https://github.com/FraxFinance/fraxlend/blob/main/src/contracts/FraxlendPairCore.sol#L279-L298

Solidity
    function addInterest(...) {
        (, _interestEarned, _feesAmount, _feesShare, _currentRateInfo) = _addInterest();
        if (_returnAccounting) {
            _totalAsset = totalAsset;
            _totalBorrow = totalBorrow;
        }
    }

When we deposit we first call _updateInterestAndMdInAllVaults to update the interest

https://github.com/sherlock-audit/2025-01-peapods-finance/blob/main/contracts/contracts/LendingAssetVault.sol#L106-L110

Solidity
    function deposit(uint256 _assets, address _receiver) external override returns (uint256 _shares) {
        _updateInterestAndMdInAllVaults(address(0));

        // assets * 1e27 / _cbr
        _shares = convertToShares(_assets);

        _deposit(_assets, _shares, _receiver);
    }

_updateInterestAndMdInAllVaults loop trough all of the vault and calls addInterest on each one of them.

https://github.com/sherlock-audit/2025-01-peapods-finance/blob/main/contracts/contracts/LendingAssetVault.sol#L204-L216

Solidity
    function _updateInterestAndMdInAllVaults(address _vaultToExclude) internal {
        uint256 _l = _vaultWhitelistAry.length;

        for (uint256 _i; _i < _l; _i++) {
            address _vault = _vaultWhitelistAry[_i];
            if (_vault == _vaultToExclude) {
                continue;
            }

            (uint256 _interestEarned,,,,,) = IFraxlendPair(_vault).addInterest(false);
            if (_interestEarned > 0) {
                _updateAssetMetadataFromVault(_vault);
            }
        }
    }

Where addInterest would add interest only if the new _rateChange is at least 0.1% bigger than the old one:

https://github.com/sherlock-audit/2025-01-peapods-finance/blob/main/fraxlend/src/contracts/FraxlendPairCore.sol#L286-L325

Solidity
        if (
            _currentUtilizationRate != 0
                && _rateChange < _currentUtilizationRate * minURChangeForExternalAddInterest / UTIL_PREC // 0.1%
        ) {
            emit SkipAddingInterest(_rateChange);
            
        } else {
            (, _interestEarned, _feesAmount, _feesShare, _currentRateInfo) = _addInterest();
        }

However the issue is in how we calculate it. As we use totalAsset, totalBorrow and the assets inside our LendingAssetVault. However both totalAsset, totalBorrow were last updated when there was a deposit, withdraw, borrow, etc... and back then the interest was accrued. Meaning that the only "fresh" value we have are the assets inside our LendingAssetVault, where this call started, and if they were not updated (no deposits/withdraws) then all of the values we used for interest would be outdated.

https://github.com/sherlock-audit/2025-01-peapods-finance/blob/main/fraxlend/src/contracts/FraxlendPairCore.sol#L286-L325

Solidity
    function addInterest(...) external nonReentrant {
        _currentRateInfo = currentRateInfo;

        uint256 _currentUtilizationRate = _prevUtilizationRate;
        uint256 _totalAssetsAvailable = totalAsset.totalAmount(address(externalAssetVault));
        uint256 _newUtilizationRate = _totalAssetsAvailable == 0 
            ? 0 
            // (1e5 * totalBorrow.amount) / _totalAssetsAvailable
            : (UTIL_PREC * totalBorrow.amount) / _totalAssetsAvailable;

        uint256 _rateChange = _newUtilizationRate > _currentUtilizationRate
            ? _newUtilizationRate - _currentUtilizationRate
            : _currentUtilizationRate - _newUtilizationRate;

        if (
            _currentUtilizationRate != 0
                && _rateChange < _currentUtilizationRate * minURChangeForExternalAddInterest / UTIL_PREC // 0.1%
        ) {
            emit SkipAddingInterest(_rateChange);
            
        } else {
            (, _interestEarned, _feesAmount, _feesShare, _currentRateInfo) = _addInterest();
        }
    }

In short this means that we are trying to calculate the new interest change with values that were changed with the last update on interest and never touched afterwards. This of course will lead to the interest being unchanged, as for the only way totalBorrow.amount and totalAsset.amount to increase is if there were any interactions or interest updates.

Internal Pre-conditions

No response

External Pre-conditions

No response

Attack Path

  1. There are no interactions (deposit/withdraw/borrow) with frax lend for a few hours or days
  2. User deposits, but _updateInterestAndMdInAllVaults doesn't update the interest

Now the user can deposits another small amount or performs any other auction that will trigger _updateInterestAndMdInAllVaults to update the interest on all of the vaults, which is possible as the deposit increased _totalAssets, which the vault tracks

The user ca just withdraw, the withdraw will update the interest and thus increase the share value.

Impact

User has claimed rewards for time that he was not staked. This will happen regularly, where the amounts can range from dust to some reasonable MEV money (a couple of bucks).

PoC

No response

Mitigation

Rely on previewAddInterest for if the interest should be worth changing as it would us current numbers and perform the actual math thanks to _calculateInterest.

Solidity
        _newCurrentRateInfo = currentRateInfo;
        // Write return values
        InterestCalculationResults memory _results = _calculateInterest(_newCurrentRateInfo);

The original report as published on Sherlock, by JohnTPark24. 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 interest update check uses outdated total asset and borrow values, so the calculated rate change is often below the threshold and interest is skipped.

Impact

Users can claim rewards for time they were not staked, with amounts ranging from dust to a few dollars, and MEV bots could exploit this regularly.

What the attacker needed

No recent interactions with the frax lend pair; Attacker can deposit and withdraw

The fix

The interest update should rely on `previewAddInterest` to use current numbers and perform the actual interest calculation.

How it was found

  1. Wait for a period with no interactions (deposit, withdraw, borrow) on the frax lend pair.
  2. Deposit into `LendingAssetVault`; the interest update is skipped because the rate change is below the threshold.
  3. Deposit a small amount again or perform another action that triggers `_updateInterestAndMdInAllVaults` to update interest.
  4. Withdraw; the interest is updated and the share value increases, giving the attacker more than they should have.

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.

When you put money into a lending pool, you earn interest over time. The pool should update the interest before you join so you don't get interest from before you deposited. Here, the pool sometimes forgets to update the interest, so a new depositor can get interest that was earned before they arrived, taking money from others.

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 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.