Skip to content
Business logic Audit finding Advanced

Old borrowers steal from new borrowers after redemptions are claimed

When a redemption is claimed, collateral is removed equally from every borrower, but debt is only cleared in proportion to how long each borrower held debt during the redemption period. A borrower who joined late therefore loses collateral without a matching debt reduction, and an older borrower effectively gains at their expense.

arturtoros Follow

Originally disclosed on Immunefi

Critical View original
  • Disclosed after under an hour

57852 sc critical old borrowers steal from new borrowers after redemptions are claimed

Submitted on Oct 29th 2025 at 08:08:37 UTC by @arturtoros for Audit Comp | Alchemix V3

Description

Brief/Intro

After a redemption is claimed in Transmuter.sol, debt is cleared. It is cleared from the people that have had debt while the redemption was passing. The debt to clear is calculated proportionally from two thing -> the amount the user have been borrower ever since the redemption was created to the time it was claimed. Collateral is also decreased from the borrowers, but it is not calculated in the same way, it is equally decreased from everyone, no matter if someone has been borrower the whole time, or they have been borrower for 1 second. So it is unfair for newcomers, because their collateral is decreased, but their debt is not.

Vulnerability Details

In the function _sync(), we have the following:

Solidity
// Collateral to remove from redemptions and fees
        uint256 collateralToRemove = PositionDecay.ScaleByWeightDelta(account.rawLocked, _collateralWeight - account.lastCollateralWeight);
        account.collateralBalance -= collateralToRemove;

_collateralWeight can only increase in redeem() which is called during claiming of redemptions in the Transmuter.sol. So whenever there is a redemption, collateral weight goes up and the collateralToRemove does not actually rely on time the user has been borrower during the redemption's period, it is equally for all borrowers.

When a redemption happens, the protocol decides how much debt (account.debt) to clear from each borrower based on how long they’ve been borrowing during the redemption period.

It compares the current redemption weight (_redemptionWeight) to the previous one (account.lastAccruedRedemptionWeight) to see how much of the redemption period has passed. Then it looks at the user’s exposure (userExposure), which is the part of their debt that hasn’t been earmarked yet.

Using these values, it calculates how much of that user’s debt should be cleared (redeemedTotal). In short, the longer a user has had active debt during the redemption, the more of it gets cleared.

So debt is reduced proportionally to time and exposure, not equally for everyone.

Impact Details

Each time redemption happens, all of the users that have been borrowers for less than the full period of the redemption will lose part of their collateral unfairly, so that's loss of funds for the newcomed borrowers.

Also, their collateralization ratio decreases, and in some cases they could become liquidatable, as their position can become unhealthy.

Proof of Concept

Proof of Concept

Add this test to AlchemistV3.t.sol

Solidity
function testOldBorrowersStealFromNew() external {
        uint256 amount = 100e18;

        // both beef and dad deposit 100e18, but only beef mints 50e18 for now (with a collaterization ratio of 2)
        
        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 tokenIdBeef = AlchemistNFTHelper.getFirstTokenId(address(0xbeef), address(alchemistNFT));
        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 0xbeef
        uint256 tokenIdDad = AlchemistNFTHelper.getFirstTokenId(address(0xdad), address(alchemistNFT));
        alchemist.mint(tokenIdDad, amount / 2, address(0xdad));
        vm.stopPrank();

        // Need to start a transmutator deposit, to start earmarking debt
        vm.startPrank(anotherExternalUser);
        SafeERC20.safeApprove(address(alToken), address(transmuterLogic), amount / 2);
        transmuterLogic.createRedemption(amount / 2);
        vm.stopPrank();

        // the transmutation time has passed but it is not yet claimed
        vm.roll(block.number + 5_256_000);

        // beef mints debt to themselves, again 50e18, so that their collaterization ratio is 2e18
        vm.startPrank(address(0xbeef));
        alchemist.mint(tokenIdBeef, amount / 2, address(0xbeef));
        vm.stopPrank();

        // redemption is claimed
        vm.startPrank(address(anotherExternalUser));
        transmuterLogic.claimRedemption(1);
        vm.stopPrank();


        (uint256 collateralBeef, uint256 debtBeef, uint256 earmarkedBeef) = alchemist.getCDP(tokenIdBeef);
        console.log("collateral beef: ", collateralBeef);
        console.log("debt beef: ", debtBeef);
        console.log("earmarked beef: ", earmarkedBeef);


        (uint256 collateralDad, uint256 debtDad, uint256 earmarkedDad) = alchemist.getCDP(tokenIdDad);
        console.log("collateral dad: ", collateralDad);
        console.log("debt dad: ", debtDad);
        console.log("earmarked dad: ", earmarkedDad);

        // dad can actually withdraw 75e18, although his cleared debt is 50e18 (not 25e18)
        vm.startPrank(address(0xdad));
        alchemist.withdraw(75e18, address(0xdad), tokenIdDad);
        vm.stopPrank();

        // collaterization of Beef has dropped to 1,5e18, because from this redemption his debt was not cleared, but his collateral deposited has decreased
        uint256 collaterizationBeef = alchemist.totalValue(tokenIdBeef) * FIXED_POINT_SCALAR / debtBeef;
        console.log("collaterization of Beef: ", collaterizationBeef);

    }

The original report as published on Immunefi, by arturtoros. 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 collateral reduction in _sync uses only the change in collateral weight, which is applied uniformly to all borrowers, whereas the debt reduction is weighted by each user's time and exposure during the redemption period.

Impact

Late borrowers lose collateral without a matching debt reduction, and their collateralisation ratio can fall far enough to make them liquidatable.

What the attacker needed

A redemption is created and later claimed; borrower joins partway through the period

How it was found

  1. Two users each deposit collateral; only one mints debt initially.
  2. A third user creates a redemption, starting the earmarking of debt.
  3. Time passes without the redemption being claimed.
  4. The first user mints additional debt, becoming a borrower late in the period.
  5. The redemption is claimed, clearing debt proportionally to time borrowed.
  6. The late borrower's collateral is reduced equally, lowering their collateralisation ratio.

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.

In this lending protocol, people lock collateral and borrow against it. When someone redeems, the protocol is meant to reduce everyone's debt and collateral fairly. The bug is that collateral is cut from everyone equally, while debt is only cut for people who were borrowing for the whole period, so newcomers pay for the older borrowers' share.

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 arturtoros

View all

1 more disclosed report, 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.