Skip to content
Business logic Audit finding Advanced

Earmark consumes excess cover, inflating cumulativeEarmarked

The _earmark function advances the transmuter balance pointer to the full current balance even when only part of the observed increase is used as cover, discarding unused cover. This inflates cumulativeEarmarked, reduces liveUnearmarked, and can clamp future earmarks, potentially causing permanent freezing of funds and protocol insolvency.

OxPhantom Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

58522 sc high earmark consumes excess cover inflating cumulativeearmarked

Submitted on Nov 3rd 2025 at 00:36:13 UTC by @OxPhantom for Audit Comp | Alchemix V3

Description

Brief/Intro

_earmark() advances the transmuter balance pointer (lastTransmuterTokenBalance) to the full current balance every call, regardless of how much of the observed balance delta is actually applied as cover to reduce the earmark amount. This prematurely “consumes” future cover, causing unnecessary growth of cumulativeEarmarked, reducing liveUnearmarked, and throttling subsequent earmarks even when the transmuter still holds sufficient MYT to offset future maturations.

Vulnerability Details

Global earmarking computes the matured amount via Transmuter.queryGraph() and offsets it by a “cover” derived from the increase in transmuter MYT balance since the last earmark. However, _earmark() then updates the pointer lastTransmuterTokenBalance to the entire current transmuter balance instead of only accounting for the portion of cover that was actually applied. Any residual, unused cover from the observed delta is effectively discarded for future _earmark() calls.

Relevant flow in AlchemistV3._earmark():

Solidity
// delta of transmuter MYT since last earmark
uint256 transmuterDifference = transmuterCurrentBalance > lastTransmuterTokenBalance
    ? transmuterCurrentBalance - lastTransmuterTokenBalance
    : 0;

// matured amount over [lastEarmarkBlock+1, block.number]
uint256 amount = ITransmuter(transmuter).queryGraph(lastEarmarkBlock + 1, block.number);

// cover computed from delta; amount is reduced by cover
uint256 coverInDebt = convertYieldTokensToDebt(transmuterDifference);
amount = amount > coverInDebt ? amount - coverInDebt : 0;

// BUG: pointer advanced to full current balance, even if only part of the delta was actually applied
lastTransmuterTokenBalance = transmuterCurrentBalance;

By contrast, redeem() advances the pointer only by the cover actually consumed (converted back to yield), which preserves any residual cover for later:

Solidity
// consume the observed cover so it can't be reused, but only the portion actually applied
uint256 usedYield = convertDebtTokensToYield(coverToApplyDebt);
lastTransmuterTokenBalance = transmuterBal > usedYield ? transmuterBal - usedYield : transmuterBal;

Because _earmark() over-advances the pointer, future earmarks do not see the still-available MYT as cover, so amount remains higher than it should be, and cumulativeEarmarked increases unnecessarily. This reduces liveUnearmarked = totalDebt - cumulativeEarmarked, which then clamps future earmarks and distorts weight/survival accounting that depends on these buckets.

Note: Transmuter.claimRedemption() eventually calls setTransmuterTokenBalance() to resync the pointer to the actual transmuter MYT balance after transfers; however, that does not retroactively restore the prematurely “consumed” cover from prior _earmark() calls.

Impact Details

  • Inflates cumulativeEarmarked, shrinking liveUnearmarked = totalDebt - cumulativeEarmarked and clamping subsequent _earmark() amounts.
  • Skews weighting/decay attribution that relies on correct earmarked vs unearmarked bucket sizes, impacting fairness of redemption distribution.

References

https://github.com/alchemix-finance/v3-poc/blob/a192ab313c81ba3ab621d9ca1ee000110fbdd1e9/src/AlchemistV3.sol#L1102C1-L1112

Proof of Concept

Proof of Concept

to run the PoC you can copy paste this code in the IntegrationTest.t.sol test file and run forge test --mt test_transmutterBalance_earmark_PoC

In this PoC, 0xBeef mints 90 alUSD and fully repays his debt. The Transmuter therefore holds 90 yield tokens. Then, 0xDad also mints 90 alUSD and creates a redemption for 45 alUSD. The Transmuter has enough balance, so after the earmark, there is no cumulative earmark — however, the Transmuter’s final balance is set to 90 yield tokens.

After that, 0xDad creates another redemption for 22.5 alUSD. After the earmark, the cumulative earmark is set to 22.5 even though the Transmuter still has enough balance.

Solidity
        function test_transmutterBalance_earmark_PoC() external {
        deal(alUSD, address(0xdad), 0);
        deal(alUSD, address(0xdead), 0);
        uint256 amount = 100e18;
        vm.startPrank(address(0xbeef));
        SafeERC20.safeApprove(address(vault), address(alchemist), amount + 100e18);
        alchemist.deposit(amount, address(0xbeef), 0);
        // a single position nft would have been minted to 0xbeef
        uint256 tokenIdFor0xBeef = AlchemistNFTHelper.getFirstTokenId(address(0xbeef), address(alchemistNFT));

        alchemist.mint(tokenIdFor0xBeef, ((amount *1e18)/ alchemist.minimumCollateralization()), address(0xbeef));
        console.log("balance of beef", IERC20(alUSD).balanceOf(address(0xbeef)));
        vm.roll(block.number + 1);
        SafeERC20.safeApprove(address(vault), address(alchemist), amount + 100e18);

        alchemist.repay(alchemist.convertDebtTokensToYield(amount), tokenIdFor0xBeef);
        vm.stopPrank();
        vm.startPrank(address(0xdad));
        SafeERC20.safeApprove(address(vault), address(alchemist), amount + 100e18);
        alchemist.deposit(amount, address(0xdad), 0);
        // a single position nft would have been minted to 0xdad
        uint256 tokenIdFor0xDad = AlchemistNFTHelper.getFirstTokenId(address(0xdad), address(alchemistNFT));

        alchemist.mint(tokenIdFor0xDad, ((amount *1e18)/ alchemist.minimumCollateralization()), address(0xdad));
        console.log("balance of dad: %18e", IERC20(alUSD).balanceOf(address(0xdad)));

        SafeERC20.safeApprove(address(alUSD), address(transmuterLogic), alchemist.totalSyntheticsIssued());
        transmuterLogic.createRedemption(IERC20(alUSD).balanceOf(address(0xdad))/2);
        vm.roll(block.number + transmuterLogic.timeToTransmute());
        alchemist.poke(tokenIdFor0xDad);
        console.log("\n after first createRedemption: \n cumulativeEarmarked after createRedemption: %18e", alchemist.cumulativeEarmarked());
        console.log("lastTransmuterTokenBalance", alchemist.lastTransmuterTokenBalance());

        transmuterLogic.createRedemption(IERC20(alUSD).balanceOf(address(0xdad))/2);
        vm.roll(block.number + transmuterLogic.timeToTransmute());
        alchemist.poke(tokenIdFor0xDad);
        console.log("\n after second createRedemption: \n cumulativeEarmarked after createRedemption: %18e", alchemist.cumulativeEarmarked());
        console.log("lastTransmuterTokenBalance", alchemist.lastTransmuterTokenBalance());
        vm.stopPrank();
        assertGt(alchemist.cumulativeEarmarked(),0);
        }

The original report as published on Immunefi, by OxPhantom. 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 _earmark function updates lastTransmuterTokenBalance to the entire current balance instead of only the portion of cover actually applied, discarding residual cover.

Impact

This could permanently freeze funds and cause protocol insolvency by inflating cumulativeEarmarked and clamping future earmarks, skewing redemption distribution.

What the attacker needed

None

The fix

The _earmark function should advance lastTransmuterTokenBalance only by the cover actually applied, similar to redeem, to preserve residual cover.

How it was found

  1. 0xBeef mints 90 alUSD and fully repays debt, leaving 90 yield tokens in Transmuter.
  2. 0xDad mints 90 alUSD and creates a redemption for 45 alUSD; after earmark, cumulative earmark is zero but Transmuter balance is set to 90 yield tokens.
  3. 0xDad creates another redemption for 22.5 alUSD; after earmark, cumulative earmark becomes 22.5 despite sufficient Transmuter balance.

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 protocol tracks how much debt is 'earmarked' for future redemptions. It uses a pointer to remember the last balance of a token so it can calculate new cover. The bug is that the pointer is moved too far forward, so some cover is lost and the earmarked amount grows incorrectly, which can lock funds.

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 OxPhantom

View all

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