Skip to content
Business logic Audit finding Intermediate

Incorrect totalVolumeOfBorrowersAmountinWei update in withdraw()

The withdraw function deducts the deposited amount in the asset's own units (e.g., wrsETH) from a total that is meant to be in Ether, so the total becomes too high. This makes all calculations that rely on that total, such as the CDS cumulative value, incorrect, potentially causing CDS owners to receive more or less than they should.

0x37 Follow with 0xAadi, CL001 and 2 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2024-11-autonomint-judging/issues/375

Found by

0x37, 0xAadi, CL001, Cybrid, John44

Summary

In withdraw, we should deduct depositedAmountInETH not depositedAmount from the totalVolumeOfBorrowersAmountinWei.

Root Cause

When borrowers withdraw collateral, we will update totalVolumeOfBorrowersAmountinWei. The totalVolumeOfBorrowersAmountinWei is the total collateral amount in term of Ether. When borrowers withdraw collateral, we should deduct the related amount in Ether from the totalVolumeOfBorrowersAmountinWei.

The problem is that we use depositDetail.depositedAmount. The depositDetail.depositedAmount means this deposit's collateral amount, maybe Ether's amount, or WrsETH amount. This will cause that if this borrower's deposit asset is not Ether, e.g. WrsETH, we will deduct less amount from totalVolumeOfBorrowersAmountinWei than expected.

This will cause all calculations related with totalVolumeOfBorrowersAmountinWei will be incorrect.

Solidity
omniChainData.totalVolumeOfBorrowersAmountinWei -= depositDetail.depositedAmount;
Solidity
    function deposit(
        IBorrowing.BorrowLibDeposit_Params memory libParams,
        IBorrowing.BorrowDepositParams memory params,
        IBorrowing.Interfaces memory interfaces,
        mapping(IBorrowing.AssetName => address assetAddress) storage assetAddress
    ) public returns (uint256) {
        uint256 depositingAmount = params.depositingAmount;
        ...
        depositDetail.depositedAmount = uint128(depositingAmount);
}

Internal pre-conditions

N/A

External pre-conditions

N/A

Attack Path

N/A

Impact

After borrowers withdraw non-Ether collateral(weETH, wrsETH), the totalVolumeOfBorrowersAmountinWei will be incorrect. This will cause all calculations related with totalVolumeOfBorrowersAmountinWei will be incorrect. For example: cds's cumulativeValue will be calculated incorrectly.

Solidity
        CalculateValueResult memory result = _calculateCumulativeValue(
            omniChainData.totalVolumeOfBorrowersAmountinWei,
            omniChainData.totalCdsDepositedAmount,
            ethPrice // current ether price.
        );

CDS owners can get more or less than expected.

PoC

N/A

Mitigation

Deduct depositedAmountInETH from totalVolumeOfBorrowersAmountinWei when users withdraw collateral.

The original report as published on Sherlock, by 0x37. 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

The withdraw function subtracts depositDetail.depositedAmount (which may be in a non-Ether asset's units) from totalVolumeOfBorrowersAmountinWei, which is meant to be an Ether-denominated total, instead of subtracting the Ether-equivalent amount.

Impact

After borrowers withdraw non-Ether collateral, the total volume becomes incorrect, causing all related calculations (such as CDS cumulative value) to be wrong, so CDS owners could get more or less than expected.

What the attacker needed

Borrower deposits non-Ether collateral; borrower withdraws that collateral

The fix

The withdraw function should deduct depositedAmountInETH from totalVolumeOfBorrowersAmountinWei instead of depositedAmount.

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 smart contract keeps a running total of all collateral, but it is supposed to be measured in Ether. When someone withdraws collateral that is not Ether, the code subtracts the raw amount of that other token instead of its Ether value. This leaves the total too high, so later calculations that use it give wrong results.

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

View all

79 more disclosed reports, best first.

More from Autonomint Colored Dollar V1

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.