OpenSea Seaport 1.2 contest - ABA's results

A marketplace protocol for safely and efficiently buying and selling NFTs.

General Information

Platform: Code4rena

Start Date: 13/01/2023

Pot Size: $100,500 USDC

Total HM: 1

Participants: 23

Period: 10 days

Judge: hickuphh3

Total Solo HM: 1

Id: 201

League: ETH

OpenSea

Findings Distribution

Researcher Performance

Rank: 6/23

Findings: 1

Award: $1,551.45

QA:
grade-a

🌟 Selected for report: 0

🚀 Solo Findings: 0

Findings Information

Awards

1551.4544 USDC - $1,551.45

Labels

bug
grade-a
QA (Quality Assurance)
Q-15

External Links

[1] incorrect size round up in _encodeBytes

Context: https://github.com/ProjectOpenSea/seaport/blob/5de7302bc773d9821ba4759e47fc981680911ea0/contracts/lib/ConsiderationEncoder.sol#L73

_encodeBytes attempts to round up the provided size of src memory pointer to the nearest word but instead it rounds up to the second nearest word by using AlmostTwoWords instead of AlmostOneWord

// Mask the length of the bytes array to protect against overflow // and round up to the nearest word. size = (src.readUint256() + AlmostTwoWords) & OnlyFullWordMask;

_encodeBytes is used in 3 places:

  • _encodeGenerateOrder -> over extens the size of the bytes memory context in the calldata
  • _encodeRatifyOrder -> over extens the size of the bytes memory context in the calldata
  • _encodeValidateOrder -> over extens the size of bytes memory extraData in the calldata

In all cases, the over increase in size dose not pose an issue internally as the values are only passed through a call to the calling ContractOffererInterface implementation functions. Here, depending on the logic used by the implementer the size may cause an issue/hidden bug, althought of a low severity.

Proof of Concept

pragma solidity ^0.8.13.0; contract Testing { function _encodeBytes(uint256 src) external pure returns (uint256 size) { uint256 AlmostTwoWords = 0x3f; uint256 OnlyFullWordMask = 0xff_ff_ff_e0; unchecked { size = (src + AlmostTwoWords) & OnlyFullWordMask; } } }

Input: 0x12345678

Expectation: 0x12345680

Output: 0x123456A0

change AlmostTwoWords to AlmostOneWord

[2] Natspec minor issues

Natspec typos of wrongly named arguments

For function _encodeBytes second param is named dst but the natspec has it as src. Simply rename it to fix.

Context: https://github.com/ProjectOpenSea/seaport/blob/5de7302bc773d9821ba4759e47fc981680911ea0/contracts/lib/ConsiderationEncoder.sol#L60

#0 - HickupHH3

2023-01-25T09:13:06Z

Nice find for the 1st issue! Possibly grade A because of it.

#1 - c4-judge

2023-01-26T03:02:05Z

HickupHH3 marked the issue as grade-a

#2 - HickupHH3

2023-01-26T18:15:39Z

Regarding the 1st issue, impl is working as expected, whereby word storing the length needs to be copied over as well. See https://github.com/ProjectOpenSea/seaport/pull/906/files

Keeping the grade because the issue helped to clarify the return argument of the function => finding is of value.

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