Blur Exchange contest - MiloTruck's results

An NFT exchange for the Blur marketplace.

General Information

Platform: Code4rena

Start Date: 05/10/2022

Pot Size: $50,000 USDC

Total HM: 2

Participants: 80

Period: 5 days

Judge: GalloDaSballo

Id: 168

League: ETH

Blur Exchange

Findings Distribution

Researcher Performance

Rank: 35/80

Findings: 1

Award: $114.82

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

114.8239 USDC - $114.82

Labels

bug
duplicate
3 (High Risk)
sponsor acknowledged

External Links

Lines of code

https://github.com/code-423n4/2022-10-blur/blob/main/contracts/matchingPolicies/StandardPolicyERC1155.sol#L24-L35

Vulnerability details

Impact

Due to the way StandardPolicyERC1155 is coded, users will only receive 1 ERC1155 token instead of the amount specified in their buy order.

Proof of Concept

In the StandardPolicyERC1155, contract, the functions canMatchMakerAsk() and canMatchMakerBid() return 1 as the amount to be transferred:

// Using canMatchMakerAsk() as an example
  24:    return (
  25:        (makerAsk.side != takerBid.side) &&
  26:        (makerAsk.paymentToken == takerBid.paymentToken) &&
  27:        (makerAsk.collection == takerBid.collection) &&
  28:        (makerAsk.tokenId == takerBid.tokenId) &&
  29:        (makerAsk.matchingPolicy == takerBid.matchingPolicy) &&
  30:        (makerAsk.price == takerBid.price),
  31:        makerAsk.price,
  32:        makerAsk.tokenId,
  33:        1, // @audit This is the amount to be transferred in an order
  34:        AssetType.ERC1155
  35:    );

Thus, if StandardPolicyERC1155 is used as the matching policy for an ERC1155 order pair, only 1 ERC1155 token will be transferred to the buyer, regardless of the amount specified in the order. Attackers could abuse this by creating sell orders with a high amount, misleading buyers into thinking they are buying more than 1 ERC1155 token.

Furthermore, this goes against what is written in the README, which states amount works for ERC1155 tokens:

The responsibility of each policy is to assert the criteria for a valid match are met and return the parameters for proper execution -

  • price - matching price
  • tokenId - NFT token id to transfer
  • amount - (for erc1155) amount of the token to transfer
  • assetType - ERC721 or ERC1155

In StandardPolicyERC1155, check that amount is the same for both ask and bid orders, and return that instead.

#0 - blur-io-toad

2022-10-16T23:38:53Z

This was an oversight on my part for not putting this contract as out-of-scope. Our marketplace does not handle ERC1155 yet and so we haven't concluded what the matching critieria for those orders will be. This contract was mainly created to test ERC1155 transfers through the rest of the exchange, but shouldn't be deployed initially. When we are prepared to handle ERC1155 orders we will have to develop a new matching policy that determines the amount from the order parameters. Acknowledging that it's incorrect, but won't be making any changes as the contract won't be deployed.

#1 - trust1995

2022-10-28T00:00:28Z

Dup #711

#2 - GalloDaSballo

2022-10-28T00:06:56Z

#3 - trust1995

2022-10-28T00:15:36Z

I believe warden identified the issue in #711 . His recommended fix: In StandardPolicyERC1155, check that amount is the same for both ask and bid orders, and return that instead is much more similar to #711 than #666

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