58004 sc high protocol insolvency from cumulativeearmarked during forcerepay
Submitted on Oct 29th 2025 at 23:15:45 UTC by @ihtishamsudo for Audit Comp | Alchemix V3
Report ID: #58004
Report Type: Smart Contract
Report severity: High
Target: https://github.com/alchemix-finance/v3-poc/blob/immunefi_audit/src/AlchemistV3.sol
Impacts:
Protocol insolvency
Description
Brief/Intro
The _forceRepay() internal function in AlchemistV3.sol fails to update the global cumulativeEarmarked state variable when processing forced debt repayments during liquidations, while correctly updating the per-account earmarked debt.
Vulnerability Details
The vulnerability exists in the _forceRepay() function which is called during liquidation operations when underwater accounts have earmarked debt that must be forcibly repaid. Unlike the public repay() function which correctly updates both account-level and global debt tracking, _forceRepay() only updates the account-level earmarked amount without decrementing the global cumulativeEarmarked variable.
function _forceRepay(address accountId, uint256 amount) internal {
Account storage account = accounts[accountId];
// ... validation and debt calculation ...
uint256 earmarkToRemove = amount > account.earmarked ? account.earmarked : amount;
account.earmarked -= earmarkToRemove; //@audit not updating global earmark
// ... rest of function ...
}Impact Details
A permanent discrepancy between individual account debt tracking and the protocol's global debt accounting. causes the protocol to maintain inflated global debt records that never decrease, leading to accounting corruption that compounds with each liquidation. Also breaks the fundamental invariant that cumulativeEarmarked should equal the sum of all account earmarked debts`
References
https://github.com/alchemix-finance/v3-poc/blob/b2e2aba046c36ff5e1db6f40f399e93cd2bdaad0/src/AlchemistV3.sol#L738
Proof of Concept
Proof of Concept
Cooked a poc for it!
Include this test in AlchemistV3.t.sol and execute it with forge test --mt testVulnerability_CumulativeEarmarkedNotUpdatedInForceRepay -vv
Test Logs
Was this helpful?