# No one can sell `TaxTokensReceipts` NFT receipt to the buy order

TaxTokensReceipt NFT overrides transferFrom to whitelist only borrow/lend/loan contracts, so selling the receipt to a Buy Order always reverts, breaking limit orders.

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

**Target:** TaxTokensReceipt ERC721 receipt / buyOrder.sellNFT
**Root cause:** TaxTokensReceipt.transferFrom only permits transfers where from/to is a legit BorrowOrder, LendOrder, or Loan contract; the BuyOrder contract is not whitelisted, so transferFrom reverts.
**Steps:**
1. Bob creates a Buy Order wanting TaxTokensReceipt NFT.
2. Alice (holder) calls `buyOrder.sellNFT(receiptID)`.
3. buyOrder.sol L99 calls `IERC721(buyInformation.wantedToken).transferFrom(msg.sender, address(this), receiptID)`.
4. TaxTokensReceipt.transferFrom checks isReceiverAddressDebita/isSenderAddressDebita against borrow/lend/loan factories only.
5. Neither Alice nor BuyOrder is whitelisted -> require reverts 'TaxTokensReceipts: Debita not involved'.
**How found:** Code reading of buyOrder.sellNFT's transferFrom call against the overridden TaxTokensReceipt.transferFrom whitelist, noticing BuyOrder contract absent from the allowed set.
**Insight:** When a receipt/NFT overrides transfer hooks with a protocol-contract allowlist, enumerate every protocol contract that must custody the token (buy orders, aggregators, new modules) and check each against the allowlist; new features silently break.

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

**TaxTokensReceipt transferFrom authorization check**

```
function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public virtual override(ERC721, IERC721) {
        bool isReceiverAddressDebita = IBorrowOrderFactory(borrowOrderFactory)
            .isBorrowOrderLegit(to) ||
            ILendOrderFactory(lendOrderFactory).isLendOrderLegit(to) ||
+						IBuyOrderFactory(buyOrderFactory).isBuyOrderLegit(to) ||
            IAggregator(Aggregator).isSenderALoan(to);
        bool isSenderAddressDebita = IBorrowOrderFactory(borrowOrderFactory)
            .isBorrowOrderLegit(from) ||
            ILendOrderFactory(lendOrderFactory).isLendOrderLegit(from) ||
+						IBuyOrderFactory(buyOrderFactory).isBuyOrderLegit(from) ||
            IAggregator(Aggregator).isSenderALoan(from);
        // Debita not involved --> revert
        require(
            isReceiverAddressDebita || isSenderAddressDebita,
            "TaxTokensReceipts: Debita not involved"
        );
```

