# After the buyOrder is completed, the order creator does not receive the NFT

Debita buyOrder.sellNFT transfers the NFT receipt to the buyOrder contract itself and never forwards it to the order creator, locking the NFT.

- 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/890
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-10-debita%3AH-5
- Tags: area:web3 domain:web3 impact:funds-loss impact:integrity kind:contest platform:sherlock sev:high tech:evm tech:solidity vuln:accounting-error vuln:business-logic

**Target:** buyOrder.sol sellNFT / NFT receipt escrow
**Root cause:** sellNFT transfers the NFT receipt to the buyOrder contract address instead of the order creator; the contract only emits an event and deletes the order without forwarding the NFT.
**Steps:**
1. User A creates a buyOrder.
2. User B approves the receipt to buyOrderContract and calls `sellNFT(receiptID)`.
3. Seller receives buyToken; receipt ownership becomes `address(buyOrderContract)`.
4. Order creator never receives the NFT; assert `receiptContract.ownerOf(receiptID) == address(buyOrderContract)`.
**How found:** Code reading of sellNFT's post-fill flow: noticed the receipt transfer target was the contract itself and no subsequent transfer to the order creator existed, confirmed via fork test asserting ownerOf equals the contract.
**Exploitation:** Any seller fulfilling a buyOrder causes the purchased NFT receipt to be stranded in the buyOrder contract; the buyer pays buyToken but receives nothing, and the NFT is unrecoverable without a fix.
**Insight:** In escrow-style order contracts, trace the asset's final destination after fill logic—ownership landing on the contract address itself (not the counterparty) is a reliable signal of a missing forwarding step.

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

**Foundry test proving NFT stuck in buyOrderContract**

```
function testpoc() public{
        vm.startPrank(seller);
        receiptContract.approve(address(buyOrderContract), receiptID);
        uint balanceBeforeAero = AEROContract.balanceOf(seller);
        address owner = receiptContract.ownerOf(receiptID);
       
        console.log("receipt owner before sell",owner);


        buyOrderContract.sellNFT(receiptID);
        address owner1 = receiptContract.ownerOf(receiptID);
        console.log("receipt owner after sell",owner1);
        //owner = buyOrderContract
        assertEq(owner1,address(buyOrderContract));
        
        
        vm.stopPrank();

    }
```

