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:
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.
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:
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:
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.
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
lastAccruefor about2,626,332seconds (≈ 30 days)
When someone finally calls accrueInterest():
expRateis computed as:expRate = wadLn(2e18) / 43,200s = 16045073624072_timeElapsed ≈ 2,626,332swadExp(-int(_expRate * _timeElapsed))returns0(per Solmate’s documented behavior above) as-int(_expRate * _timeElapsed)=-42139690301256263904growthDecay == 0currBorrowRate = _lastRate * 1e18 / 0reverts insideInterestModel.calculateInterest()Lender.accrueInterest()catches the revert and skips accrual without updatinglastAccrue- since
lastAccrueis 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
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
- Set the half-life to 12 hours so the exponential rate is large.
- Keep the system in the below-target free debt ratio branch.
- Leave accrual untouched for about 30 days so the elapsed time is large.
- Call accrueInterest and observe the helper return zero and the division revert.
- 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.