Skip to content
Business logic Audit finding Beginner

MintDebt returns a wrong value

The mintDebt function returns the shares amount instead of the assets amount, contradicting its declared return type and documentation. This wrong return value breaks the ERC-4626 invariant that mint functions should return assets.

Bx4 Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

#34959 [SC-Low] `mintDebt` returns a wrong value

Submitted on Sep 1st 2024 at 21:26:18 UTC by @Bx4 for Audit Comp | Acre

Description

Brief/Intro

In `mintDebt` it returns `shares` but it is rather supposed to return assets

Vulnerability Details

In `mintDebt` it returns `shares` as seen below `return shares;` meanwhile it is stated in the function natspec to return assets as seen below `/// @return assets The debt amount in asset taken for the shares minted.` Also, it is seen in the function declaration that it returns assets as shown below ` function mintDebt( uint256 shares, address receiver) public whenNotPaused returns (uint256 assets){} ` However the return statement declared last will overwrite it.

Impact Details

it will return a wrong value and it will break the ERC 4626 invariant because it is stated that mint functions return assets as seen in this link.

References

https://github.com/thesis/acre/blob/c3790ef2d4a5a11ae1cadcdaf72ce538b8d67dd3/solidity/contracts/stBTC.sol#L307

Proof of Concept

Proof of Concept

from the comment(@return) and the return value of the `mintDebt` function below

```solidity /// @return assets The debt amount in asset taken for the shares minted. function mintDebt( uint256 shares, address receiver ) public whenNotPaused returns (uint256 assets) {

...

@-> return shares; } ```

we can deduce that the return value is supposed to be assets and yes in the function declaration it returns `uint256 assets`, However the last return statement will overwrite it and return shares

The original report as published on Immunefi, by Bx4. Images and videos are our own copies; raw HTML is shown as text. View it on Immunefi.

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 function's final return statement returns the variable 'shares' instead of the declared return variable 'assets', overwriting the intended value.

Impact

The function returns a wrong value, which could break the ERC-4626 invariant and cause issues for integrators expecting the correct asset amount.

What the attacker needed

None

The fix

The function should return the correct assets value instead of shares.

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 function is supposed to give back a number representing the amount of assets (like tokens) involved. Instead, it gives back a different number (shares), which can confuse other programs that rely on the correct value.

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 Bx4

View all

4 more disclosed reports, best first.

More from Acre

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.