Reproduced Exploit

Debita: a filled buy order never delivers the NFT to its creator

The creator escrows 1000 AERO in a buy order. The seller calls sellNFT. The receipt is transferred to the order contract, the seller receives the AERO, and the order deletes creator. Nothing sends the NFT to the person who paid. ownerOf is the order. The creator's AERO balance is zero.

Nov 2024•Ethereum•logic•3 min read

Loss

Creator paid 1000 AERO. The receipt NFT is owned by the buy-order contract

Chain

Ethereum

Category

logic

Date

Nov 2024

Source

AuditVault

EVM Playground

Source-level debugger — step opcodes and Solidity in sync

evm-hack-analyzer

The attack is replayed in an in-browser EVM preloaded with the exact dumped fork state. The execution tree shows every call; step by Solidity line or by opcode across all depths — source, Stack, Memory, Storage, Balances (native / ERC-20 / NFT), Transient storage and Return value stay in sync. Click a tree node, opcode, or source line to jump. Query opens a search over the trace: previous and next writes, balance changes and calls, breakpoints, and a diff of everything that changed between two steps. No backend, no live RPC.

Loading fork state…

Source & credit. Reproduction of a public audit finding curated by AuditVault — the original finding: 44228-h-5-after-the-buyorder-is-completed-the-order-creator-does-n. Standalone Foundry PoC and full write-up: 44228-h-5-after-the-buyorder-is-completed-the-order-creator-does-n_exp in the evm-hack-registry mirror.


Vulnerability classes: vuln/logic/incorrect-state-transition · vuln/logic/missing-check

Key info#

FieldValue
LossCreator paid 1000 AERO. The receipt NFT is owned by the buy-order contract
Vulnerable contractBuyOrder.sellNFT
Attacker EOA0x1111111111111111111111111111111111111111
Attack contractExploit
Attack txExploit.run()
Chain / block / dateEthereum model · block 0 · 2024-11
Compilersolc 0.8.27, cancun
Bug classNFT is transferred to the order and the order is then deleted

TL;DR#

The creator escrows 1000 AERO in a buy order. The seller calls sellNFT. The receipt is transferred to the order contract, the seller receives the AERO, and the order deletes creator. Nothing sends the NFT to the person who paid. ownerOf is the order. The creator's AERO balance is zero.

Background#

Sherlock's November 2024 Debita Finance V3 contest, issue 890, reported by newspacexyz and many others. sellNFT in buyOrder.sol at commit 1465ba6 transfers the NFT to the order. The order emits and deletes the order. It does not transfer the NFT to the creator. The report's fork test logs the owner changing from the seller to the buy-order contract.

The vulnerable code#

SOLIDITY
function sellNFT(uint256 receiptID) external {
    require(active, "no order");
    nft.transferFrom(msg.sender, address(this), receiptID); // @> VULN: NFT is delivered to the order contract, not the creator
    // FIX: nft.transferFrom(msg.sender, creator, receiptID);
    aero.transfer(msg.sender, price);
    active = false;
    creator = address(0);
    emit OrderFilled(receiptID);
}

sellNFTFixed captures creator before the delete and transfers the NFT there. The control test asserts that owner.

Root cause#

The fill pays the seller and then forgets the buyer. The NFT's destination is address(this), and the only stored buyer is cleared in the same function. There is no later withdrawal.

Preconditions#

  • The creator has opened a buy order and escrowed 1000 AERO.
  • The seller owns receipt id 1 and has approved the order.

Attack walkthrough#

  1. The creator approves and calls createBuyOrder. Their AERO balance becomes zero and the order records them.
  2. The seller calls sellNFT(1).
  3. transferFrom moves the NFT to the order.
  4. The order pays 1000 AERO to the seller.
  5. creator is set to the zero address and active is cleared.
  6. ownerOf(1) is the order. The creator still has no AERO and no NFT.

Diagrams#

flowchart TD A["Creator escrows 1000 AERO"] --> B["Seller calls sellNFT"] B --> C["VULN NFT is transferred to the order"] C --> D["Seller receives the 1000 AERO"] D --> E["Order deletes the creator"] E --> F["Receipt stays in the order and the creator holds nothing"]

Impact#

The creator paid 1000 AERO for a receipt they do not own. The seller was paid. The NFT is stuck in a contract whose order record has been deleted, so the buyer cannot claim it. That is the loss the report states: the buy-order creator loses the NFT.

Remediation#

Transfer the NFT to creator before clearing the order. The control path does that and the creator becomes ownerOf.

How to reproduce#

BASH
cd 44228-h-5-after-the-buyorder-is-completed-the-order-creator-does-n_exp
forge test -vv

test_creator_does_not_receive_nft asserts the order owns the NFT, the seller holds 1000 AERO, and the creator holds zero. test_control_fixed_delivers_nft_to_creator asserts the fixed transfer. Captured output is output.txt.

Sources#


Sources & further analysis#

Reproductions & code

Alerts & third-party analyses

  • Web3Sec X hacked database: search.
  • Rekt leaderboard: search.
  • Solodit incident search: search.

These dashboards index community alerts tweets, post-mortems, and independent write-ups. Reach them through the protocol name above to cross-check this reproduction against other analyses.