sherlock-audit / 2024-08-flayer-judging

2 stars 0 forks source link

anon339900 - The struct CreateListing exists two times which can cause shadowing and unexepcted behavior #750

Open sherlock-admin4 opened 1 month ago

sherlock-admin4 commented 1 month ago

anon339900

High

The struct CreateListing exists two times which can cause shadowing and unexepcted behavior

Summary

There are two structs called CreateListing, this can cause one to shadow the other.

Root Cause

    struct CreateListing {
        address collection;
        uint[] tokenIds;
        Listing listing;
    }// IListings.sol

    struct CreateListing {
        address collection;
        uint[] tokenIds;
        ProtectedListing listing;
    } // IProtectedListings.sol

As we can see there are 2 structs both called CreateListing being imported both in the listings contract.

@> import {IListings} from '@flayer-interfaces/IListings.sol';
import {ILocker} from '@flayer-interfaces/ILocker.sol';
@> import {IProtectedListings} from '@flayer-interfaces/IProtectedListings.sol'; 
// Listings.sol

As the compiler imports both of them this can cause shadowing(not allowing one to run) or not compile at all. 1, 2

Internal pre-conditions

No response

External pre-conditions

No response

Attack Path

  1. A user calls the function createListings which uses the struct CreateListings
  2. This causes unexpected behavior/fails unexpectedly

Impact

This could render the function useless, get unexpected behavior or the compiler wont compile.

PoC

No response

Mitigation

Change the name of one of the structs.