Skip to content
Business logic Audit finding Advanced

Insufficient Decimal

Interest accrual in the lending pool rounds down when the calculated interest is smaller than one unit of the asset, so frequent index updates can record no interest at all. An attacker could repeatedly deposit and redeem small amounts to force frequent updates, reducing or eliminating the profit owed to depositors.

future2_22 Follow

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2025-02-yieldoor-judging/issues/190

Found by

future2_22

Summary

The decimal precision of the collateral is insufficient for calculating the interest, especially for wbtc.

Root Cause

In ReserveLogic::_updateIndexes::L156, the totalBorrows may not update or may experience precision loss. https://github.com/sherlock-audit/2025-02-yieldoor/blob/main/yieldoor/src/libraries/ReserveLogic.sol#L156

Solidity
156:        newTotalBorrows = newBorrowingIndex * (reserve.totalBorrows) / (reserve.borrowingIndex);

To change the totalBorrows, the unaccounted interest must be equal to or greater than 1 wei. To avoid precision loss, the interest must exceed 10,000 wei. If the collateral is wbtc, this value is not small. And the _updateIndexes function could be executed every block(period = 15s), and the unaccounted interest may be less than the above value.

Internal pre-conditions

N/A

External pre-conditions

N/A

Attack Path

An attacker can repeatedly deposit 1001 wei of wbtc and redeem the maximum amount of wbtc (type(uint256).max). Alternatively, users can interact with the LendingPool frequently

PoC

Let's consider the following scenario. LendingPool's asset = wbtc, BorrowingRateConfig: (0%, 0%) -> (80%, 20%) -> (90%, 50%) -> (100%, 150%) totalLiquidityAndBorrows = 0.25 wbtc, totalBorrows = 0.126144 wbtc currentUtilizationRate = 50.4576%, https://github.com/sherlock-audit/2025-02-yieldoor/blob/main/yieldoor/src/libraries/InterestRateUtils.sol#L28 currentBorrowingRate = 50.4576% * 20% / 80% = 12.6144% https://github.com/sherlock-audit/2025-02-yieldoor/blob/main/yieldoor/src/libraries/InterestRateUtils.sol#L73 rate = 12.6144% = 0.126144e27, currentTimestamp = lastUpdateTimestamp + 15. ratePerSecond = rate / SECONDS_PER_YEAR = 4e18 basePowerTwo = ratePerSecond * ratePerSecond / PRECISION = 16e9 basePowerThree = 64 secondTerm = exp * expMinusOne * basePowerTwo / 2 = 15 * 14 * 16e9 = 3360e9 thirdTerm = exp * expMinusOne * expMinusTwo * basePowerThree / 6 = 15 * 14 * 13 * 64 / 6 = 29120 CompoundedInterest = (PRECISION) + (ratePerSecond * exp) + (secondTerm) + (thirdTerm) = = 1e27 + 4e18 * 15 + 3360e9 + 29120 = 1e27 + 60e18 + 3360e9 + 29120 < 1e27 + 60.1e18 https://github.com/sherlock-audit/2025-02-yieldoor/blob/main/yieldoor/src/libraries/ReserveLogic.sol#L115 latestBorrowingIndex = reserve.borrowingIndex * calculateCompoundedInterest / 1e27 < reserve.borrowingIndex * (1e27 + 60.1e18) / 1e27 https://github.com/sherlock-audit/2025-02-yieldoor/blob/main/yieldoor/src/libraries/ReserveLogic.sol#L156 newTotalBorrows = latestBorrowingIndex * (reserve.totalBorrows) / (reserve.borrowingIndex) < < (reserve.borrowingIndex * (1e27 + 60.1e18) / 1e27) * (reserve.totalBorrows) / (reserve.borrowingIndex) = = (1e27 + 60.1e18) / 1e27 * (reserve.totalBorrows) = = reserve.totalBorrows + 60.1e-9 * 0.126144e8 < < reserve.totalBorrows + 1; Therefore, newTotalBorrows = reserve.totalBorrows

Impact

The depositor of the LendingPool may not be able to take any profits at all or may receive reduced profits.

When BorrowingRateConfig := (0%, 0%) -> (80%, 20%) -> (90%, 50%) -> (100%, 150%),

  1. LendingPool's asset = wbtc, totalLiquidityAndBorrows = 0.25 wbtc, totalBorrows = 0.126144 wbtc

If the _updateIndexes function is executed every block, the interest is not collected. If it is executed every 100 blocks (25 mins), the calculation of interest experiences 1% precision loss.

  1. LendingPool's asset = wbtc, totalLiquidityAndBorrows = 25 wbtc, totalBorrows = 12.6144 wbtc

If the _updateIndexes function is excuted every 100 block (25 mins), the calculation of interest experiences 0.01% precision loss.

  1. LendingPool's asset = usdc, totalLiquidityAndBorrows = 250,000 usdc, totalBorrows = 126,144 usdc

If the _updateIndexes function is excuted every block, the calculation of interest experiences 0.01% precision loss.

Mitigation

Consider increasing the decimal precision of the collateral.

The original report as published on Sherlock, by future2_22. 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 integer division in the interest index update truncates the accrued interest to zero whenever it is below one unit of the asset's smallest denomination.

Impact

Depositors may earn no profit or reduced profit, with precision loss of about 1% when updates happen every 25 minutes for a small wbtc pool.

What the attacker needed

A lending pool with a low-decimal asset such as wbtc; ability to deposit and redeem repeatedly

The fix

The report suggests increasing the decimal precision used for the collateral so small interest amounts are not truncated away.

How it was found

  1. An attacker repeatedly deposits a small amount of wbtc into the lending pool.
  2. The attacker redeems the maximum amount, which triggers the index update each time.
  3. Each update recalculates total borrows with truncated interest, so no interest is recorded.
  4. Depositors end up with reduced or zero profit from the pool.

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 lending pool tracks how much interest borrowers owe. The maths keeps only whole units of the asset, so tiny amounts of interest get thrown away each time it recalculates. If someone triggers that recalculation very often, the thrown-away amounts add up and savers earn less 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 from Yieldoor

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.