Skip to content
Business logic Audit finding Intermediate

LendingAssetVault incorrectly updates vaultUtilization if CBR for a single FraxlendPair decreases

The LendingAssetVault contract incorrectly calculates the percentage change in a vault's asset/share ratio (CBR) when the ratio decreases, using a formula that overstates the decrease. This can cause users to receive fewer assets than they should, effectively losing funds.

Honour Follow with RampageAudit, TessKimy and 7 others

Originally disclosed on Sherlock

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

Found by

Honour, RampageAudit, TessKimy, X77, cu5t0mPe0, exploitabilityexplorer, future2_22, octopus_testjjj, pkqs90, super_jack

Summary

LendingAssetVault incorrectly updates vaultUtilization if CBR for a single FraxlendPair decreases.

Root Cause

_updateAssetMetadataFromVault() function is used to update the vaultUtilization for a single vault (FraxlendPair). The bug is if the vault's CBR (asset/share ratio) is decreasing, the formula is incorrect.

For example, if the previous vault CBR is 1.5e27, the current is 1e27, the decrease should be (1.5e27 - 1e27) / 1.5e27 = 33%, but currently it is (1.5e27 / 1e27) - 1 = 50%. This is totally wrong, and would result in a lower CBR, which results in users receiving less assets, effectively losing funds.

Another example, if we plug in 1.5e27 -> 0.75e27 (a supposedly 50% decrease), the current formula would end up in a 100% decrease, which means the CBR would end up in zero.

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

Solidity
    function _updateAssetMetadataFromVault(address _vault) internal {
        uint256 _prevVaultCbr = _vaultWhitelistCbr[_vault];
        _vaultWhitelistCbr[_vault] = IERC4626(_vault).convertToAssets(PRECISION);
        if (_prevVaultCbr == 0) {
            return;
        }
        uint256 _vaultAssetRatioChange = _prevVaultCbr > _vaultWhitelistCbr[_vault]
@>          ? ((PRECISION * _prevVaultCbr) / _vaultWhitelistCbr[_vault]) - PRECISION
            : ((PRECISION * _vaultWhitelistCbr[_vault]) / _prevVaultCbr) - PRECISION;

        uint256 _currentAssetsUtilized = vaultUtilization[_vault];
        uint256 _changeUtilizedState = (_currentAssetsUtilized * _vaultAssetRatioChange) / PRECISION;
        vaultUtilization[_vault] = _prevVaultCbr > _vaultWhitelistCbr[_vault]
            ? _currentAssetsUtilized < _changeUtilizedState ? 0 : _currentAssetsUtilized - _changeUtilizedState
            : _currentAssetsUtilized + _changeUtilizedState;
        _totalAssetsUtilized = _totalAssetsUtilized - _currentAssetsUtilized + vaultUtilization[_vault];
        _totalAssets = _totalAssets - _currentAssetsUtilized + vaultUtilization[_vault];
        emit UpdateAssetMetadataFromVault(_vault, _totalAssets, _totalAssetsUtilized);
    }

Internal pre-conditions

  • CBR for a FraxlendPair decreases, e.g. due to bad debt liquidation.

External pre-conditions

N/A

Attack Path

N/A

Impact

Users would receive less assets.

PoC

N/A

Mitigation

Use the correct formula: PRECISION - ((PRECISION * _prevVaultCbr) / _vaultWhitelistCbr[_vault]); for the decreasing scenario.

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 formula for calculating the ratio decrease uses division in the wrong order, computing (previous/current)-1 instead of (previous-current)/previous.

Impact

Users would receive less assets, effectively losing funds.

What the attacker needed

CBR for a FraxlendPair decreases

The fix

Use the correct formula: `PRECISION - ((PRECISION * _prevVaultCbr) / _vaultWhitelistCbr[_vault]);` for the decreasing scenario.

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 tracks how many assets each share is worth, called the CBR. When that value goes down, the code calculates the drop incorrectly, making it seem larger than it is. As a result, users may get less money back than they are owed.

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.