Skip to content
Business logic Audit finding Intermediate

Incorrect condition marks valid order as invalid

The order-matching logic in a smart contract contained an incorrect check that caused valid orders to be rejected. An attacker could not exploit this directly, but legitimate users would be unable to execute trades that should have succeeded.

Anurag Jain Follow

Originally disclosed on Code4rena

Submitted by csanuragjain, also found by KIntern

canExecMatchOrder is having an incorrect check which makes a valid order as invalid.

doItemsIntersect function is also checked on sell.nfts, buy.nfts which is incorrect.

doItemsIntersect should only be checked in reference to constructedNfts.

Proof of Concept

  1. Assume buy has nfts {A,B,C}, sell has nft {A,B}, constructedNfts has nft {A}, buy.constraints[0]/sell.constraints[0]/numConstructedItems is 1
  2. Ideally this order should match since constructedNfts {A} is present in both buy and sell
  3. But this will not match since doItemsIntersect(sell.nfts, buy.nfts) will fail because of item C which is not present in sell

Recommended Mitigation Steps

Remove doItemsIntersect(sell.nfts, buy.nfts) from InfinityOrderBookComplication.sol#L140

nneverlander (Infinity) confirmed and resolved:

Fixed in https://github.com/infinitydotxyz/exchange-contracts-v2/commit/74a7d6b39dc441b5b496b74735a1b09b93bef12f

HardlyDifficult (judge) decreased severity to Medium and commented:

Some orders that should be matched would revert. Lowering this to Medium risk.


The original report as published on Code4rena, by csanuragjain. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The function doItemsIntersect was called on the full sell and buy NFT lists instead of only on the constructed NFTs, causing valid orders to fail when the lists were not identical.

Impact

Some orders that should be matched would revert, preventing legitimate trades from executing.

What the attacker needed

A valid order with overlapping but non-identical NFT sets

The fix

The check doItemsIntersect(sell.nfts, buy.nfts) was removed from the order book complication contract, and the fix was confirmed by the project.

How it was found

  1. Assume a buy order contains NFTs A, B, C and a sell order contains NFTs A, B.
  2. Assume the constructed NFTs contain only A, and the constraint count is 1.
  3. The order should match because the constructed NFT A is present in both buy and sell.
  4. The order fails to match because the check compares the full sell and buy NFT lists, and item C is not in the sell list.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

This is a bug in a smart contract that matches buy and sell orders. The contract had an extra check that compared the full list of items in the buy order with the full list in the sell order, even though only a subset of items (the constructed items) needed to match. As a result, some orders that should have been accepted were rejected, preventing users from trading.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by Anurag Jain

View all

63 more disclosed reports, best first.

More from Infinity NFT Marketplace contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.