Infinity NFT Marketplace contest - k's results

The world's most advanced NFT marketplace.

General Information

Platform: Code4rena

Start Date: 14/06/2022

Pot Size: $50,000 USDC

Total HM: 19

Participants: 99

Period: 5 days

Judge: HardlyDifficult

Total Solo HM: 4

Id: 136

League: ETH

Infinity NFT Marketplace

Findings Distribution

Researcher Performance

Rank: 15/99

Findings: 4

Award: $812.96

🌟 Selected for report: 1

🚀 Solo Findings: 0

Findings Information

🌟 Selected for report: PwnedNoMore

Also found by: 0xsanson, hyh, k, throttle, zzzitron

Labels

bug
duplicate
3 (High Risk)
sponsor confirmed

Awards

455.8432 USDC - $455.84

External Links

Lines of code

https://github.com/code-423n4/2022-06-infinity/blob/765376fa238bbccd8b1e2e12897c91098c7e5ac6/contracts/core/InfinityOrderBookComplication.sol#L278

Vulnerability details

Impact

The purpose of the doItemsIntersect() function is to determine whether the buy and sell orders match. No duplication check is performed, and as a result qualifying items can be included multiple times in a sell order. As such, the following is possible:

  1. A buyer creates an order for 3 items with the following requirements:
  • 1 item from collection A (ERC-721)
  • 1 item from collection B (ERC-721)
  • 1 item of token ID #10 from collection C (ERC-1155)
  1. The expected behavior is that in order to fulfill this order, a seller will need to have each of these items.
  2. However, if a seller has a balance of 3 token ID #10 from collection C, it's possible to fill this order by submitting a sell order comprising of only collection C tokens as the amount of tokens will match the required 3 and the collection will also correctly validate.

This will generally not be possible for ERC-721 tokens as they are non-fungible. When trying to perform the second transfer the call will fail as the seller will no longer be the owner of that NFT. It's likely still possible to bypass this by using afterTransferHook or onERC721Received hook, but no risk was observed in this path.

Proof of Concept

https://gist.github.com/kylriley/4db98ba6c67035c91dc35f5a5560f56d

Tools Used

N/A

Validation should be added to order matching to ensure that there are no duplicate token IDs present.

Findings Information

🌟 Selected for report: k

Also found by: 0x29A, 0xf15ers, 0xsanson, PwnedNoMore, antonttc, hyh, zzzitron

Labels

bug
3 (High Risk)
sponsor confirmed

Awards

276.9248 USDC - $276.92

External Links

Lines of code

https://github.com/code-423n4/2022-06-infinity/blob/765376fa238bbccd8b1e2e12897c91098c7e5ac6/contracts/core/InfinityExchange.sol#L1062

Vulnerability details

Impact

If an NFT is sold that does not specify support for the ERC-721 or ERC-1155 standard interface, the sale will still succeed. In doing so, the seller will receive funds from the buyer, but the buyer will not receive any NFT from the seller. This could happen in the following cases:

  1. a token that claims to be ERC-721/1155 compliant, but fails to implement the supportsInterface() function properly.
  2. an NFT that follows a standard other than ERC-721/1155 and does not implement their EIP-165 interfaces.
  3. a malicious contract that is deployed to take advantage of this behavior.

Proof of Concept

https://gist.github.com/kylriley/3bf0e03d79b3d62dd5a9224ca00c4cb9

Tools Used

N/A

If neither the ERC-721 nor the ERC-1155 interface is supported the function should revert. An alternative approach would be to attempt a transferFrom and check the balance before and after to ensure that it succeeded.

#2 - HardlyDifficult

2022-07-09T19:42:52Z

Selecting this report as the primary for the clear impact description and PoC code.

If supportsInterface returns false for both 721 & 1155 then no NFT is transferred but funds are still sent to the seller.

A number of NFTs do not fully comply with the 721/1155 standards. Since the order is not canceled or the tx reverted, this seems like a High risk issue.

  1. To follow standard practices, the MATCH_EXECUTOR, WETH_TRANSFER_GAS_UNITS and PROTOCOL_FEE_BPS variables should use camel case as they are not constants. Using caps case gives the incorrect impression that they are immutable.
  2. The setProtocolFee() function should validate that the _protocolFeeBps parameter is less than 10,000.
  3. The Solidity version of 0.8.14 should be bumped to 0.8.15. Note: the bug does not seem to affect the code in scope as assembly is not used.
  4. Some typos:

#0 - nneverlander

2022-06-23T11:41:32Z

Duplicate

Use custom errors instead of require messages

Replacing all require statements with custom errors will reduce the gas cost of deployment, as well as runtime costs when the revert condition is met.

#0 - nneverlander

2022-06-23T11:27:04Z

Duplicate

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter