OpenSea Seaport contest - twojoy's results

A marketplace contract for safely and efficiently creating and fulfilling orders for ERC721 and ERC1155 items.

General Information

Platform: Code4rena

Start Date: 20/05/2022

Pot Size: $1,000,000 USDC

Total HM: 4

Participants: 59

Period: 14 days

Judge: leastwood

Id: 128

League: ETH

OpenSea

Findings Distribution

Researcher Performance

Rank: 25/59

Findings: 2

Award: $2,339.78

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

1904.8298 USDC - $1,904.83

Labels

bug
QA (Quality Assurance)

External Links

1. Missing zero address check of initialOwner in createConduit of ConduitController.sol

  • Consider adding zero address checks while setting initialOwner.
function createConduit(bytes32 conduitKey, address initialOwner)
        external
        override
        returns (address conduit)
    {
       ......
       //recommendation
       if(initialOwner == address(0){
        revert ZeroAddressError();
        .....
     }

2. Use specific memory offset variables instead of generic offset in inline assembly

In contracts/lib/GettersAndDerivers.sol#L68

While writing assembly, use the specific memory offset variable for specific structs instead of using generic offsets such as OneWords TwoWords. This make the code easy to read/understand and reduces chances of error on change.

  // Current

  // Get the pointer to the offers array.
  let offerArrPtr := mload(add(orderParameters, TwoWords))

  
  // Recommended Change:

  // Get the pointer to the offers array.
  let offerArrPtr := mload(add(orderParameters, OrderParameters_offer_head_offset))

#0 - GalloDaSballo

2022-07-17T18:29:32Z

1. Missing zero address check of initialOwner in createConduit of ConduitController.sol

Valid Low per #56

2. Use specific memory offset variables instead of generic offset in inline assembly

Disagree

1L

1. keccak256 hash computation can be precomputed to save deployment gas

  • In _deriveTypehashes() of ConsiderationBase.sol the keccak256 hash of the encoded values can be precomputed.
........
eip712DomainTypehash = keccak256(
            abi.encodePacked(
                "EIP712Domain(",
                    "string name,",
                    "string version,",
                    "uint256 chainId,",
                    "address verifyingContract",
                ")"
            )
....


// recommendation: precompute

eip712DomainTypehash = 0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f 

2. Use prefix increment/decrement operation whenever possible

3. array length in loops can be cached instead of calculating in every iteration

The loop bounds are calculated with array.length which are calculated in every loop iterations which can result in high gas. The array length can be cached instead of calculating in every loop iteration to save gas.

// Current
for (uint i = 0; i < offer.length; ++i) {
}

// Recommendation
uint len = offer.length;
for (uint i = 0; i < len; ++i) {
}

The instances where this pattern can be applied is found as follows

❯ grep -rn './contracts/' -e 'for.*[.]length'
./contracts/lib/OrderFulfiller.sol:217:            for (uint256 i = 0; i < orderParameters.offer.length; ) {
./contracts/lib/OrderFulfiller.sol:306:            for (uint256 i = 0; i < orderParameters.consideration.length; ) {
./contracts/lib/OrderCombiner.sol:247:                for (uint256 j = 0; j < offer.length; ++j) {
./contracts/lib/OrderCombiner.sol:291:                for (uint256 j = 0; j < consideration.length; ++j) {
./contracts/lib/OrderCombiner.sol:598:                for (uint256 j = 0; j < consideration.length; ++j) {
./contracts/lib/OrderCombiner.sol:621:        for (uint256 i = 0; i < executions.length; ) {   

#0 - HardlyDifficult

2022-06-24T19:08:13Z

keccak256 hash computation can be precomputed to save deployment gas

Given that this only impacts the constructor and therefore will not impact users, it seems reasonable to leave the code as-is for improved readability. If the precomputed form was used one would need to run the hash manually in order to validate it is as expected.

The other two findings should provide small savings.

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