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.
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
- 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
- Ideally this order should match since constructedNfts {A} is present in both buy and sell
- 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:
HardlyDifficult (judge) decreased severity to Medium and commented:
Some orders that should be matched would revert. Lowering this to Medium risk.
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
- Assume a buy order contains NFTs A, B, C and a sell order contains NFTs A, B.
- Assume the constructed NFTs contain only A, and the constraint count is 1.
- The order should match because the constructed NFT A is present in both buy and sell.
- 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.