CFLOW
Smart Contract Audit Report
Audit Summary
The CFLOW Team is building a new marketplace for their CFLOW NFT.
For this audit, we reviewed the CFLOW and CFLOWFactory contracts provided to us by the project team.
Audit Findings
Please ensure trust in the team prior to investing as they have substantial control in the ecosystem.
Date: April 12th, 2022.
Updated: April 20th, 2022 to resolve findings #1, #2, #3, and #4.Finding #1 - CFLOWFactory - High (Resolved)
Description: The withdraw() function issues a call() to send ETH to itself and the contract has no fallback or receive function.Risk/Impact: When called this function will fail and ETH is stuck in the contract.address(this).call{ value: address(this).balance }("");
Recommendation: The team should execute the call to the intended withdraw destination.
Resolution: The team has implemented a receive function.Finding #2 - CFLOWFactory - High (Resolved)
Description: The mintAndBuy() and buy() functions pass msg.value to calculateFeeAndSendFunds() as the price.Risk/Impact: Users can supply zero ETH and still be able to mint and buy tokens.require (calculateFeeAndSendFunds(owner, marketPlaceList[tokenId].creator, msg.value), "Failed to send funds"); ... function calculateFeeAndSendFunds(address owner, address creator, uint256 price) private returns (bool) { require(msg.value >= price, "Insufficient price value sent");
Recommendation: The team should consider if it is intended that buyers using mintAndBuy() and buy() set their own price.
Resolution: The team has implemented appropriate checks to ensure buyers are sending ETH equal to the listing price.Finding #3 - CFLOWFactory - Low (Resolved)
Description: The contract relies on NFTs being sent via safeTransfer().
Risk/Impact: NFTs transferred to the CFLOWFactory contract will be stuck if not sent via a safeTransfer().
Recommendation: The team should override the ERC721 transferFrom() to either deny its use or implement an onERC721Recieved() check.
Resolution: The team has overridden the ERC721 transferFrom() function.Finding #4 - CFLOWFactory - Informational (Resolved)
Description: The contract is implemented using Solidity v0.8.0 which is protected against overflow/underflow errors.
Recommendation: The SafeMath library can be removed for additional gas savings.
Resolution: The team has removed the SafeMath library.
Contracts Overview
CFLOW Contract:
- The contracts utilize ReentrancyGuard to prevent against reentrancy attacks in applicable functions.
- As the contracts are implemented with Solidity v0.8.0, they are safe from any possible overflows/underflows.
CFLOWFactory Contract:
- This contract is used to facilitate the creation of CFLOW NFTs.
- In the event that the address being minted a CFLOW NFT is a contract, the contract must have implemented the onERC721Received() function in order to successfully receive the NFT.
- The token owner or any address approved by the token owner can burn any token at any time.
- The token owner or any address approved by the token owner can set the token's URI to any value at any time.
- The Owner can transfer ownership to any address at any time.
- The Owner can pause or unpause minting at any time.
- The Owner can update the factory address that is able to mint to any address at any time.
- This contract complies with the ERC-721 standard.
- This contract is used to create and trade CFLOW NFTs.
- Users can mint CFLOW NFTs to the contract and provide a listing price; those NFTs can then be bought from the contract by other users.
- Users need to pass in the exact ETH required for an NFT to be successfully bought.
- A fee is taken on every NFT purchase and sent to a wallet controlled by the team.
- An additional creator fee is taken on every NFT purchase and sent to the address of the NFT creator.
- Users have the choice of minting and then buying a CFLOW NFT, in which case the token is sent to the minter and fees are collected on the payment. NFTs minted in this way have an associated price determined and paid by the minter.
- Users can mint batches of up to 20 CFLOW NFTs directly to the contract to be listed for sale. NFTs minted in this way have an associated price determined by the minter.
- On receiving a valid CFLOW NFT, the contract will list that token for sale.
- The Owners can set the address to which fees are sent to any address at any time.
- The Owners can set the fee rates to any value up to 100%.
- The Owners can add or remove any address from a blacklist at any time; this prevents that address from minting NFTs.
- The Owners can add or remove other addresses as Owners at any time.
- The Owners can set the address of the CFLOW NFT token being traded to any address at any time.
Audit Results
Vulnerability Category | Notes | Result |
---|---|---|
Arbitrary Jump/Storage Write | N/A | PASS |
Centralization of Control |
| WARNING |
Compiler Issues | N/A | PASS |
Delegate Call to Untrusted Contract | N/A | PASS |
Dependence on Predictable Variables | N/A | PASS |
Ether/Token Theft | N/A | PASS |
Flash Loans | N/A | PASS |
Front Running | N/A | PASS |
Improper Events | N/A | PASS |
Improper Authorization Scheme | N/A | PASS |
Integer Over/Underflow | N/A | PASS |
Logical Issues | N/A | PASS |
Oracle Issues | N/A | PASS |
Outdated Compiler Version | N/A | PASS |
Race Conditions | N/A | PASS |
Reentrancy | N/A | PASS |
Signature Issues | N/A | PASS |
Unbounded Loops | N/A | PASS |
Unused Code | N/A | PASS |
Overall Contract Safety | PASS |
CFLOW Contract
($) = payable function
# = non-constant function
Int = Internal
Ext = External
Pub = Public
+ [Int] IERC165
- [Ext] supportsInterface
+ [Int] IERC721 (IERC165)
- [Ext] balanceOf
- [Ext] ownerOf
- [Ext] safeTransferFrom #
- [Ext] transferFrom #
- [Ext] approve #
- [Ext] getApproved
- [Ext] setApprovalForAll #
- [Ext] isApprovedForAll
- [Ext] safeTransferFrom #
+ [Int] IERC721Receiver
- [Ext] onERC721Received #
+ [Int] IERC721Metadata (IERC721)
- [Ext] name
- [Ext] symbol
- [Ext] tokenURI
+ [Lib] Address
- [Int] isContract
- [Int] sendValue #
- [Int] functionCall #
- [Int] functionCall #
- [Int] functionCallWithValue #
- [Int] functionCallWithValue #
- [Int] functionStaticCall
- [Int] functionStaticCall
- [Int] functionDelegateCall #
- [Int] functionDelegateCall #
- [Int] verifyCallResult
+ Context
- [Int] _msgSender
- [Int] _msgData
+ [Lib] Strings
- [Int] toString
- [Int] toHexString
- [Int] toHexString
+ ERC165 (IERC165)
- [Pub] supportsInterface
+ ERC721 (Context, ERC165, IERC721, IERC721Metadata)
- [Pub] #
- [Pub] supportsInterface
- [Pub] balanceOf
- [Pub] ownerOf
- [Pub] name
- [Pub] symbol
- [Pub] tokenURI
- [Int] _baseURI
- [Pub] approve #
- [Pub] getApproved
- [Pub] setApprovalForAll #
- [Pub] isApprovedForAll
- [Pub] transferFrom #
- [Pub] safeTransferFrom #
- [Pub] safeTransferFrom #
- [Int] _safeTransfer #
- [Int] _exists
- [Int] _isApprovedOrOwner
- [Int] _safeMint #
- [Int] _safeMint #
- [Int] _mint #
- [Int] _burn #
- [Int] _transfer #
- [Int] _approve #
- [Int] _setApprovalForAll #
- [Prv] _checkOnERC721Received #
- [Int] _beforeTokenTransfer #
- [Int] _afterTokenTransfer #
+ ERC721URIStorage (ERC721)
- [Pub] tokenURI
- [Int] _setTokenURI #
- [Int] _burn #
+ [Lib] Counters
- [Int] current
- [Int] increment #
- [Int] decrement #
- [Int] reset #
+ CFLOW (ERC721URIStorage)
- [Pub] #
- modifiers: ERC721
- [Pub] owner
- [Pub] transferOwnership #
- modifiers: onlyOwner
- [Int] _transferOwnership #
- [Pub] mintNew #
- [Pub] setTokenMetadata #
- [Pub] exists
- [Pub] burn #
- [Pub] setMintActive #
- modifiers: onlyOwner
CFLOWFactory Contract
($) = payable function
# = non-constant function
Int = Internal
Ext = External
Pub = Public
+ [Int] IERC20
- [Ext] totalSupply
- [Ext] balanceOf
- [Ext] transfer #
- [Ext] allowance
- [Ext] approve #
- [Ext] transferFrom #
+ [Int] IERC165
- [Ext] supportsInterface
+ [Int] IERC721 (IERC165)
- [Ext] balanceOf
- [Ext] ownerOf
- [Ext] safeTransferFrom #
- [Ext] transferFrom #
- [Ext] approve #
- [Ext] getApproved
- [Ext] setApprovalForAll #
- [Ext] isApprovedForAll
- [Ext] safeTransferFrom #
+ [Int] IERC721Receiver
- [Ext] onERC721Received #
+ [Lib] SafeMath
- [Int] tryAdd
- [Int] trySub
- [Int] tryMul
- [Int] tryDiv
- [Int] tryMod
- [Int] add
- [Int] sub
- [Int] mul
- [Int] div
- [Int] mod
- [Int] sub
- [Int] div
- [Int] mod
+ ReentrancyGuard
- [Pub] #
+ [Int] IERC721Metadata (IERC721)
- [Ext] name
- [Ext] symbol
- [Ext] tokenURI
+ [Lib] Address
- [Int] isContract
- [Int] sendValue #
- [Int] functionCall #
- [Int] functionCall #
- [Int] functionCallWithValue #
- [Int] functionCallWithValue #
- [Int] functionStaticCall
- [Int] functionStaticCall
- [Int] functionDelegateCall #
- [Int] functionDelegateCall #
- [Int] verifyCallResult
+ Context
- [Int] _msgSender
- [Int] _msgData
+ [Lib] Strings
- [Int] toString
- [Int] toHexString
- [Int] toHexString
+ ERC165 (IERC165)
- [Pub] supportsInterface
+ ERC721 (Context, ERC165, IERC721, IERC721Metadata)
- [Pub] #
- [Pub] supportsInterface
- [Pub] balanceOf
- [Pub] ownerOf
- [Pub] name
- [Pub] symbol
- [Pub] tokenURI
- [Int] _baseURI
- [Pub] approve #
- [Pub] getApproved
- [Pub] setApprovalForAll #
- [Pub] isApprovedForAll
- [Pub] transferFrom #
- [Pub] safeTransferFrom #
- [Pub] safeTransferFrom #
- [Int] _safeTransfer #
- [Int] _exists
- [Int] _isApprovedOrOwner
- [Int] _safeMint #
- [Int] _safeMint #
- [Int] _mint #
- [Int] _burn #
- [Int] _transfer #
- [Int] _approve #
- [Int] _setApprovalForAll #
- [Prv] _checkOnERC721Received #
- [Int] _beforeTokenTransfer #
- [Int] _afterTokenTransfer #
+ ERC721URIStorage (ERC721)
- [Pub] tokenURI
- [Int] _setTokenURI #
- [Int] _burn #
+ [Lib] Counters
- [Int] current
- [Int] increment #
- [Int] decrement #
- [Int] reset #
+ CFLOW (ERC721URIStorage)
- [Pub] #
- modifiers: ERC721
- [Pub] owner
- [Pub] transferOwnership #
- modifiers: onlyOwner
- [Int] _transferOwnership #
- [Pub] mintNew #
- [Pub] setTokenMetadata #
- [Pub] exists
- [Pub] burn #
- [Pub] setMintActive #
- modifiers: onlyOwner
+ CFLOWFactory (IERC721Receiver, ReentrancyGuard)
- [Pub] #
- [Pub] onERC721Received #
- [Ext] addOwner #
- modifiers: onlyOwner
- [Ext] removeOwner #
- modifiers: onlyOwner
- [Ext] isOwner
- [Ext] addToBlacklist #
- modifiers: onlyOwner
- [Ext] removeFromBlacklist #
- modifiers: onlyOwner
- [Ext] isBlacklisted
- [Ext] setFeeAddress #
- modifiers: onlyOwner
- [Ext] setFeeRate #
- modifiers: onlyOwner
- [Ext] setCreatorFeeRate #
- modifiers: onlyOwner
- [Ext] getFeeInfo
- [Ext] setNFTAddress #
- modifiers: onlyOwner
- [Ext] setActive #
- modifiers: nftSet,nonReentrant
- [Ext] setInactive #
- modifiers: nftSet,nonReentrant
- [Ext] mintTo #
- modifiers: nftSet,nonReentrant
- [Ext] mintAndBuy ($)
- modifiers: nftSet,nonReentrant
- [Ext] mintAndActivate #
- modifiers: nftSet,nonReentrant
- [Ext] batchMintAndActivate #
- modifiers: nftSet,nonReentrant
- [Ext] buy ($)
- modifiers: nftSet,nonReentrant
- [Prv] calculateFeeAndSendFunds #
- [Pub] withdraw ($)
- modifiers: onlyOwner
About SourceHat
SourceHat has quickly grown to have one of the most experienced and well-equipped smart contract auditing teams in the industry. Our team has conducted 1800+ 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!
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 SourceHat Audit?
Typically, a smart contract audit is a comprehensive review process designed to discover logical errors, security vulnerabilities, and optimization opportunities within code. A SourceHat 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.