# setbidtobuy allows token purchase even when sale is no longer listed

setbidtobuy in Coded Estate's CosmWasm NFT contract ignores the sell.islisted flag, letting buyers purchase tokens the seller delisted when auto-approve is enabled.

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

**Target:** CosmWasm NFT marketplace contract (setbidtobuy / setlistforsell)
**Root cause:** setbidtobuy never checks token.sell.islisted before accepting a bid and granting approval, so delisting via setlistforsell(islisted=false) has no effect on purchases.
**Steps:**
1. Seller calls `SetListForSell{islisted:true, price:1000, denom:USDC, auto_approve:true}`
2. Seller delists via `SetListForSell{islisted:false, ...}` leaving auto_approve true
3. Attacker calls `SetBidToBuy{token_id}` with `1000 USDC` funds
4. auto_approve grants attacker approval; attacker calls `TransferNft{recipient:attacker}` to take ownership
**How found:** Code review of setbidtobuy versus setlistforsell: noticed islisted is written but never read in the buy path, and that delisting is the only way to halt a sale (no dedicated unlist function as in rental flows).
**Exploitation:** Attacker sends a bid matching price/denom on a delisted token; because auto_approve remains true and islisted is unchecked, the contract pushes an approval for the attacker, who then calls TransferNft to seize the NFT against the seller's intent.
**Insight:** When a listing struct has a boolean state flag, grep every consumer of that struct for reads of the flag; state written by one entrypoint but never enforced in the purchase/approval path is a recurring marketplace bug, especially where auto-approve short-circuits seller consent.

