Mashiat Amin Farin
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    <div style="text-align:center"> <img src="https://avatars.githubusercontent.com/u/3339759?s=280&v=4" alt="Sublime's custom image"/> </div> # Brain Station 23 Ltd. This report was made by | Name | Brain Station 23 ID | Official Email | Auditor Type | | --- | --- | --- | --- | | [Sampad Sikder](https://www.linkedin.com/in/sampad-sikder-897b90200/) | BS1464 |sampad.sikder@brainstation-23.com | External | | [Mashiat Amin Farin](https://www.linkedin.com/in/mashiataminfarin/)| BS1463 | mashiat.amin@brainstation-23.com | External| | [Md. Ariful Islam](https://www.linkedin.com/in/engr-arif/) | BS1121 | ariful.islam@brainstation-23.com | Internal | ### Tools used - Solidity Metrics (IDE Extenstion) - Slither - Aderyn <div style="text-align:left"> <img src="https://tintinweb.gallerycdn.vsassets.io/extensions/tintinweb/solidity-metrics/0.0.23/1697194552562/Microsoft.VisualStudio.Services.Icons.Default" alt="Sublime's custom image"/ width ="10%"> <img src="https://pypi-camo.freetls.fastly.net/7eddc9243716c076b02e313302c993d7293a45e7/68747470733a2f2f7261772e67697468756275736572636f6e74656e742e636f6d2f6372797469632f736c69746865722f6d61737465722f6c6f676f2e706e67" alt="Sublime's custom image"/ width ="25%"> <img src="https://framerusercontent.com/images/JatrJSTzKGDcgdyx9sNdTbxtBjg.png" alt="Sublime's custom image"/ width ="25%"> </div> ### Standards used - Rekt test - Tincho Method - [cyfrin.io standard](https://www.cyfrin.io/) # Hotelereum NFT Market Audit Report ## Private Audit A NFT Marketplace for Hotel Rooms and Holiday packages. Hotel partners can enlist their inventory price in stable coins. Users can purchase NFTs (Bookings) in MATIC coin or stable coin. ## Developer report In progress - how to setup project npm install --force install and run hardhat - Commit Hash e12d3e29ce9ae74774110d47b53d7e426ef08e64 - Repo URL: (https://github.com/nsal-ai/Blockchain-Web3/tree/develop) Branch:Develop - In scope vs out of scope contracts ./contract/ └── Hotelereum-NFT-Marketplace.sol - Compatibilities Solc Version: 0.8.19 Chain(s) to deploy contract to: Polygon Mumbai Native Tokens: MATIC ### Security review scope (Unit Test and Coverage) Hotelereum NFT Marketplace Deployment √ Should set the right Smart Contract owner (2319ms) Oracle √ Ask the oracle about MATIC price (117ms) On-Chain Inventory √ Should be able to enroll a hotel partner √ Should be able to manage inventory with Proper Stable-Coin Value (71ms) Super Admin NFT Mint √ Should mint an NFT by the Smart Contract owner where guest will be the owner of NFT (48ms) √ Should fail to mint if the sender is not actual Smart Contract owner Regular Guest NFT Mint √ Should mint if the sender is paying with crypto (117ms) √ Should primary market stakeholder's crypto balances got updated after a successful mint (94ms) NFT Reselling √ Should mark an NFT for resell when the sender is the current NFT owner (52ms) √ Should fail to mark NFT for resell when the sender is not the current NFT owner (46ms) √ Should be able to purchase resellable NFT as hotel reservation (92ms) √ Should secondary market stakeholder's crypto balances got updated after a successful sale (130ms) Smart Contract Ownership Transfer √ Should transfer the Smart Contract's ownership if the request is from current owner √ Should fail to transfer the Smart Contract's ownership if the sender is not current Smart Contract owner 14 passing (3s) | File | % Stmts | % Branch | % Funcs | % Lines |Uncovered Lines | | --- | --- | --- | --- | --- | --- | |contracts | 97.22 | 53.45 | 91.3 | 96.91 | | | HotelereumNFTMarketplace.sol | 97.22 | 53.45 | 91.3 | 96.91 | 46,183,595 | |All files | 97.22 | 53.45 | 91.3 | 96.91 | ### Roles - **Superadmin** Owner of smart contract - **Hotel organizations** Hotel Partners - **NFT owners** Guests or reservation owners ### Known issues - createCryptoBooking - client requested back to back changes which caused to create a lot more parameters <mark>Struct will be introduced to deal with this issue </mark> ## Rekt Test (needs editing and spell check and icon adding) - [x] Do you have all actors, roles and privileges documented? - [x] Do you keep documentation of all the external services, contracts, and oracles you rely on? - [ ] Do you have a written and tested incident response plan? - [ ] Do you document the best ways to attack your system? - [ ] Do you perform identity verification and background checks on all employees? - [x] Do you have a team member with securtity defined in their role - [ ] Do you require hardware security keys for production system (?) - [ ] Does your key management system require multiple humans and physical steps? (?)(managed with ENV (12 Factor authentication)) - [x] Do you define key invariants for your system and test rthem on every commit? - [x] Do you use the best automated tools to discover security issues in your code? - [ ] Do you undergo external audits and maintain a vulneravbilitiy disclosue or bug bounty program? - [x] Have you considered and mitigated avenues for abusing users of your system? ## Metrics report from .sol (Consensys Diligence) ### Files Summary | Key | Value | | --- | --- | | .sol Files | 1 | | Total nSLOC | 348 | ### Files Details | Type | File | Logic Contracts | Interfaces | Lines | nLines | nSLOC | Comment Lines | Complex Score | Capabilities | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | 📝🔍| HotelereumNFTMarketplace.sol | 1 | 1 | 601 | 502 | 348 | 109 | 165 |💰📤🔆Σ| ### Report Overview The analysis finished with 0 errors and 0 duplicate files. #### Risk ![image](https://hackmd.io/_uploads/rJU-87rYa.png) #### Inline documentation - Comment to source ratio: On average there are4.09 code lines per comment (lower=better). #### Components ## Issue Summary (From Aderyn) Category | No. of Issues | | --- | --- | | Critical | 0 | | High | 0 | | Medium | 1 | | Low | 1 | | NC | 3 | ## Issues ### Medium Issues - [ ] ***Centralization Issues*** Contracts have owners with privileged rights to perform admin tasks and need to be trusted to not perform malicious updates or drain funds. - Found in contracts/HotelereumNFTMarketplace.sol [Line: 245](contracts/HotelereumNFTMarketplace.sol#L245) ```solidity onlyOwner ``` ### Low Issues - [ ] ***L-1: Unsafe ERC20 Operations should not be used*** ERC20 functions may not behave as expected. For example: return values are not always meaningful. It is recommended to use OpenZeppelin's SafeERC20 library. - Found in contracts/HotelereumNFTMarketplace.sol [Line: 410](contracts/HotelereumNFTMarketplace.sol#L410) ```solidity idToMarketItem[_tokenId].hotel.transfer(primaryHotelFee); ``` - Found in contracts/HotelereumNFTMarketplace.sol [Line: 411](contracts/HotelereumNFTMarketplace.sol#L411) ```solidity payable(owner()).transfer(primaryPlatformFee); ``` - Found in contracts/HotelereumNFTMarketplace.sol [Line: 436](contracts/HotelereumNFTMarketplace.sol#L436) ```solidity idToMarketItem[_tokenId].hotel.transfer(secondaryHotelFee); ``` - Found in contracts/HotelereumNFTMarketplace.sol [Line: 437](contracts/HotelereumNFTMarketplace.sol#L437) ```solidity payable(owner()).transfer(secondaryPlatformFee); ``` - Found in contracts/HotelereumNFTMarketplace.sol [Line: 438](contracts/HotelereumNFTMarketplace.sol#L438) ```solidity sellerWallet.transfer(secondaryOwnerFee); ``` ### NC Issues - [ ] ***NC-1: Functions not used internally could be marked external*** - Found in contracts/HotelereumNFTMarketplace.sol [Line: 30](contracts/HotelereumNFTMarketplace.sol#L30) ```solidity function initialize(address _maticOracleRoute) public initializer { ``` - Found in contracts/HotelereumNFTMarketplace.sol [Line: 322](contracts/HotelereumNFTMarketplace.sol#L322) ```solidity function createBookingTwin( ``` - Found in contracts/HotelereumNFTMarketplace.sol [Line: 358](contracts/HotelereumNFTMarketplace.sol#L358) ```solidity function createCryptoBookingTwin( ``` - Found in contracts/HotelereumNFTMarketplace.sol [Line: 492](contracts/HotelereumNFTMarketplace.sol#L492) ```solidity function markForResell( ``` - Found in contracts/HotelereumNFTMarketplace.sol [Line: 521](contracts/HotelereumNFTMarketplace.sol#L521) ```solidity function createFixMarketSale(uint256 _tokenId) public payable { ``` - Found in contracts/HotelereumNFTMarketplace.sol [Line: 574](contracts/HotelereumNFTMarketplace.sol#L574) ```solidity function tokenURI( ``` - Found in contracts/HotelereumNFTMarketplace.sol [Line: 586](contracts/HotelereumNFTMarketplace.sol#L586) ```solidity function supportsInterface( ``` - [ ] ***NC-2: Constants should be defined and used instead of literals*** - Found in contracts/HotelereumNFTMarketplace.sol [Line: 181](contracts/HotelereumNFTMarketplace.sol#L181) ```solidity return 82110000; ``` - Found in contracts/HotelereumNFTMarketplace.sol [Line: 265](contracts/HotelereumNFTMarketplace.sol#L265) ```solidity return (_expirationDate - _startingDate) / 86400; ``` <mark>Mentioned in @dev tag</mark> - Found in contracts/HotelereumNFTMarketplace.sol [Line: 300](contracts/HotelereumNFTMarketplace.sol#L300) ```solidity uint256 rate = uint256(getLatestMaticPriceInUSD()) / 10 ** 2; ``` <mark>Decimal scaling for calculation purpose</mark> - Found in contracts/HotelereumNFTMarketplace.sol [Line: 305](contracts/HotelereumNFTMarketplace.sol#L305) ```solidity (10 ** 18) / rate; ``` <mark>Gas optimization purpose </mark> - Found in contracts/HotelereumNFTMarketplace.sol [Line: 408](contracts/HotelereumNFTMarketplace.sol#L408) ```solidity 100; ``` - Found in contracts/HotelereumNFTMarketplace.sol [Line: 409](contracts/HotelereumNFTMarketplace.sol#L409) ```solidity uint256 primaryHotelFee = (_amount * primaryHotelPercentage) / 100; ``` - Found in contracts/HotelereumNFTMarketplace.sol [Line: 433](contracts/HotelereumNFTMarketplace.sol#L433) ```solidity secondaryPlatformFeePercentage) / 100; ``` - Found in contracts/HotelereumNFTMarketplace.sol [Line: 434](contracts/HotelereumNFTMarketplace.sol#L434) ```solidity uint256 secondaryHotelFee = (_amount * secondaryHotelPercentage) / 100; ``` - Found in contracts/HotelereumNFTMarketplace.sol [Line: 435](contracts/HotelereumNFTMarketplace.sol#L435) ```solidity uint256 secondaryOwnerFee = (_amount * secondaryOwnerPercentage) / 100; ``` <mark> All these are for storage gas optimization purpose </mark> - [ ] ***NC-3: Does indexing cost outweigh storage costs (Follow up)*** Index event fields make the field more quickly accessible to off-chain tools that parse events. It should be checked if all events having indices are being emitted repeatedly. - Found in contracts/HotelereumNFTMarketplace.sol [Line: 102](contracts/HotelereumNFTMarketplace.sol#L102) ```solidity event InventoryItemCreated( ``` - Found in contracts/HotelereumNFTMarketplace.sol [Line: 121](contracts/HotelereumNFTMarketplace.sol#L121) ```solidity event MarketItemPayemt( ``` - Found in contracts/HotelereumNFTMarketplace.sol [Line: 128](contracts/HotelereumNFTMarketplace.sol#L128) ```solidity event PrimaryRevenueDistributed( ``` - Found in contracts/HotelereumNFTMarketplace.sol [Line: 135](contracts/HotelereumNFTMarketplace.sol#L135) ```solidity event SecondaryRevenueDistributed( ``` ## Issues Summary (Manual audit) Category | No. of Issues | | --- | --- | | Critical | 0| | High | 2 | | Medium |1 | | Low | 2| | NC |5 | ## Issues ### Critical Issues ### High Issues - [ ] ***H-1: initialize is a public function*** [Line 32]((contracts/HotelereumNFTMarketplace.sol#L435)). It can be called by anyone and they may change important parameters of the contract or change the contract address. ``` function initialize(address _maticOracleRoute) public initializer ``` - [ ] ***H-2 : ERC20 used instead of IERC20*** - [ ] ERC20 functions may not behave as expected. For example: return values are not always meaningful. It is recommended to use OpenZeppelin's SafeERC20 library. - Found in contracts/HotelereumNFTMarketplace.sol [Line: 410](contracts/HotelereumNFTMarketplace.sol#L410) ```solidity idToMarketItem[_tokenId].hotel.transfer(primaryHotelFee); ``` - Found in contracts/HotelereumNFTMarketplace.sol [Line: 411](contracts/HotelereumNFTMarketplace.sol#L411) ```solidity payable(owner()).transfer(primaryPlatformFee); ``` - Found in contracts/HotelereumNFTMarketplace.sol [Line: 436](contracts/HotelereumNFTMarketplace.sol#L436) ```solidity idToMarketItem[_tokenId].hotel.transfer(secondaryHotelFee); ``` - Found in contracts/HotelereumNFTMarketplace.sol [Line: 437](contracts/HotelereumNFTMarketplace.sol#L437) ```solidity payable(owner()).transfer(secondaryPlatformFee); ``` - Found in contracts/HotelereumNFTMarketplace.sol [Line: 438](contracts/HotelereumNFTMarketplace.sol#L438) ```solidity sellerWallet.transfer(secondaryOwnerFee); ### Medium Issues - [ ] ***M-1: Adding updatable function for enrolled entities*** ### Low Issues - [ ] ***L-1: use caching while using .length*** [line 255]((contracts/HotelereumNFTMarketplace.sol#L255)) ``` for (uint i; i < _propertyIds.length; ) { items[i] = hotelIdToInventory[_hotelId][_propertyIds[i]]; unchecked { ++i; } } ``` - [ ] ***L-2: use caching while using .length*** [line 284]((contracts/HotelereumNFTMarketplace.sol#L2)) ``` for (uint i; i < _propertyIds.length; ) { items[i] = hotelIdToInventory[_hotelId][_propertyIds[i]]; unchecked { ++i; } } ``` ### NC Issues - [ ] ***NC-1: Need to add natspec documentation*** [Line 32]((contracts/HotelereumNFTMarketplace.sol#L435)) - [ ] ***NC-2: Variable packing. must be careful while upgrading contract*** [Line 55](contracts/HotelereumNFTMarketplace.sol#L55) ***Storage Collision:*** In upgradable contracts, mixing up variable locations can cause storage collisions. This is extremely high Impact High likelihood error. ``` ThunderLoan.sol uint256 private s_feePrecision; uint256 private s_flashLoanFee; // 0.3% ETH fee ThunderLoanUpgraded.sol uint256 private s_flashLoanFee; // 0.3% ETH fee uint256 public constant FEE_PRECISION = 1e18; ``` So in upgraded contract flashLoanFee will be replaced by feePrecision. - [ ] ***NC-3: Events dont have natspec documentation*** [Line 104]((contracts/HotelereumNFTMarketplace.sol#L104)) - [ ] ***NC-4: Spelling Mistakes*** - Found in [Line:238](contracts/HotelereumNFTMarketplace.sol#L238) - Found in [Line:320](contracts/HotelereumNFTMarketplace.sol#L320) - Found in [Line:361](contracts/HotelereumNFTMarketplace.sol#L361) - Found in [Line:411](contracts/HotelereumNFTMarketplace.sol#L411) ``` function primeryRevenueDistribution( uint256 _tokenId, uint256 _amount ) private { ``` - Found in [Line:531](contracts/HotelereumNFTMarketplace.sol#L531) - [ ] ***NC-5: Inappropriate modifier naming*** [Line 163](contracts/HotelereumNFTMarketplace.sol#163) ``` modifier validHotelPartner(uint256 hotelId) { require(hotelIdToWallet[hotelId] != address(0), "Invalid Hotel ID"); _; } ```

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully