Reproduced Exploit

Debita: TaxTokensReceipt cannot be sold into a buy order

sellNFT transfers the wanted receipt into the buy order. TaxTokensReceipt.transferFrom reverts unless from or to is a borrow order, a lend order, or a loan. A buy order is none of those. Alice's sale reverts, she is paid 0, and the 1000 USDC Bob escrowed never moves.

Nov 2024•Ethereum•access-control•3 min read

Loss

Alice cannot sell receipt 1. Bob's 1000 USDC stays in the buy order

Chain

Ethereum

Category

access-control

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: 44227-h-4-no-one-can-sell-taxtokensreceipts-nft-receipt-to-the-buy. Standalone Foundry PoC and full write-up: 44227-h-4-no-one-can-sell-taxtokensreceipts-nft-receipt-to-the-buy_exp in the evm-hack-registry mirror.


Vulnerability classes: vuln/access-control/broken-logic · vuln/logic/wrong-condition

Key info#

FieldValue
LossAlice cannot sell receipt 1. Bob's 1000 USDC stays in the buy order
Vulnerable contractTaxTokensReceipt.transferFrom
Attacker EOA0x1111111111111111111111111111111111111111
Attack contractExploit
Attack txExploit.run()
Chain / block / dateEthereum model · block 0 · 2024-11
Compilersolc 0.8.27, cancun, via IR
Bug classallowlist omits buy orders

TL;DR#

sellNFT transfers the wanted receipt into the buy order. TaxTokensReceipt.transferFrom reverts unless from or to is a borrow order, a lend order, or a loan. A buy order is none of those. Alice's sale reverts, she is paid 0, and the 1000 USDC Bob escrowed never moves.

The vulnerable code#

SOLIDITY
bool isReceiverAddressDebita = registry.isBorrowOrderLegit(to)
    || registry.isLendOrderLegit(to)
    || registry.isSenderALoan(to);
bool isSenderAddressDebita = registry.isBorrowOrderLegit(from)
    || registry.isLendOrderLegit(from)
    || registry.isSenderALoan(from);
require(
    isReceiverAddressDebita || isSenderAddressDebita,
    "TaxTokensReceipts: Debita not involved"
); // @> VULN

The recommended fix also accepts isBuyOrderLegit on both sides.

Root cause#

The transfer override was written for the three contracts that already move receipts. Buy orders were added later and were not added to the same allowlist. sellNFT has no other way to take the NFT.

Preconditions#

  • Alice owns a TaxTokensReceipt.
  • A buy order for that receipt is active and holds 1000 USDC.
  • Alice is not herself a loan, borrow order, or lend order.

Attack walkthrough#

  1. Mint receipt 1 to Alice and fund the buy order with 1000 USDC.
  2. Mark unrelated borrow, lend, and loan addresses so the allowlist is non-empty.
  3. Alice calls sellNFT(1).
  4. transferFrom reverts with TaxTokensReceipts: Debita not involved.
  5. The receipt owner is still Alice. Her USDC balance is 0. The order still holds 1000.

Diagrams#

flowchart TD A["Bob funds a buy order with 1000 USDC"] --> B["Alice calls sellNFT with her TaxTokensReceipt"] B --> C["transferFrom checks borrow, lend, and loan allowlists"] C --> D["VULN neither side is on those lists"] D --> E["Sale reverts"] E --> F["Receipt stays with Alice and 1000 USDC stays in the order"]

Impact#

The limit-order path for this receipt cannot be used. Buyers who escrowed USDC against a TaxTokensReceipt cannot be filled. A control that marks the seller as a loan pays Alice the 1000 and moves the receipt, which is the transfer the buy-order allowlist was supposed to permit.

Remediation#

Treat a legitimate buy order as a Debita counterparty in both the sender and receiver checks, matching the patch in the Sherlock issue.

How to reproduce#

BASH
cd 44227-h-4-no-one-can-sell-taxtokensreceipts-nft-receipt-to-the-buy_exp
forge test -vv

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.