Skip to content
Business logic Audit finding Intermediate

Liquidators Must Supply Collateral Asset Before Redeeming Seized Rewards

Liquidators who seize collateral without previously supplying that asset cannot redeem it because the protocol does not add the asset to their supplied assets list, causing a liquidity check to fail. They must first supply the same asset to redeem their seized rewards.

Brene Follow with Tigerfrake, Uddercover and 10 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2025-05-lend-audit-contest-judging/issues/905

Found by

Brene, Tigerfrake, Uddercover, aman, dreamcoder, dystopia, future, kom, mahdifa, rokinot, t.aksoy, xiaoming90, zraxx

Title

Liquidators Must Supply Collateral Asset Before Redeeming Seized Rewards

Summary

Liquidators can initiate liquidations even if they haven’t previously supplied the asset being liquidated. However, during this process, although their totalInvestment is updated based on the difference between seizeTokens and currentReward, the system does not register the asset as part of their suppliedAssets. This omission causes the liquidator’s collateral balance for the asset to remain at zero. Consequently, when the liquidator tries to redeem the seized collateral, the protocol treats them as having no supplied collateral, causing a failed liquidity check. To redeem, the liquidator is forced to make a fresh supply of the collateral asset, just so the protocol recognizes it as one of their supplied tokens.

Root Cause

In liquidateSeizeUpdate function, the updateTotalInvestment() function updates the totalInvestment mapping for both borrower and liquidator:

Solidity
        // Update total investment
        lendStorage.updateTotalInvestment(
            borrower, lTokenCollateral, lendStorage.totalInvestment(borrower, lTokenCollateral) - seizeTokens
        );

>>      lendStorage.updateTotalInvestment(
            sender,
            lTokenCollateral,
            lendStorage.totalInvestment(sender, lTokenCollateral) + (seizeTokens - currentReward)
        );

However, unlike borrowers who already have the asset recorded in their supplied list, the liquidator’s userSuppliedAssets array remains empty since no action explicitly registers the new asset. This becomes problematic during redemption, which relies on userSuppliedAssets to determine collateral value. The following explain this;

A user calls the redeem function to redeem his investments from the seized tokens, the getHypotheticalAccountLiquidityCollateral() is called to return both borrowed and collateral

Solidity
        // @audit These arrays are empty so far
>>      address[] memory suppliedAssets = userSuppliedAssets[account].values();
>>      address[] memory borrowedAssets = userBorrowedAssets[account].values();

        // First loop: Calculate collateral value from supplied assets
>>      // @audit Will not loop as there is nothing in the array
        for (uint256 i = 0; i < suppliedAssets.length;) {
            ---snip---

            // Add to collateral sum
            vars.sumCollateral =
                mul_ScalarTruncateAddUInt(vars.tokensToDenom, lTokenBalanceInternal, vars.sumCollateral);

            unchecked {
                ++i;
            }
        }

        // Second loop: Calculate borrow value from borrowed assets
        // @audit Will not loop as there is nothing in the array
        for (uint256 i = 0; i < borrowedAssets.length;) {
           ---snip---

            // Add to borrow sum
            vars.sumBorrowPlusEffects =
                mul_ScalarTruncateAddUInt(vars.oraclePrice, totalBorrow, vars.sumBorrowPlusEffects);

            unchecked {
                ++i;
            }
        }

        // Handle effects of current action
>>      // @audit Since address(lTokenModify) != address(0), and `redeemTokens > 0`,
        if (address(lTokenModify) != address(0)) {
            vars.oraclePriceMantissa = UniswapAnchoredViewInterface(priceOracle).getUnderlyingPrice(lTokenModify);
            vars.oraclePrice = Exp({mantissa: vars.oraclePriceMantissa});

            // Add effect of redeeming collateral
            if (redeemTokens > 0) {
                vars.collateralFactor = Exp({
                    mantissa: LendtrollerInterfaceV2(lendtroller).getCollateralFactorMantissa(address(lTokenModify))
                });
                vars.exchangeRate = Exp({mantissa: lTokenModify.exchangeRateStored()});
                vars.tokensToDenom = mul_(mul_(vars.collateralFactor, vars.exchangeRate), vars.oraclePrice);
>>              vars.sumBorrowPlusEffects =
                    mul_ScalarTruncateAddUInt(vars.tokensToDenom, redeemTokens, vars.sumBorrowPlusEffects);
            }

            // Add effect of new borrow
            if (borrowAmount > 0) {
                vars.sumBorrowPlusEffects =
                    mul_ScalarTruncateAddUInt(vars.oraclePrice, borrowAmount, vars.sumBorrowPlusEffects);
            }
        }

>>      return (vars.sumBorrowPlusEffects, vars.sumCollateral);

Then in redeem(), the following check is made:

Solidity
    require(collateral >= borrowed, "Insufficient liquidity");

But since collateral == 0 and borrowed > 0, this reverts.

Internal Pre-conditions

  1. The liquidator had never supplied the asset being seized before initiating the liquidation.
  2. The redeem logic depends on the userSuppliedAssets array to calculate liquidity.
  3. Collateral balance is calculated to be zero, leading to a failed redeem.

External Pre-conditions

None

Attack Path

  1. A user liquidates another user’s position and receives seized collateral.
  2. Since the liquidator hasn’t supplied the collateral asset before, it isn't included in their userSuppliedAssets.
  3. When attempting to redeem, the liquidity check fails as the protocol calculates collateral as zero.
  4. The liquidator cannot redeem unless they first supply the seized token themselves.

Impact

Liquidators encounter a barrier when trying to redeem the collateral they rightfully acquired. Without manually supplying the asset first, they are unable to redeem. This creates unnecessary friction and traps seized rewards unless the liquidator takes an extra, unintuitive step of supplying the token they already received.

POC

  1. In test/TestLiquidations.t.sol, add the following test:
Solidity
    function test_liquidator_must_supply_tokens_to_redeem_reward(uint256 supplyAmount, uint256 borrowAmount, uint256 newPrice) public {
        // Bound inputs to reasonable values
        supplyAmount = bound(supplyAmount, 100e18, 1000e18);
        borrowAmount = bound(borrowAmount, 50e18, supplyAmount * 60 / 100); // Max 60% LTV
        newPrice = bound(newPrice, 1e16, 5e16); // 1-5% of original price

        // Supply token0 as collateral on Chain A
        (address tokenA, address lTokenA) = _supplyA(deployer, supplyAmount, 0);

        // Supply token1 as liquidity on Chain A from random wallet
        (address tokenB, address lTokenB) = _supplyA(address(1), supplyAmount, 1);

        vm.prank(deployer);
        coreRouterA.borrow(borrowAmount, tokenB);

        // Simulate price drop of collateral (tokenA) only on first chain
        priceOracleA.setDirectPrice(tokenA, newPrice);
        // Simulate price drop of collateral (tokenA) only on second chain
        priceOracleB.setDirectPrice(
            lendStorageB.lTokenToUnderlying(lendStorageB.crossChainLTokenMap(lTokenA, block.chainid)), newPrice
        );

        // Attempt liquidation
        vm.startPrank(liquidator);
        ERC20Mock(tokenB).mint(liquidator, borrowAmount);
        IERC20(tokenB).approve(address(coreRouterA), borrowAmount);

        // Expect LiquidateBorrow event
        vm.expectEmit(true, true, true, true);
        emit LiquidateBorrow(liquidator, lTokenB, deployer, lTokenA);

        // Repay 1% of the borrow
        uint256 repayAmount = borrowAmount / 100;

        coreRouterA.liquidateBorrow(deployer, repayAmount, lTokenA, tokenB);
        vm.stopPrank();

        // Verify liquidation was successful
        assertLt(
            lendStorageA.borrowWithInterestSame(deployer, lTokenB),
            borrowAmount,
            "Borrow should be reduced after liquidation"
        );
        
        // retrieve liquidators investment in protocol from seized collateral
        uint256 liquidatorSeizureRewards = lendStorageA.totalInvestment(liquidator, lTokenA);

        // assert that is greater than 0 from liquidation
        assertGt(liquidatorSeizureRewards, 0, "Liquidator should have some seizure rewards");

        // get liquidator supply assets
        address[] memory liquidatorSupplyAssets = lendStorageA.getUserSuppliedAssets(liquidator);

        // should show that no asset was added for him
        assertEq(liquidatorSupplyAssets.length, 0, "Liquidator should have no supply assets");
        
        // Check liquidity for liquidator
        (uint256 borrowed, uint256 collateral) =
            lendStorageA.getHypotheticalAccountLiquidityCollateral(
                liquidator,
                LToken(lTokenA),
                liquidatorSeizureRewards,
                0
            );
        // should show that collateral is 0  and borrowed is positive from Adding effect of 
        // redeemTokens i.e liquidatorSeizureRewards
        assertEq(collateral, 0);
        assertGt(borrowed, 0);
        
        // liquidator attempts to redeem his seized collateral
        vm.startPrank(liquidator);
        // expect revert
        vm.expectRevert(bytes("Insufficient liquidity"));
        coreRouterA.redeem(liquidatorSeizureRewards, payable(lTokenA));

        vm.stopPrank();

        // Now liquidator has to supply some tokens to redeem his reward
        // Supply token0 as collateral on Chain A
        _supplyA(liquidator, supplyAmount, 0);

        // retrieve liquidators current investment
        uint256 liquidatorCurrentInvestment = lendStorageA.totalInvestment(liquidator, lTokenA);

        // assert current investemnt is greater than seized reward
        assertGt(liquidatorCurrentInvestment, liquidatorSeizureRewards);

        // liquidator now attempts to redeem
        vm.prank(liquidator);
        coreRouterA.redeem(liquidatorCurrentInvestment, payable(lTokenA));

        // Now assert that liquidator has 0 investment in protocol
        assertEq(lendStorageA.totalInvestment(liquidator, lTokenA), 0); 
    }
  1. Run: forge test --mt test_liquidator_must_supply_tokens_to_redeem_reward -vvvv

Mitigation

Add this asset to the liquidator:

Diff
        // Update total investment
        lendStorage.updateTotalInvestment(
            borrower, lTokenCollateral, lendStorage.totalInvestment(borrower, lTokenCollateral) - seizeTokens
        );

+       lendStorage.addUserSuppliedAsset(sender, lTokenCollateral);

>>      lendStorage.updateTotalInvestment(
            sender,
            lTokenCollateral,
            lendStorage.totalInvestment(sender, lTokenCollateral) + (seizeTokens - currentReward)
        );

The original report as published on Sherlock, by Brene. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

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

The `liquidateSeizeUpdate` function updates the liquidator's `totalInvestment` but fails to add the seized asset to the liquidator's `userSuppliedAssets` list, so the liquidity calculation ignores it.

Impact

Liquidators cannot redeem seized collateral without first supplying the same asset, trapping their rewards and adding unnecessary friction.

What the attacker needed

Liquidator has not previously supplied the seized asset; redeem logic depends on userSuppliedAssets

The fix

The fix is to add the seized asset to the liquidator's supplied assets list by calling `addUserSuppliedAsset` before updating the total investment.

How it was found

  1. A user liquidates another user's position and receives seized collateral.
  2. Since the liquidator hasn't supplied the collateral asset before, it isn't included in their `userSuppliedAssets`.
  3. When attempting to redeem, the liquidity check fails as the protocol calculates collateral as zero.
  4. The liquidator cannot redeem unless they first supply the seized token themselves.

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.

When someone liquidates a loan, they receive collateral as a reward. But the system forgets to record that they now hold that collateral, so when they try to withdraw it, the system thinks they have nothing and blocks the withdrawal. They have to first deposit some of the same collateral to make the system recognise it.

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 from LEND

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.