58531 sc critical querygraph function zero return bug causing tracking earmarking failure over progressive block intervals

Submitted on Nov 3rd 2025 at 03:21:08 UTC by @Outliers for Audit Comp | Alchemix V3arrow-up-right

  • Report ID: #58531

  • Report Type: Smart Contract

  • Report severity: Critical

  • Target: https://github.com/alchemix-finance/v3-poc/blob/immunefi_audit/src/Transmuter.sol

  • Impacts:

    • Temporary freezing of funds for at least 24 hour

Description

Brief/Intro

Users lock up their debt tokens with the expectation of being repaid over time. However, there is a critical flaw that can bring this entire process to a halt.

The problem lies within the queryGraph function. It contains a condition that returns 0 if the starting and ending blocks are the same. While this may seem logical at first glance, it disrupts the system when _earmark() is called. If _earmark() attempts to retrieve data for a single block (which is a perfectly valid request), queryGraph returns 0. This failure in data retrieval halts the earmarking process, causing the repayment system to freeze.

As a result, users' debts do not get marked for redemption, leading to discrepancies in the system's accounting. This discrepancy makes the total debt appear larger than it should be relative to the synthetic assets. Consequently, users may find themselves repaying more MYT than necessary or may risk being liquidated unfairly.

Vulnerability Details

Let’s examine the problematic code:

The issue arises because the condition <= is too strict. A query for a single block, such as queryGraph(N + 1, N + 1), is a legitimate request; however, this condition incorrectly treats it as invalid and returns 0.

This flaw disrupts the earmarking process here:

When amount is 0, no new debt is earmarked but we update the lastEarmarkBlock to block.number. This leads to a freeze in the repayment process, causing the system's core accounting—such as totalDebt and cumulativeEarmarked—to become desynchronized. These imbalances create a ripple effect throughout the entire system, affecting redemptions and collateral calculations, and may even result in underflow errors during updates.

Impact Details

The immediate effect of this flaw is that the transmuter can freeze, halting redemptions of debts for the affect blocks and throwing the system's accounting into disarray. This leads to a cascade of problems:

  • Broken Accounting: The total debt and synthetic asset supply become misaligned, violating a core system invariant.

  • Unfair Costs for Users: Users may end up repaying more MYT than necessary to clear their debts.

  • Inaccurate Collateral: The calculations for locked collateral become incorrect, which can lead to transaction failures (like underflow errors) or inaccuracies in collateral weights.

References

Proof of Concept

Proof of Concept

Result

Correct state

bug gives a final balance of 199994954957234589041101 , normal state gives 199994955000000000000004

Was this helpful?