Skip to content
Business logic Audit finding Intermediate

LendingAssetVault should also call `_updateInterestAndMdInAllVaults()` in multiple functions

Four functions in the LendingAssetVault contract change the vault's asset balance without triggering an interest update across the linked FraxlendPairs. This leaves the interest rate for those pairs inaccurate, since their rates depend on the utilisation rate that in turn depends on the vault's asset amount.

X77 Follow with future2_22 and pkqs90

Originally disclosed on Sherlock

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

Found by

X77, future2_22, pkqs90

Summary

In LendingAssetVault.sol, There are four functions that should call _updateInterestAndMdInAllVaults() when it didn't:

  1. whitelistWithdraw
  2. whitelistDeposit
  3. depositToVault
  4. redeemFromVault

This would lead to inaccurate interest for FraxlendPairs.

Root Cause

_updateInterestAndMdInAllVaults() function is used to trigger an interest update for all FraxlendPairs. Each FraxlendPair's interest rate depends on the utilization rate. The utilization rate depends on the amount of assets within the FraxlendPair and in LVA.

So if the asset amount of the LVA changes, each FraxlendPair should also update their interest.

This is the case for deposit() and withdraw() function of the LVA (_updateInterestAndMdInAllVaults() is always triggered). But there are four more functions that changes amount of LVA assets.

First two is whitelistWithdraw() and whitelistDeposit(). This is used by a single FraxlendPair if assets are transferred between the FraxlendPair and LVA.

Next two is depositToVault() and redeemFromVault(). This is used by the admin to manually transfer assets to and from a FraxlendPair.

All four functions should also call _updateInterestAndMdInAllVaults(), or else the interest for other FraxlendPairs would be inaccurate.

Solidity
    function whitelistWithdraw(uint256 _assetAmt) external override onlyWhitelist {
        address _vault = _msgSender();
        _updateAssetMetadataFromVault(_vault);

        // validate max after doing vault accounting above
        require(totalAvailableAssetsForVault(_vault) >= _assetAmt, "MAX");
        vaultDeposits[_vault] += _assetAmt;
        vaultUtilization[_vault] += _assetAmt;
        _totalAssetsUtilized += _assetAmt;
        IERC20(_asset).safeTransfer(_vault, _assetAmt);
        emit WhitelistWithdraw(_vault, _assetAmt);
    }

    /// @notice The ```whitelistDeposit``` function is called by any whitelisted target vault to deposit assets back into this vault.
    /// @notice need this instead of direct depositing in order to handle accounting for used assets and validation
    /// @param _assetAmt the amount of underlying assets to deposit
    function whitelistDeposit(uint256 _assetAmt) external override onlyWhitelist {
        address _vault = _msgSender();
        _updateAssetMetadataFromVault(_vault);
        vaultDeposits[_vault] -= _assetAmt > vaultDeposits[_vault] ? vaultDeposits[_vault] : _assetAmt;
        vaultUtilization[_vault] -= _assetAmt;
        _totalAssetsUtilized -= _assetAmt;
        IERC20(_asset).safeTransferFrom(_vault, address(this), _assetAmt);
        emit WhitelistDeposit(_vault, _assetAmt);
    }

    function depositToVault(address _vault, uint256 _amountAssets) external onlyOwner {
        require(_amountAssets > 0);
        _updateAssetMetadataFromVault(_vault);
        IERC20(_asset).safeIncreaseAllowance(_vault, _amountAssets);
        uint256 _amountShares = IERC4626(_vault).deposit(_amountAssets, address(this));
        require(totalAvailableAssetsForVault(_vault) >= _amountAssets, "MAX");
        vaultDeposits[_vault] += _amountAssets;
        vaultUtilization[_vault] += _amountAssets;
        _totalAssetsUtilized += _amountAssets;
        emit DepositToVault(_vault, _amountAssets, _amountShares);
    }

    /// @notice The ```redeemFromVault``` function redeems shares from a specific vault
    /// @param _vault The vault to redeem shares from
    /// @param _amountShares The amount of shares to redeem (0 for all)
    function redeemFromVault(address _vault, uint256 _amountShares) external onlyOwner {
        _updateAssetMetadataFromVault(_vault);
        _amountShares = _amountShares == 0 ? IERC20(_vault).balanceOf(address(this)) : _amountShares;
        uint256 _amountAssets = IERC4626(_vault).redeem(_amountShares, address(this), address(this));
        uint256 _redeemAmt = vaultUtilization[_vault] < _amountAssets ? vaultUtilization[_vault] : _amountAssets;
        vaultDeposits[_vault] -= _redeemAmt > vaultDeposits[_vault] ? vaultDeposits[_vault] : _redeemAmt;
        vaultUtilization[_vault] -= _redeemAmt;
        _totalAssetsUtilized -= _redeemAmt;
        emit RedeemFromVault(_vault, _amountShares, _redeemAmt);
    }

Internal pre-conditions

N/A

External pre-conditions

N/A

Attack Path

N/A

Impact

Interest for FraxlendPairs would be inaccurate.

PoC

N/A

Mitigation

Call _updateInterestAndMdInAllVaults() for the above four functions.

The original report as published on Sherlock, by X77. 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 four asset-moving functions update local accounting but omit the call to `_updateInterestAndMdInAllVaults()` that `deposit()` and `withdraw()` make, so dependent FraxlendPairs keep stale interest rates.

Impact

Interest for the FraxlendPairs could be inaccurate after any of the four functions changes the vault's asset amount.

What the attacker needed

Whitelisted vault or owner role

The fix

The four functions should call `_updateInterestAndMdInAllVaults()` so every FraxlendPair recalculates its interest.

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 vault holds assets and lends them to several lending pairs. Each pair's interest rate is calculated from how much of the vault's money is in use, so when the vault's balance changes, every pair needs to recalculate. Here, four functions move money in or out but forget to tell the pairs to recalculate, so the interest rates shown can be wrong.

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 X77

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.