Skip to content
DoS Audit finding Intermediate

Interest accrual can get stuck when `wadExp()` underflows to 0 causing division-by-zero

The interest model's exponential decay helper returns zero for very large negative inputs, and the below-target branch then divides by that zero. Because the lender catches the revert and skips updating the last accrual timestamp, interest accrual can stay stuck and paid borrowers stop accruing interest.

0xMosh Follow with 0xShoonya, 0xSpider_Raphl and 34 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2025-12-monolith-stablecoin-factory-judging/issues/1202

Found by

0xMosh, 0xShoonya, 0xSpider_Raphl, 0xeix, 0xlucky, 0xnija, 4vian, Ba17, Cryptek_Megatron, Edoscoba, HeckerTrieuTien, JohnWeb3, MissDida, Proof-of-Spirit, Sir_Shades, Yuubee, algiz, arunabha003, blockace, bratwork, copperscrewer, cosin3, cyberEth, deadmanwalking, dic0de, emmanuel_ewah, flora2627, fullstop, future, heavyw8t, itsgreg, neeloy, slowpoke, tedox, teoslaf1, vivekd, xiaoming90

Summary

N/A

Root Cause

N/A

Internal Pre-conditions

N/A

External Pre-conditions

N/A

Attack Path

The InterestModel.calculateInterest() function computes an exponential factor using Solmate's wadExp() function:

https://github.com/sherlock-audit/2025-12-monolith-stablecoin-factory/blob/main/Monolith/src/InterestModel.sol#L33

Solidity
File: InterestModel.sol
20:     function calculateInterest(
..SNIP..
33:         uint growthDecay = uint(wadExp(-int(_expRate * _timeElapsed)));

Solmate’s wadExp() explicitly returns 0 for sufficiently large negative inputs (-42e18). Refer to the comment below.

Solidity
function wadExp(int256 x) pure returns (int256 r) {
    unchecked {
        // When the result is < 0.5 we return zero. This happens when
        // x <= floor(log(0.5e18) * 1e18) ~ -42e18
        if (x <= -42139678854452767551) return 0;
        ...
    }
}

When _timeElapsed is large enough, -int(_expRate * _timeElapsed) becomes small enough (very negative) that wadExp(...) returns 0, so growthDecay == 0.

In the "below target" branch (_lastFreeDebtRatioBps < _targetFreeDebtRatioStartBps), the code divides by growthDecay in Line 36 below:

https://github.com/sherlock-audit/2025-12-monolith-stablecoin-factory/blob/main/Monolith/src/InterestModel.sol#L36

Solidity
File: InterestModel.sol
20:     function calculateInterest(
..SNIP..
33:         uint growthDecay = uint(wadExp(-int(_expRate * _timeElapsed)));
34:         
35:         if (_lastFreeDebtRatioBps < _targetFreeDebtRatioStartBps) {
36:             currBorrowRate = _lastRate * 1e18 / growthDecay;
37:             interest = _totalPaidDebt * (currBorrowRate - _lastRate) / _expRate / 365 days;
38:         } else if (_lastFreeDebtRatioBps > _targetFreeDebtRatioEndBps) {

So once growthDecay becomes 0, this branch reverts with a division-by-zero.

This revert is caught in Lender.accrueInterest() via try/catch. If enough gas was provided, the catch block does not revert and instead silently skips accrual:

https://github.com/sherlock-audit/2025-12-monolith-stablecoin-factory/blob/main/Monolith/src/Lender.sol#L202

Solidity
File: Lender.sol
try interestModel.calculateInterest(...) returns (...) {
    ... // normal accrual + lastAccrue update
} catch {
    require(gasBefore >= INTEREST_CALCULATION_GAS_REQUIREMENT, "Not enough gas for accrueInterest");
    // No state update here => accrual skipped
}

Because lastAccrue is only updated on the successful path, it stays stale. That means timeElapsed = block.timestamp - lastAccrue remains large, and future calls keep hitting the same wadExp underflow and division-by-zero revert.

In practice, this can create a persistent "interest accrual stuck" state whenever the system stays in the "below target" regime.

Consider the following scenario:

The codebase allows the operator/manager to set halfLife as low as 12 hours (43,200s). Assume that the operator set the halfLife to 12 hours.

https://github.com/sherlock-audit/2025-12-monolith-stablecoin-factory/blob/main/Monolith/src/Lender.sol#L915

Solidity
File: Lender.sol
915:     function setHalfLife(uint64 halfLife) external onlyOperatorOrManager beforeDeadline {
916:         accrueInterest();
917:         require(halfLife >= 12 hours && halfLife <= 30 days, "Invalid half life");
918:         expRate = uint64(uint(wadLn(2*1e18)) / halfLife);
919:         emit HalfLifeUpdated(halfLife);
920:     }

Now assume:

  • The system has mostly/only paid debt so the free debt ratio is below targetFreeDebtRatioStartBps (i.e., it remains in the "below target" branch).
  • No one calls any function that successfully updates lastAccrue for about 2,626,332 seconds (≈ 30 days)

When someone finally calls accrueInterest():

  • expRate is computed as: expRate = wadLn(2e18) / 43,200s = 16045073624072
  • _timeElapsed ≈ 2,626,332s
  • wadExp(-int(_expRate * _timeElapsed)) returns 0 (per Solmate’s documented behavior above) as -int(_expRate * _timeElapsed) = -42139690301256263904
  • growthDecay == 0
  • currBorrowRate = _lastRate * 1e18 / 0 reverts inside InterestModel.calculateInterest()
  • Lender.accrueInterest() catches the revert and skips accrual without updating lastAccrue
  • since lastAccrue is still old, the next call sees the same (or larger) _timeElapsed, and the failure repeats as long as the system remains "below target"

Impact

High. Interest accrual can become effectively DOSed. As a result, paid borrowers stop accruing interest and vault stakers stop receiving yield minted from borrower interest.

In addition, this also violates the stated invariant that interest “must always accrue correctly based on time elapsed and current rate” in the Contest's README.

PoC

No response

Mitigation

No response

The original report as published on Sherlock, by 0xMosh. 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 code does not guard against the exponential helper returning zero before dividing by it, and the catch block leaves the accrual timestamp stale.

Impact

Interest accrual can become effectively unavailable, so paid borrowers stop accruing interest and vault stakers stop receiving yield, as long as the system stays below target.

What the attacker needed

Operator sets a short half-life; system stays below target ratio; about 30 days without successful accrual

How it was found

  1. Set the half-life to 12 hours so the exponential rate is large.
  2. Keep the system in the below-target free debt ratio branch.
  3. Leave accrual untouched for about 30 days so the elapsed time is large.
  4. Call accrueInterest and observe the helper return zero and the division revert.
  5. Observe the catch block skip the accrual and leave the timestamp stale.

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.

The contract uses a maths helper that returns zero when a number gets very negative. Another part of the code then divides by that zero, which makes the transaction fail. The caller catches the failure and quietly does nothing, so the saved timestamp never moves forward and the same failure repeats.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More by 0xMosh

View all

4 more disclosed reports, best first.

More from Monolith Stablecoin Factory

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.