BitHotel Marketplace

Smart Contract Audit Report

Audit Summary

BitHotel Marketplace Audit Report BitHotel is creating a new marketplace in which users can list and purchase NFTs from supported collections.

For this audit, we reviewed BitHotel's BithotelMarketplaceUpgradeable contract and ERC721MarketplaceUpgradeable library at commit 518ad91c136c3c71e4bd6fa17958bca1435a3bf8 on the team's private GitHub repository.

We previously reviewed BitHotel's NFT and presale contracts here and previous marketplace here.

Audit Findings

Please ensure trust in the team prior to investing as they have substantial control in the ecosystem.
Date: February 28th, 2022.
Updated: March 4th, 2022 to support changes from commit 10aee2225f5c59da29fdf945d40d9d2cc2aea24a to commit 5eb8199a27095bfb21ca9d9ff36e11557650c77d.
Updated: March 8th, 2022 to support changes from commit 5eb8199a27095bfb21ca9d9ff36e11557650c77d to commit 518ad91c136c3c71e4bd6fa17958bca1435a3bf8

Finding #1 - BithotelMarketplaceUpgradeable - High (Resolved)

Description: A user can cancel any listing and have the listing's NFT transferred to them by calling the cancelERC721Listing() function.
Risk/Impact: Users will be able to steal NFT listings from the contract by cancelling them.
Recommendation: The team should require that the user cancelling the listing is the same user that listed it.
Resolution: A listing can now only be cancelled by its owner.


Finding #2 - BithotelMarketplaceUpgradeable - High (Resolved)

Description: Users will not have their NFT returned to them when cancelling a listing using the cancelERC721ListingByToken() function, or when cancelERC721Listings() is called by a Timelock Controller.
Risk/Impact: Users will not be able to recover their NFT if they cancel their listing using the cancelERC721ListingByToken() function. Listings may also be marked as cancelled even though they have already been executed.
Recommendation: The team should implement the same functionality and requirements used in the cancelERC721Listing() function in addition to the fix to Finding #1.
Resolution: NFTs are now returned to users upon cancellation.


Finding #3 - BithotelMarketplaceUpgradeable - Medium (Partially Resolved)

Description: Users and Timelock Controllers have the ability to cancel listings that have already been executed or previously cancelled by calling the cancelERC721ListingByToken() function or cancelERC721Listings() functions, respectively.
Risk/Impact: If a listing has been executed and then the NFT is relisted by a different address, a cancellation of the previously executed listing would result in an NFT transfer to the incorrect address. Listings may also incorrectly be updated to "Cancelled" despite already being executed.
Recommendation: The team should not allow executed or already cancelled listings to be cancelled.
Resolution: While the cancelERC721ListingByToken() function has been removed, the cancelERC721Listings() function still allows the Timelock Controller Role to cancel listings of any status. The team should be careful to not cancel any listings which have already been cancelled.


Finding #4 - BithotelMarketplaceUpgradeable - Informational (Resolved)

Description: This contract contains several functions that are not used.
_changeListingStatus(), _lockTokenId(), _releaseLockedTokenId(), pause(), unpause(), setCollectionController()
Recommendation: We recommend removing these functions to save on deployment costs if they are not needed for future functionality.
Resolution: The team has implemented logic that makes use of these functions.

Contract Overview

  • This contract allows users to list and purchase supported NFTs.
  • Upon initialization, the deployer is given the Admin and Upgrader roles. The Admin role and Timelock Controller roles are also given to two specified addresses, respectively.
  • Users must specify a NFT address, token ID, and price when listing. The NFT address must be added to the list of supported collections before one of its tokens can be listed.
  • If enabled, users must pay a listing fee in a specified listing fee token when creating new NFT listings.
  • Listing fees are sent to the 0x..dead address.
  • When listing, the seller's NFT is transferred to this contract.
  • If an added listing's NFT is a BitHotelRoomCollectionUpgradeable NFT, the NFT will be "locked" if certain conditions defined in the BitHotelRoomCollectionUpgradeable contract are met. In addition, if the BitHotelRoomCollectionUpgradeable collection's controller is not set to this contract, the NFT will not be transferred from the seller to this contract upon listing.
  • As the BitHotelRoomCollectionUpgradeable contract was not included in the scope of this audit, we are unable to provide an assessment regarding security or functionality.
  • Listing data is stored using multiple linked lists to keep track of each user's NFT listings for each NFT address as well as the total listings for each NFT address.
  • When purchasing an active listing, buyers must pay in a specified payment token.
  • A tax is taken from purchases and sent to the team's wallet address. The remainder is transferred to the seller.
  • If a purchased listing's NFT is a BitHotelRoomCollectionUpgradeable NFT, the token will also be "released" if certain conditions defined in the BitHotelRoomCollectionUpgradeable contract are met and the collection's controller is set to this contract's address.
  • A listing owner can cancel their active listing at any time, where their NFT will be returned to them if it is not a BitHotelRoomCollectionUpgradeable NFT.
  • If a listing's NFT is a BitHotelRoomCollectionUpgradeable, the NFT will not be returned to the user when cancelled. Instead, the BitHotelRoomCollectionUpgradeable NFT will be "released" if certain conditions defined in the BitHotelRoomCollectionUpgradeable contract are met and the collection's controller is set to this contract's address.

  • The Timelock Controller Role has the ability to pause the contract at any time, disabling functionality to add new listings, purchase existing listings, and for users to cancel and retreive existing listings.
  • The Timelock Controller Role has the ability to cancel any listing even if the contract is paused; users will not have their NFTs returned to them if this occurs.
  • The Timelock Controller Role has the ability to update a BitHotelRoomCollectionUpgradeable's "controller" at any time.
  • The Timelock Controller Role has the ability to add or remove a supported NFT collection at any time.
  • The Timelock Controller Role has the ability to update the listing fee token, listing fee amount, and payment token at any time.
  • The Timelock Controller Role can also disable the listing fee at any time.
  • The Timelock Controller Role has the ability to update a specified BitHotel ERC721 collection's controller at any time.
  • As we did not review any Timelock contracts in the scope of this audit, we cannot verify the delay time or any functionality related to Timelock controller.
  • Any Upgrader has the ability to upgrade the contract at any time.
  • Any Admin can grant or revoke any role from any address at any time.

  • The contract utilizes ReentrancyGuard to prevent against reentrancy attacks in applicable functions.
  • As the contract is implemented with Solidity v0.8.0, it is safe from any possible overflows/underflows.
  • Audit Results

    Vulnerability CategoryNotesResult
    Arbitrary Jump/Storage WriteN/APASS
    Centralization of Control
  • The owner and mentioned roles have the permissions described above.
  • The Timelock Controller Role can update the payment token at any time.
  • The Timelock Controller Role can update the listing fee to any amount at any time.
  • The Timelock Controller Role can cancel any listing at any time.
  • The Timelock Controller Role can pause the contract at any time.
  • Any Upgrader can upgrade the contract at any time.
  • WARNING
    Compiler IssuesN/APASS
    Delegate Call to Untrusted ContractN/APASS
    Dependence on Predictable VariablesN/APASS
    Ether/Token TheftN/APASS
    Flash LoansN/APASS
    Front RunningN/APASS
    Improper EventsN/APASS
    Improper Authorization SchemeN/APASS
    Integer Over/UnderflowN/APASS
    Logical IssuesThe Timelock Controller Role can cancel listings of any status.WARNING
    Oracle IssuesN/APASS
    Outdated Compiler VersionN/APASS
    Race ConditionsN/APASS
    ReentrancyN/APASS
    Signature IssuesN/APASS
    Unbounded LoopsN/APASS
    Unused CodeN/APASS
    Overall Contract Safety PASS

    Inheritance Chart

    Smart Contract Audit - Inheritance

    Function Graph

    Smart Contract Audit - Graph

    Functions Overview

    
     ($) = payable function
     # = non-constant function
     
     Int = Internal
     Ext = External
     Pub = Public
    
     + [Int] IERC20Upgradeable 
        - [Ext] totalSupply
        - [Ext] balanceOf
        - [Ext] transfer #
        - [Ext] allowance
        - [Ext] approve #
        - [Ext] transferFrom #
    
     + [Lib] AddressUpgradeable 
        - [Int] isContract
        - [Int] sendValue #
        - [Int] functionCall #
        - [Int] functionCall #
        - [Int] functionCallWithValue #
        - [Int] functionCallWithValue #
        - [Int] functionStaticCall
        - [Int] functionStaticCall
        - [Int] verifyCallResult
    
     + [Lib] SafeERC20Upgradeable 
        - [Int] safeTransfer #
        - [Int] safeTransferFrom #
        - [Int] safeApprove #
        - [Int] safeIncreaseAllowance #
        - [Int] safeDecreaseAllowance #
        - [Prv] _callOptionalReturn #
    
     +  Initializable 
        - [Prv] _isConstructor
    
     + [Int] IERC1822ProxiableUpgradeable 
        - [Ext] proxiableUUID
    
     + [Int] IBeaconUpgradeable 
        - [Ext] implementation
    
     + [Lib] StorageSlotUpgradeable 
        - [Int] getAddressSlot
        - [Int] getBooleanSlot
        - [Int] getBytes32Slot
        - [Int] getUint256Slot
    
     +  ERC1967UpgradeUpgradeable (Initializable)
        - [Int] __ERC1967Upgrade_init #
           - modifiers: onlyInitializing
        - [Int] __ERC1967Upgrade_init_unchained #
           - modifiers: onlyInitializing
        - [Int] _getImplementation
        - [Prv] _setImplementation #
        - [Int] _upgradeTo #
        - [Int] _upgradeToAndCall #
        - [Int] _upgradeToAndCallUUPS #
        - [Int] _getAdmin
        - [Prv] _setAdmin #
        - [Int] _changeAdmin #
        - [Int] _getBeacon
        - [Prv] _setBeacon #
        - [Int] _upgradeBeaconToAndCall #
        - [Prv] _functionDelegateCall #
    
     +  UUPSUpgradeable (Initializable, IERC1822ProxiableUpgradeable, ERC1967UpgradeUpgradeable)
        - [Int] __UUPSUpgradeable_init #
           - modifiers: onlyInitializing
        - [Int] __UUPSUpgradeable_init_unchained #
           - modifiers: onlyInitializing
        - [Ext] proxiableUUID
           - modifiers: notDelegated
        - [Ext] upgradeTo #
           - modifiers: onlyProxy
        - [Ext] upgradeToAndCall ($)
           - modifiers: onlyProxy
        - [Int] _authorizeUpgrade #
    
     + [Int] IAccessControlUpgradeable 
        - [Ext] hasRole
        - [Ext] getRoleAdmin
        - [Ext] grantRole #
        - [Ext] revokeRole #
        - [Ext] renounceRole #
    
     +  ContextUpgradeable (Initializable)
        - [Int] __Context_init #
           - modifiers: onlyInitializing
        - [Int] __Context_init_unchained #
           - modifiers: onlyInitializing
        - [Int] _msgSender
        - [Int] _msgData
    
     + [Lib] StringsUpgradeable 
        - [Int] toString
        - [Int] toHexString
        - [Int] toHexString
    
     + [Int] IERC165Upgradeable 
        - [Ext] supportsInterface
    
     +  ERC165Upgradeable (Initializable, IERC165Upgradeable)
        - [Int] __ERC165_init #
           - modifiers: onlyInitializing
        - [Int] __ERC165_init_unchained #
           - modifiers: onlyInitializing
        - [Pub] supportsInterface
    
     +  AccessControlUpgradeable (Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable)
        - [Int] __AccessControl_init #
           - modifiers: onlyInitializing
        - [Int] __AccessControl_init_unchained #
           - modifiers: onlyInitializing
        - [Pub] supportsInterface
        - [Pub] hasRole
        - [Int] _checkRole
        - [Pub] getRoleAdmin
        - [Pub] grantRole #
           - modifiers: onlyRole
        - [Pub] revokeRole #
           - modifiers: onlyRole
        - [Pub] renounceRole #
        - [Int] _setupRole #
        - [Int] _setRoleAdmin #
        - [Int] _grantRole #
        - [Int] _revokeRole #
    
     + [Lib] CountersUpgradeable 
        - [Int] current
        - [Int] increment #
        - [Int] decrement #
        - [Int] reset #
    
     + [Int] IERC721ReceiverUpgradeable 
        - [Ext] onERC721Received #
    
     +  ERC721HolderUpgradeable (Initializable, IERC721ReceiverUpgradeable)
        - [Int] __ERC721Holder_init #
           - modifiers: onlyInitializing
        - [Int] __ERC721Holder_init_unchained #
           - modifiers: onlyInitializing
        - [Pub] onERC721Received #
    
     +  PausableUpgradeable (Initializable, ContextUpgradeable)
        - [Int] __Pausable_init #
           - modifiers: onlyInitializing
        - [Int] __Pausable_init_unchained #
           - modifiers: onlyInitializing
        - [Pub] paused
        - [Int] _pause #
           - modifiers: whenNotPaused
        - [Int] _unpause #
           - modifiers: whenPaused
    
     +  ReentrancyGuardUpgradeable (Initializable)
        - [Int] __ReentrancyGuard_init #
           - modifiers: onlyInitializing
        - [Int] __ReentrancyGuard_init_unchained #
           - modifiers: onlyInitializing
    
     + [Int] IERC721Upgradeable (IERC165Upgradeable)
        - [Ext] balanceOf
        - [Ext] ownerOf
        - [Ext] safeTransferFrom #
        - [Ext] transferFrom #
        - [Ext] approve #
        - [Ext] getApproved
        - [Ext] setApprovalForAll #
        - [Ext] isApprovedForAll
        - [Ext] safeTransferFrom #
    
     + [Int] IBitHotelRoomCollectionUpgradeable (IERC721Upgradeable)
        - [Ext] tokenIds
        - [Ext] ownersHistory
        - [Ext] getRoomInfos
        - [Ext] getRoomDimensions
        - [Ext] locked
        - [Ext] controller
        - [Ext] replicas
        - [Ext] baseURI
        - [Ext] exists
        - [Ext] setRoomInfos #
        - [Ext] setController #
        - [Ext] lockTokenId #
        - [Ext] releaseLockedTokenId #
        - [Ext] setBaseURI #
        - [Ext] setTokenURI #
    
     + [Lib] ERC721MarketplaceUpgradeable 
        - [Int] appStorage
        - [Int] getAllListingIds
        - [Int] totalListingIds
        - [Int] getListingIdIndex
        - [Int] getErc721Categories
        - [Int] getErc721OwnerListingHead
        - [Int] getErc721TokenToListingId
        - [Int] getErc721ListingHead
        - [Int] getErc721OwnerListingListItem
        - [Int] getERC721ListingListItem
        - [Int] _getERC721Listing
        - [Int] addCollectionCategory #
        - [Int] addERC721ListingItem #
        - [Int] cancelERC721Listing #
        - [Int] cancelERC721ListingByToken #
        - [Int] removeERC721ListingItem #
        - [Int] updateERC721Listing #
    
     +  BithotelMarketplaceUpgradeable (Initializable, AccessControlUpgradeable, ERC721HolderUpgradeable, PausableUpgradeable, ReentrancyGuardUpgradeable, UUPSUpgradeable)
        - [Pub]  #
           - modifiers: initializer
        - [Pub] initialize #
           - modifiers: initializer
        - [Int] __BithotelMarketplace_init_unchained #
           - modifiers: onlyInitializing
        - [Ext] version
        - [Ext] getChainId
        - [Ext] getERC721Listing
        - [Ext] bulkAddIncludedCollections #
           - modifiers: nonReentrant,onlyRole
        - [Ext] bulkRemoveIncludedCollections #
           - modifiers: nonReentrant,onlyRole
        - [Ext] setListingFeeEnabled #
           - modifiers: nonReentrant,onlyRole
        - [Ext] changeListingFeeInWei #
           - modifiers: nonReentrant,onlyRole
        - [Ext] changeBth #
           - modifiers: nonReentrant,onlyRole
        - [Ext] changeToken #
           - modifiers: nonReentrant,onlyRole
        - [Ext] setCollectionController #
           - modifiers: nonReentrant,onlyRole
        - [Ext] addERC721Listing #
           - modifiers: nonReentrant
        - [Ext] cancelERC721Listing #
           - modifiers: nonReentrant
        - [Ext] executeERC721Listing #
           - modifiers: nonReentrant
        - [Ext] cancelERC721Listings #
           - modifiers: nonReentrant,onlyRole
        - [Pub] getAllIncludedCollections
        - [Pub] totalIncludedCollections
        - [Pub] getIncludedCollectionIndex
        - [Pub] isListingFeeEnabled
        - [Pub] listingFeeInWei
        - [Pub] listingTax
        - [Pub] getNextERC721ListingId
        - [Pub] listingIds
        - [Pub] totalListingIds
        - [Pub] listingIdIndex
        - [Pub] getERC721ListingListItem
        - [Pub] getErc721ListingHead
        - [Pub] getErc721Categories
        - [Pub] getErc721OwnerListingHead
        - [Pub] getErc721TokenToListingId
        - [Pub] getERC721Category
        - [Pub] timelockController
        - [Pub] token
        - [Pub] bth
        - [Pub] wallet
        - [Pub] burnAddress
        - [Pub] pause #
        - [Pub] unpause #
        - [Int] _changeListingStatus #
        - [Int] _addIncludedCollection #
        - [Int] _removeIncludedCollection #
        - [Int] addCollectionCategory #
        - [Int] _beforeAddERC721Listing #
        - [Int] _afterAddERC721Listing #
        - [Int] _beforeExecuteERC721Listing #
        - [Int] _afterExecuteERC721Listing #
        - [Int] _lockTokenId #
        - [Int] _releaseLockedTokenId #
        - [Int] _receiveTokens #
        - [Int] _sendTokens #
        - [Int] _receiveERC721 #
        - [Int] _sendERC721 #
        - [Int] _beforePause #
           - modifiers: onlyRole
        - [Int] _beforeUnpause #
           - modifiers: onlyRole
        - [Int] _authorizeUpgrade #
           - modifiers: onlyRole
    
    

    About Solidity Finance

    Solidity Finance was founded in 2020 and quickly grew to have one of the most experienced and well-equipped smart contract auditing teams in the industry. Our team has conducted 1000+ solidity smart contract audits covering all major project types and protocols, securing a total of over $50 billion U.S. dollars in on-chain value across 1500 projects!.
    Our firm is well-reputed in the community and is trusted as a top smart contract auditing company for the review of solidity code, no matter how complex. Our team of experienced solidity smart contract auditors performs audits for tokens, NFTs, crowdsales, marketplaces, gambling games, financial protocols, and more!

    Contact us today to get a free quote for a smart contract audit of your project!

    What is a Solidity Audit?

    Typically, a smart contract audit is a comprehensive review process designed to discover logical errors, security vulnerabilities, and optimization opportunities within code. A Solidity Audit takes this a step further by verifying economic logic to ensure the stability of smart contracts and highlighting privileged functionality to create a report that is easy to understand for developers and community members alike.

    How Do I Interpret the Findings?

    Each of our Findings will be labeled with a Severity level. We always recommend the team resolve High, Medium, and Low severity findings prior to deploying the code to the mainnet. Here is a breakdown on what each Severity level means for the project:

    • High severity indicates that the issue puts a large number of users' funds at risk and has a high probability of exploitation, or the smart contract contains serious logical issues which can prevent the code from operating as intended.
    • Medium severity issues are those which place at least some users' funds at risk and has a medium to high probability of exploitation.
    • Low severity issues have a relatively minor risk association; these issues have a low probability of occurring or may have a minimal impact.
    • Informational issues pose no immediate risk, but inform the project team of opportunities for gas optimizations and following smart contract security best practices.