# Lenders and borrowers can not claim liquidation token after NFT collateral auction sold

After an NFT collateral auction sells, the buyer can withdraw the veNFT, burning the receipt; claimCollateralAsNFTLender/Borrower then revert on ownerOf, locking liquidation tokens.

- Payout: Audit contest
- Severity: high
- Program: Debita
- Found by: 0xc0ffEE
- Disclosed: 2024-10-31
- Write-up quality: 7/10
- Original: https://github.com/sherlock-audit/2024-10-debita-judging/issues/156
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-10-debita%3AH-1
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:sherlock sev:high tech:evm tech:solidity technique:source-review vuln:business-logic vuln:dos

**Target:** DebitaV3Loan claimCollateralAsNFTLender / claimCollateralNFTAsBorrower via veNFTAerodrome.getDataByReceipt
**Root cause:** getDataByReceipt calls ownerOf(receiptID) which reverts with ERC721NonexistentToken once the auction buyer withdraws the veNFT and burns the receipt, so claim functions that depend on it revert.
**Steps:**
1. Borrower deposits veNFT via veNFTAerodrome::deposit() and receives a Receipt token
2. Borrower creates borrow offer using the Receipt as collateral; matched with lenders
3. Borrower defaults; lender calls createAuctionForCollateral(0)
4. Auction sells; buyer becomes holder of the Receipt token
5. Buyer calls veNFTVault::withdraw(), which calls burnReceipt(receiptID) and burns the receipt
6. Lender calls claimCollateralAsLender(0) -> getDataByReceipt -> ownerOf(receiptID) reverts ERC721NonexistentToken
**How found:** Code reading of getDataByReceipt's ownerOf call against OpenZeppelin's _requireOwned revert on burned tokens, combined with tracing that veNFTVault::withdraw burns the receipt; confirmed with a fork test expecting revert on claimCollateralAsLender.
**Exploitation:** Auction buyer withdraws the veNFT from the vault, burning the receipt token; subsequent claimCollateralAsNFTLender and claimCollateralNFTAsBorrower calls revert because getDataByReceipt reads ownerOf on the now-nonexistent token, permanently locking liquidation proceeds for lenders and borrower.
**Insight:** When a claim/accounting path reads ERC721 ownerOf for metadata, check whether the token can be burned before the claim executes (e.g. auction buyer withdrawing collateral); prefer try/catch or cached data so post-burn claims don't revert.

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

**Foundry test proving claim reverts after buyer withdraws**

```
function testDefaultAndAuctionCall() public {
        MatchOffers();
        uint256[] memory indexes = allDynamicData.getDynamicUintArray(1);
        indexes[0] = 0;
        vm.warp(block.timestamp + 8640010);
        DebitaV3LoanContract.createAuctionForCollateral(0);
        DutchAuction_veNFT auction = DutchAuction_veNFT(DebitaV3LoanContract.getAuctionData().auctionAddress);
        DutchAuction_veNFT.dutchAuction_INFO memory auctionData = auction.getAuctionData();

        vm.warp(block.timestamp + (86400 * 10) + 1);

        address buyer = 0x5C235931376b21341fA00d8A606e498e1059eCc0;
        deal(AERO, buyer, 100e18);
        vm.startPrank(buyer);

        AEROContract.approve(address(auction), 100e18);
        auction.buyNFT();
        vm.stopPrank();
        address ownerOfNFT = receiptContract.ownerOf(receiptID);


        // buyer withdraws NFT
        vm.startPrank(ownerOfNFT);
        address vaultAddress = receiptContract.s_ReceiptID_to_Vault(receiptID);
        veNFTVault vault = veNFTVault(vaultAddress);
        vault.withdraw();

        // lender claim liquidation token
        vm.stopPrank();
        vm.expectRevert();
        DebitaV3LoanContract.claimCollateralAsLender(0);
    }
```

