# Insufficient price validation in transfer_nft function enables theft of listed tokens

transfer_nft in Coded Estate's CosmWasm marketplace pays seller only the recipient's bid, so a buyer can name a bidless recipient and take the NFT for free.

- Payout: Audit contest
- Severity: high
- Program: Coded Estate
- Found by: nnez
- Disclosed: 2024-12-04
- Write-up quality: 7/10
- Original: https://github.com/code-423n4/2024-10-coded-estate-findings/issues/12
- Library page: https://bugbountylibrary.com/r/c4%3A2024-10-coded-estate%3AH-03
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:code4rena sev:high tech:solidity technique:race-window technique:source-review vuln:access-control vuln:business-logic

**Target:** CosmWasm NFT marketplace contract (transfer_nft / setbidtobuy / setlistosell)
**Root cause:** transfer_nft derives payment solely from the recipient's existing bid and never checks it against the seller's listed price; a recipient with no bid yields amount=0 and the transfer still succeeds with no payment.
**Steps:**
1. Seller calls `setlistosell` with price=1000 USDC, auto_approve=true.
2. Buyer calls `setbidtobuy` with 1000 USDC to gain approval.
3. Buyer calls `transfer_nft` with `recipient=attacker1` (no bid on token).
4. Contract sets owner=attacker1, amount defaults to 0, no BankMsg::Send to seller.
5. Buyer cancels bid via `setbidtobuy` with no funds and gets full 1000 USDC refund.
6. Variant: with auto_approve=false, attacker bids then front-runs seller's `transfer_nft` with a bid cancellation; seller's tx executes with amount=0.
**How found:** Code review of transfer_nft: noticed amount initialized to 0 and only set from a matching recipient bid, and that no comparison against token.sell.price exists; hypothesized a bidless recipient bypasses payment.
**Exploitation:** Buyer needs only the listed price in capital (refundable). With auto_approve, bid to obtain approval, transfer to a bidless recipient address, then cancel bid for full refund. Without auto_approve, bid then front-run the seller's transfer_nft with a cancel so the seller's tx pays zero. NFT ends up with attacker, seller receives nothing.
**Insight:** In NFT marketplace finalize functions, payment must be derived from the seller's ask (or validated against it), not from the buyer-supplied recipient's bid record; test transfers to addresses with no bid and to self to expose zero-payment paths.

