58799 sc high forcerepay does not reduce cumulativeearmarked which leads to wrong accounting users debts are incorrectly higher which can cause wrongful liquidations

Submitted on Nov 4th 2025 at 13:57:39 UTC by @x0xmechanic for Audit Comp | Alchemix V3arrow-up-right

  • Report ID: #58799

  • Report Type: Smart Contract

  • Report severity: High

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

  • Impacts:

    • Theft of unclaimed yield

Description

Brief/Intro

cumulativeEarmarked is not reduced in _forceRepay when a user gets liquidated, even though the user's own earmarked debt was properly reduced. This causes wrong global accounting which reflects in how users' debts are calculated: they stay higher than they should be, leading to wrongful liquidations and loss of users funds.

Vulnerability Details

_forceRepay() clears a user’s local earmark but never adjusts the global earmark counter cumulativeEarmarked. This desynchronizes per-account vs global bookkeeping and poisons subsequent earmark/redemption math.

Key lines:

// forceRepay: local removal only
uint256 earmarkToRemove = credit > account.earmarked ? account.earmarked : credit;
account.earmarked -= earmarkToRemove;          // LOCAL ONLY
// ...no write to cumulativeEarmarked

Contrast with _earmark() which increases the global counter:

Impact Details

  • Users who should receive redemption credit (earmarked yield used to reduce their debt) don’t receive it because cumulativeEarmarked is overstated. positions can appear more undercollateralized than reality (debt not decaying as it should), leading to premature/extra liquidations and lost fee rebates.

References

Add any relevant links to documentation or code

Proof of Concept

Proof of Concept

We show the bug with two users who deposit and mint in the alchemist. One user gets liquidated and his earmarked debt goes to zero, while the cumulative earmarked does not change before and after the liquidation. The other user's debt also does not change.

Was this helpful?