Skip to content
Business logic Audit finding Intermediate

Unnecessary computation of lockedCollateral in _addDebt() and _subDebt()

The contract recalculates locked collateral inside two internal debt functions even though a prior sync step already stored the up-to-date value. This is a gas inefficiency, not an exploitable vulnerability, and the report claims no security impact.

algiz Follow

Originally disclosed on Immunefi

Informational View original
  • Disclosed after under an hour

57448 sc insight unnecessary computation of lockedcollateral in adddebt and subdebt

Submitted on Oct 26th 2025 at 10:01:53 UTC by @algiz for Audit Comp | Alchemix V3

Description

Brief/Intro

Locked collateral is computed in both _addDebt() and _subDebt(), although it has already been updated by the _sync()

Vulnerability Details

Both _addDebt() and _subDebt() calculate the locked collateral:

Solidity
uint256 lockedCollateral = convertDebtTokensToYield(account.debt) * minimumCollateralization / FIXED_POINT_SCALAR;

which makes an external call to the Morpho vault.

  • _addDebt() is called from _mint(), which is called in _mint() and _mintFrom()
  • _subDebt() is called from burn(), repay(), _forceRepay() and _doLiquidation() (which is called from _liquidate())

In any of those cases the _sync() function has been called prior, hence the locked collateral has been already calculated and up to date in rawLocked:

Solidity
// Update locked collateral
        account.rawLocked = convertDebtTokensToYield(account.debt) * minimumCollateralization / FIXED_POINT_SCALAR;

Impact Details

Unnecessary calculation with external call that costs additional gas.

References

n/a

Proof of Concept

Proof of Concept

provided in the Impact details section

The original report as published on Immunefi, by algiz. 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

Likely the debt functions recompute locked collateral instead of reusing the value already written to storage by the earlier sync step.

What the attacker needed

None

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 is a program on a blockchain, and every operation costs a small fee called gas. This report points out that the code does the same calculation twice, including a call to another contract, which wastes gas. It is a code-quality note rather than a way for someone to steal funds or break the system.

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 algiz

View all

2 more disclosed reports, best first.

More from Alchemix V3

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.