Download audit report
This document presents the security review performed by Nethermind on the Blockframe protocol. Blockframe is a marketplace for nonfungible tokens (NFTs) that supports on-chain royalties. Enabling users to buy, sell, and split royalty proceeds for NFT collections. The marketplace engine is an adapted version of the Seaport protocol, enabling royalty payments within the platform. The platform also introduces the Creator Studio, a user-friendly feature that simplifies NFT collection creation and customization for users.
The reviewed code comprises partially the two mentioned components. Nethermind reviewed the additions made to the Seaport marketplace, specifically the code enabling royalty payments. Additionally, the review encompassed the implementation of the Creator studio. Throughout this process, the Blockframe and Nethermind teams engaged in extensive discussions to deepen their understanding of the code and enhance the review’s effectiveness. However, it was observed that there is a notable lack of adequate testing and documentation accompanying these developments.
The audit was performed using (a) manual analysis of the codebase, (b) automated analysis tools, and (c) simulation of the smart contract. Along with this document, we report 18 points of attention, where one is classified as Critical, two are classified as High, three are classified as Medium, one are classified as Low, six are classified as Info and five are classified as Best Practices.
Remarks
Upon reviewing the source code of the project, to ensure the security and quality of the project, the Nethermind team suggests engaging in complementary security reviews and bug bounty programs.
Remarks
All the fixes were reviewed in an isolated manner. No full version of the code was reviewed during the fixes-review phase.
| Audit assessment | |
| Audit Type | Security Review |
| Initial Report | Nov 27, 2023 |
| Final Report | Jan 29, 2024 |
| Methods | Manual Review, Automated Analysis, Tests |
| Repository (Royalties, Creator-studio) | blockframeapp/audit |
| Commit Hash (Royalties, Creator-studio) | fd43ad3265 |
| Repository (Seaport modification) | blockframeapp/seaport |
| Commit Hash (Seaport modification) | 2cf367d2c1 |
| Documentation Assessment | Low |
| Test Suite Assessment | Low |
Findings by severity
| # | Contract | LoC | Comments | Ratio | Blank | Total |
| 1 | contracts/contracts/RoyaltyRegistrar.sol | 25 | 1 | 4.0% | 3 | 29 |
| 2 | contracts/contracts/RoyaltyRegistrarImpl.sol | 189 | 67 | 35.4% | 40 | 296 |
| 3 | contracts/contracts/creatorStudio/factory/GenerativeCollection.sol | 147 | 21 | 14.3% | 35 | 203 |
| 4 | contracts/contracts/creatorStudio/factory/OnlyOwnerCollection.sol | 26 | 19 | 73.1% | 11 | 56 |
| 5 | contracts/contracts/creatorStudio/factory/CollectionFactory.sol | 39 | 20 | 51.3% | 8 | 67 |
| 6 | contracts/contracts/creatorStudio/factory/GenerativeCollectionMetadata.sol | 19 | 1 | 5.3% | 1 | 21 |
| 7 | contracts/contracts/interfaces/ICurrencyManager.sol | 8 | 1 | 12.5% | 5 | 14 |
| Total | 453 | 130 | 28.7% | 103 | 686 |
Remarks
In addition to the files listed, the review also encompasses the modifications in the Seaport marketplace, particularly the changes facilitating royalty payments. The Seaport marketplace code was forked in commit a27eff9fa299a14c432666c8dc963aa072437dde
The Blockframe protocol’s Marketplace is a customized adaptation of the seaport protocol, tailored to support royalty payments within the system. At its core, the RoyaltyRegistrarImpl smart contract tracks royalties and enables their transfer, splitting, and withdrawal across diverse collections and currencies. Creators can claim royalty contracts for their collections, specifying precise royalty percentages. Furthermore, the contract owner possesses the authority to claim royalties for different collections, particularly for un-owned or revoked ownership instances.
Royalties are represented via an ERC20 token known as the Royalty Token. It is associated with each collection and its respective payment currency. These Royalty Tokens are tracked in the mapping hostContractToRoyaltyTokens[_hostContract][currency]. This mapping associates each host contract, representing a collection and its respective payment currency with the corresponding ERC20 Royalty Token. Users’ stake within the contract royalties are denoted by their balances in these tokens. For example, possessing 10% of the total Royalty Tokens for a specific collection signifies ownership of 10% of the future royalty revenue for that particular collection.
Deposits into the royalty system are open to any participant. Additionally, Token holders can withdraw, transfer, or split their tokens with other users. The alteration to the seaport protocol includes the addition of two fields to all order items: royaltyPaymentFor and frameIncentive. Orders involving royalty payments should include the payment as a token itself within the order, designating the RoyaltyRegistrarImpl as the recipient and specifying the associated host contract in the royaltyPaymentFor field. It is essential to note that the current on-chain implementation does not enforce the royalty percentage set by the contract claimer during payments. Instead, the off-chain system retrieves these percentages from the RoyaltyRegistrarImpl contract to compute appropriate royalty payments, which are subsequently included in the corresponding orders as royalty payments.
Blockframe’s Creator Studio is designed to support users in effortlessly creating, customizing, and managing NFT collections. The CollectionFactory contract enables users to create a generative collection or an only owner collection by calling the respective functions createGenerativeCollection(...), createOnlyOwnerCollection(...) from the CollectionFactory contract. The two types of collections differ in the functionality they offer:
GenerativeCollection is a more complex and flexible collection type. NFTs can be minted during the pre-sale and public sale periods. Only the whitelisted users can participate in the pre-sale. Apart from the whitelist, the collection creator specifies the currency in which he wants the users to pay for the NFTs. This can be either native Ether or ERC20 tokens. Funds gathered during these sales can be withdrawn by the owner by calling the withdraw(...) function. The 2% of these funds are sent to the protocol as fees. The collection owner can also reserve an arbitrary number of NFTs outside of the regular sale periods by calling the reserve(...) function.The risk rating methodology used by Nethermind Security follows the principles established by the OWASP Foundation. The severity of each finding is determined by two factors: Likelihood and Impact.
Likelihood measures how likely the finding is to be uncovered and exploited by an attacker. This factor will be one of the following values:
When defining the likelihood of a finding, other factors are also considered. These can include but are not limited to motive, opportunity, exploit accessibility, ease of discovery, and ease of exploit.
Impact is a measure of the damage that may be caused if an attacker exploits the finding. This factor will be one of the following values:
When defining the impact of a finding, other factors are also considered. These can include but are not limited to data and state integrity, loss of availability, financial loss, and reputation damage. After defining the likelihood and impact of an issue, the severity is determined according to the table below.
| Impact / Likelihood | Low | Medium | High |
| High | Medium | High | Critical |
| Medium | Low | Medium | High |
| Low | Info / Best Practices | Low | Medium |
| Undetermined | Undetermined | Undetermined | Undetermined |
To address issues that do not fit a High, Medium or Low severity, Nethermind Security also uses three more finding severities: Informational, Best Practices, and Undetermined.
ERC20 royalties deposited in the RoyaltyRegistrarImpl contract cannot be withdrawn| File | Fix commit | Type | Status |
RoyaltyRegistrarImpl.sol | — | Critical | Fixed |
The withdraw(...) function is used to withdraw the royalties deposited in the RoyaltyRegistrarImpl contract and transfer them to the recipient address. This function is supposed to handle both types of currencies that royalties can be denominated in - native tokens and ERC20 tokens. In the latter case, the tokens are transferred to the recipient by calling the transferFrom(...) function from the ERC20 standard. However, the problem with this function is that the spender requires the allowance to transfer the tokens successfully. The issue in the withdraw(...) function is that the spender - in this case, the RoyaltyRegistrarImpl contract does not have the necessary allowance to make the call to transferFrom(...) succeed. Whenever someone calls the withdraw(...) function to withdraw the deposited ERC20 royalties, the call will revert due to insufficient allowance. This failure causes the ERC20 royalties to be locked inside the RoyaltyRegistrarImpl contract. The snippet of the withdraw(...) function is presented below:
function withdraw(...) external override nonReentrant {
// ...
if (currency == address(0)) {
// ...
} else {
// @audit A call to `transferFrom` will revert due to insufficient allowance
require(IERC20(currency).transferFrom(address(this), recipient, availableRoyalties), "Transfer failed");
}
// ...
}Recommendation
Consider using transfer(...) instead of transferFrom(...).
Resolution
Changed to transfer.
RoyaltyRegistrarImpl.sol, leading to reverting order fulfillment| File | Fix commit | Type | Status |
RoyaltyRegistrarImpl.sol | — | High | Fixed |
Blockframe’s marketplace incorporates royalties by including the royalty payment in the concerned order. The contract supports payments in both ERC20 tokens and native tokens. Upon order fulfillment, the royalty payment is sent to the RoyaltyRegistrarImpl contract.
For payments made in native tokens, the _updateRoyaltiesIfNeeded(...) function is called, which updates the accounting of royalties in the RoyaltyRegistrarImpl contract by invoking the updateRoyalties(...) function and using a currency of address(0) to denote native tokens. Subsequently, the tokens are transferred to the contract within the _transferNativeTokens(...) function. Below is the code segment handling this process within the BasicOrderFullfiller contract:
// @audit calling `updateRoyalties(...)` function to account royalties
_updateRoyaltiesIfNeeded(token, address(0), additionalRecipientAmount, recipient);
// ...
// @audit Sending native tokens to the registrar contract
_transferNativeTokens(recipient, additionalRecipientAmount);The _transferNativeTokens(...) function sends native tokens to the RoyaltyRegistrarImpl contract via a low-level call. However, the latter contract does not implement the necessary functionality to receive native tokens. This results in every order fulfillment reverting when the order sends royalties in native tokens.
Recommendation
Add the necessary functionality to the RoyaltyRegistrarImpl contract to receive native tokens.
Resolution
Added receive() external payable.
Update from Nethermind Security
As an additional comment, any eth sent by an address different from seaport will be locked.
(HostContract, Currency) pair| File | Fix commit | Type | Status |
RoyaltyRegistrarImpl.sol | — | High | Fixed |
The RoyaltyRegistrarImpl contract allows users to claim Royalty contracts associated with their host contracts and specific currencies. It defines a mapping called hostContractToRoyaltyTokens, which stores the token address for each unique (host, currency) pair. However, the following issues in the code allow the deployment of multiple Royalty tokens pointing to the same (host, currency) pair.
1. In the mintRoyaltyToken(...) function, there is no check to ensure that a token hasn’t been minted before for a specific host contract and currency pair. This lack of validation allows the deployment of multiple tokens for the same pair;
function mintRoyaltyToken(address _hostContract, address currency) external virtual override {
// ...
// @audit deploys a new token for the host contract/currency pair
address token = createERC20("Royalty Token", "RT", claimed[_hostContract], currency, _hostContract);
// @audit If the token was deployed previously, its value will be overridden
hostContractToRoyaltyTokens[_hostContract][currency] = token;
// ...
}2. The claimRoyaltyForRevoked(...) function doesn’t verify whether the recipient address differs from zero. If a zero address is set, both claimRoyalty(...) and claimRoyaltyForRevoked(...) functions could be called as we will have claimed[_hostContract] == address(0), resulting in the deployment of another token with the same host contract and currency. The corresponding value in the hostContractToRoyaltyTokens mapping will be overridden.
function claimRoyaltyForRevoked(address _hostContract, uint256 _percentage, address recipient)
external
virtual
override
onlyOwner
{
require(claimed[_hostContract] == address(0), "Token already claimed.");
IContract hostContract = IContract(_hostContract);
address token = createERC20("Royalty Token", "RT", recipient, address(0), _hostContract);
// ...
// @audit recipient can be zero address
claimed[_hostContract] = recipient;
hostContractToRoyaltyTokens[_hostContract][address(0)] = token;
// ...
}Deploying multiple tokens for a single (host contract, currency) pair causes erroneous updates in the withdrawn mapping within the updateWithdrawn(...) function. These incorrect updates directly affect royalty computation and user withdrawals. Furthermore, this flaw enables malicious behavior by the host contract owner. Consider a scenario where users purchase royalty tokens for a specific host and currency pair. The host owner can maliciously deploy another token for the same pair, overriding the initial token in the hostContractToRoyaltyTokens mapping. Consequently, users cannot withdraw their earned royalties as their balances are zero in the new token.
Recommendation
Consider adding the relevant checks in both the mintRoyaltyToken(...) and the claimRoyaltyForRevoked(...) functions to ensure that only one token is deployed per host contract and currency.
Resolution
Added missing require(hostContractToRoyaltyTokens[_hostContract][currency] == address(0), "Royalty token minted"); in mintRoyaltyToken.
updateWithdrawn(...) function may lead to reward exploitation| File | Fix commit | Type | Status |
RoyaltyRegistrarImpl.sol | — | Medium | Fixed |
The updateWithdrawn(...) function is invoked during the transfer of RoyaltyTokens. This function is critical for updating the withdrawn mapping for both the sender and the receiver. The intent is to prevent the double-claiming of assets associated with the transferred RoyaltyTokens. However, an issue arises when calculating the transferredWithdrawn value within the function.
function updateWithdrawn(...) external onlyAuthorizedTokens {
uint256 senderBalance = IERC20(hostContractToRoyaltyTokens[hostContract][currency]).balanceOf(sender);
uint256 senderWithdrawn = withdrawn[hostContract][currency][sender];
uint256 recipientWithdrawn = withdrawn[hostContract][currency][recipient];
// @audit This division rounds down, causing the value `transferredWithdrawn`
// to be lower than it should be in certain cases.
uint256 transferredWithdrawn = (senderWithdrawn * amount) / senderBalance;
withdrawn[hostContract][currency][sender] = senderWithdrawn - transferredWithdrawn;
withdrawn[hostContract][currency][recipient] = recipientWithdrawn + transferredWithdrawn;
}The division used to compute transferredWithdrawn rounds down. This behavior can result in the transferredWithdrawn value being lower than it should be, particularly with small transfer amounts. For example, if user A transfers a fraction of their RoyaltyTokens to user B, the calculated transferredWithdrawn might round to zero. Consequently, the withdrawn mapping remains unchanged, allowing user B to claim rewards on the received tokens, even if those rewards were already claimed once. User A can repeat the process multiple times, claiming the already claimed rewards.
Recommendation
Consider rounding up when computing the transferredWithdrawn value.
- uint256 transferredWithdrawn = (senderWithdrawn * amount) / senderBalance;
+ uint256 transferredWithdrawn = (senderWithdrawn * amount + (senderBalance - 1)) / senderBalance;Resolution
Fixed exactly as recommended.
Update from Nethermind Security
It was noticed that the applied fix introduces an error similar to the one described. With the added code, the sender may decrease its withdrawn value more than it should, which could allow the sender to re-claim some rewards that were already claimed. Consider modifying the scheme used for accounting rewards. One possible solution would be to apply a model similar to the one used by Synthetix to track rewards.
Update from the client
Refactored to use a discrete staking rewards methodology:
function withdraw(address recipient, address hostContract, address currency) nonReentrant external override {
accrueUserRewardsInternal(recipient, hostContract, currency);
uint256 withdrawableAmount = rewards[recipient][hostContract][currency];
require(withdrawableAmount > 0, "No royalties available for withdrawal.");
rewards[recipient][hostContract][currency] = 0;
if (currency == address(0)) {
(bool success,) = recipient.call{value: withdrawableAmount}("");
require(success, "Transfer failed");
} else {
IERC20(currency).safeTransfer(recipient, withdrawableAmount);
}
emit Withdraw(recipient, hostContract, currency, withdrawableAmount);
}
function accrueUserRewardsInternal(address account, address hostContract, address currency) internal {
uint256 userBalance = IERC20(hostContractToRoyaltyTokens[hostContract][currency]).balanceOf(account);
uint256 owed = (userBalance * (globalIndex[hostContract][currency] - userIndex[account][hostContract][currency])) / PRECISION_FACTOR;
rewards[account][hostContract][currency] += owed;
userIndex[account][hostContract][currency] = globalIndex[hostContract][currency];
}reserve(...) function will reserve more NFTs than it should| File | Fix commit | Type | Status |
GenerativeCollection.sol | — | Medium | Fixed |
The reserve(...) function is used by the collection owner to reserve some NFTs aside from the sale/presale process. The owner specifies an amount of the NFTs to be minted to his address. The _safeMint(...) function from the ERC721A is called for each NFT to be minted. However, the problem with this function is that it mints multiple NFTs simultaneously, unlike OpenZeppelin’s ERC721 implementation, which mints only one token at a time. In the code snippet below, supply + i tokens will be minted for each loop iteration.
function reserve(...) public onlyOwner {
uint256 supply = totalSupply();
uint256 i;
for (i = 0; i < amount; i++) {
// @audit Will mint supply + i NFTs for each loop iteration
_safeMint(msg.sender, supply + i);
}
// ...
}The number of tokens minted depends on the amount specified by the owner and the already existing totalSupply of tokens. The reserve(...) function can be called anytime. It is not bound to the sale status. This means that the total number of tokens reserved by the collection owner will be higher if there was a sale already and the total supply was increased.
A numerical example: There were 10 NFTs sold in the last sale. The collection owner decides to reserve 5 additional NFTs. A call to reserve(...) with an amount of 5 will mint 10 NFTs in the first loop iteration, 11 in the second, 12 in the third, and so on...
Recommendation
Consider removing the loop and mint an appropriate amount of NFTs by calling the ERC721A’s _safeMint(...) function with the desired amount of tokens to be reserved.
Resolution
Fixed:
function reserve(uint256 amount) public onlyOwner {
uint256 supply = totalSupply();
require(supply + amount <= metadata.totalSupply, "Purchase would exceed max supply of NFTs");
_safeMint(msg.sender, amount);
address seller = owner();
uint256 totalCost = 0;
emit GenerativeCollectionMint(msg.sender, seller, amount, totalCost, supply, MARKETPLACE_HASH);
}| File | Fix commit | Type | Status |
RoyaltyRegistrarImpl.sol | — | Medium | Acknowledged |
There are multiple situations that can be caused in the Blockframe systems by users with enough privileges. These situations could occur, for example, due to a privilege key being compromised or similar. Below we list examples of those situations:
claimRoyaltyForRevoked(). This function is expected to be used when the NFT host contract does not implement the owner() function. The owners of the NFT host contract can then ask Blockframe to call the function and update the contract’s royalties mapping. That is where centralization risk lies, as it can be used by the owner to create royalty for any NFT contract in the system without any checks;Recommendation
Consider setting multi-sig accounts as owner when possible and clearly stating the risks of using the system.
Resolution
setSeaport mitigated by the fact it can only be set once and provably so;depositRoyalties(...) function, resulting in locked funds| File | Fix commit | Type | Status |
RoyaltyRegistrarImpl | — | Low | Fixed |
The depositRoyalties(...) function allows users to deposit royalties for a specific host contract and currency. However, in the case where the currency is native ETH, the code enforces a condition where the transferred ETH amount msg.value must be strictly greater than the specified amount. This requirement forces users to send at least one extra wei, which is unnecessary. Furthermore, the function only accounts for the specified amount in the royaltyBalances mapping, leaving any surplus ETH (msg.value - amount) locked in the contract as there is no way to utilize or withdraw it.
function depositRoyalties(...) nonReentrant external override payable {
// ...
if (currency != address(0)) {
require(IERC20(currency).transferFrom(msg.sender, address(this), amount), "Transfer failed");
} else {
// @audit user is enforced to transfer more than the accounted amount
require(msg.value > amount, "Insufficient funds");
}
royaltyBalances[hostContract][currency] += amount; // @audit only `amount` is accounted for
// ...
}Recommendation
In order to align the expected deposit amount with the required value, consider updating the condition to accept the exact expected amount:
require(msg.value == amount, "Insufficient funds");Resolution
Resolved exactly as recommended.
| File | Fix commit | Type | Status |
RoyaltyRegistrarImpl.sol | — | Info | Fixed |
The setPercentage (...) function changes the expected royalties percentage from the sale of an asset from the _hostContract collection. The caller of this function must own the majority of the tokens representing rights over these royalties.
function setPercentage(address _hostContract, uint256 _newPercentage) external virtual override {
require(_newPercentage <= 10 ** 20, "Maximum royalty is 100%");
address royaltyToken = hostContractToRoyaltyTokens[_hostContract][address(0)];
uint256 totalSupply = IERC20(royaltyToken).totalSupply();
uint256 callerBalance = IERC20(royaltyToken).balanceOf(msg.sender);
// @audit The majority is not checked correctly
require(callerBalance >= totalSupply / 2, "Caller does not own a majority of the token supply");
require(_newPercentage <= percentages[_hostContract], "New royalty cannot be more than current royalty");
percentages[_hostContract] = _newPercentage;
emit NewPercentage(_hostContract, _newPercentage);
}However, the condition that checks the majority is not implemented correctly. The operator used is >= instead of =, allowing the owner of half of the tokens to modify the percentage.
Recommendation
Consider using > instead of >=.
Resolution
Fixed exactly as recommended.
| File | Fix commit | Type | Status |
RoyaltyRegistrarImpl.sol | — | Info | Acknowledged |
The collection owner can specify any currency(token) for his royalty payments. This can lead to potential problems when the currency is a rebasing token, such as sETH.
The rebasing tokens are changing their supply based on the token’s price, posing a problem during royalties withdrawal. When a certain amount of royalties is deposited and accounted for in the contract (using the depositRoyalties(...) or updateRoyalties(...) functions), it can be decreased with time, resulting in the withdraw(...) function potentially reverting as it will compute the royalties to be withdrawn based on the initially deposited amount.
Recommendation
To avoid potential losses related to the behavior of rebasing tokens, consider explicitly stating in the documentation that Blockframe does not support the use of rebasing tokens for royalty payments.
Resolution
OK
| File | Fix commit | Type | Status |
RoyaltyRegistrarImpl.sol | — | Info | Fixed |
claimRoyalty(...) and claimRoyaltyForRevoked(...) functions allow for claiming the royalty token for a specific host contract with a certain royalty percentage. However, these functions are missing a check for the validity of the provided percentage, making it possible to pass invalid values as a percentage higher than 100%.
function claimRoyalty(address _hostContract, uint256 _percentage) external virtual override {
// ...
// @audit missing check that `_percentage` is within a valid range
percentages[_hostContract] = _percentage;
// ...
}Recommendation
Consider adding a check for both claimRoyalty(...) and claimRoyaltyForRevoked(...) functions so that the provided percentage is within a valid range.
Resolution
Added require(_percentage <= MAX_PERCENTAGE, "Maximum royalty is 100%");
reserve(...) function| File | Fix commit | Type | Status |
GenerativeCollection.sol | — | Info | Fixed |
The generativeCollection contract includes a totalSupply field in its metadata, which specifies the maximum supply of the NFT. This value is enforced during every mint action to prevent surpassing the defined limit.
The contract defines the reserve(...) function, allowing the owner to reserve some tokens for themselves. However, This function mints the desired amount to be reserved without checking whether this will result in exceeding the supply limit defined in metadata.totalSupply.
function reserve(uint256 amount) public onlyOwner {
// @audit `metadata.totalSupply` can be exceeded after minting `amount`
uint256 supply = totalSupply();
uint256 i;
for (i = 0; i < amount; i++) {
_safeMint(msg.sender, supply + i);
}
emit GenerativeCollectionMint(address(this), amount);
}Recommendation
Implement a check within the reserve(...) function to comply with the totalSupply limit specified in the metadata.
Resolution
Decided not to fix it as it’s the owner’s collection. They can do whatever they want. Increase the supply, update the base URI.
Update from Nethermind Security
The mentioned issue was actually fixed in the received commit.
split(...) function| File | Fix commit | Type | Status |
RoyaltyRegistrarImpl.sol | — | Info | Fixed |
The split(...) function performs unnecessary checks for underflows. Solidity v0.8.0 introduced default overflow checks for arithmetic operations, making the function revert in these cases. Hence, the checks after the computation are ineffective.
function split(...) external virtual override {
// ...
for (uint256 i = 0; i < addresses.length; i++) {
amount = totalAmount * weights[i] / 1e20;
// @audit Computation reverts if `remainingAmount < amount`, the following check is unnecessary
remainingAmount = remainingAmount - amount;
require(remainingAmount <= totalAmount, "Integer overflow");
require(IERC20(token).transferFrom(msg.sender, addresses[i], amount), "Transfer failed");
}
// @audit Unnecessary check as the function reverts sooner when an underflow/overflow occurs
require(remainingAmount <= totalAmount, "Integer overflow");
}Recommendation
Consider removing unnecessary checks.
Resolution
Fixed exactly as recommended.
SafeERC20 is imported but not used| File | Fix commit | Type | Status |
RoyaltyRegistrarImpl.solGenerativeCollection.sol | — | Info | Fixed |
The SafeERC20 wrapper for ERC20 tokens from Openzeppelin is imported but not used. A list of files where this issue is present is shown below:
RoyaltyRegistrarImpl.sol
function split
function withdraw
function depositRoyalties
GenerativeCollections.sol
function withdrawRecommendation
Consider using the SafeERC20 wrapper for ERC20 operations or remove the import if it won’t be used.
Resolution
Using SafeERC20 now.
Update from Nethermind Security
transfer(...) is still used in GenerativeCollection.sol contract instead of safeTransfer(...).
Update from the client
Fixed.
| File | Fix commit | Type | Status |
RoyaltyRegistrarImpl | — | Best Practices | Fixed |
A magic number is a numerical value hard-coded in the source code, which, without the context, does not give away the developer’s intent in using that number. A proposed solution to this anti-pattern is to define a constant with a meaningful name instead of the magic number.
An example of this behavior is the number 10ˆ20 in the setPercentage(...) function. Since it represents the maximum royalty percentage, it could be replaced with a constant MAX_ROYALTY_PERCENTAGE, which is much easier to understand and change in the future.
Another occurrence is in the withdraw(...) function, which defines a hardcoded variable totalSupply, representing the total supply of the Royalty token. This value is also hardcoded in the RoyaltyToken contract. Maintaining this value in multiple places increases the risk of inconsistencies, as one value can be updated without the other, potentially leading to inaccuracies in royalty computations. This can be fixed by storing this value in a constant that both functions will use.
Recommendation
Consider implementing the fixes to the abovementioned issues.
| File | Fix commit | Type | Status |
CollectionFactory.sol | — | Best Practices | Acknowledged |
The function createGenerativeCollection(...) is used by users to create and deploy their own NFT collections. To do so, the user must provide the collection metadata, which, among others, contains information about the sale/presale start and end times and maximum token mints in each period. The lack of input validation makes the following scenarios possible:
block.timestamp;address(0) check on the feeRecipient might result in a loss of fees if the collection creator forgets to set this address correctly, as it is not possible to update the feeRecipient address after the collection is created;0) can be started with a presaleMaxMint of 0;Recommendation
Consider improving the input validation on the user-provided input to prevent the above scenarios from happening.
getWithdrawn(...) function| File | Fix commit | Type | Status |
RoyaltyRegistrarImpl.sol | — | Best Practices | Fixed |
The getWithdrawn(...) function within the RoyaltyRegistrarImpl contract returns the withdrawn amounts by the msg.sender for a provided list of host contracts with their respective currencies. The function checks that the provided arrays have the same length and that both lengths differ from zero. The check of the second array’s length is redundant and can be safely removed as the two arrays have the same size.
function getWithdrawn(address[] calldata hostContracts, address[] calldata currencies)
external
view
override
returns (uint256[] memory)
{
require(hostContracts.length == currencies.length, "Different length input");
// @audit checking the second array length is unnecessary
require(hostContracts.length != 0 && currencies.length != 0, "Zero length");
// ...
}Recommendation
Remove the redundant check for currencies.length != 0.
Resolution
Fixed exactly as recommended.
| File | Fix commit | Type | Status |
* | — | Best Practices | Fixed |
The codebase contains some unused code, affecting overall readability and code quality. A list of files and their unused declarations are shown below:
GenerativeCollection.sol
Counters.Counter _tokenIds
RoyaltyRegistrar.sol
event WithdrawAll
RoyaltyRegistrarImpl.sol
function claimRoyaltyForRevoked(...) -> IContract hostContract
GenerativeCollection.sol
function _setTokenURI(uint256 tokenId, string memory _tokenURI)Recommendation
Consider removing the unused code shown above.
Resolution
Removed.
_safeMint(...) instead of _mint(...) in OnlyOwnerCollection| File | Fix commit | Type | Status |
OnlyOwnerCollection.sol | — | Best Practices | Acknowledged |
The mintNFT(...) function mints an NFT of OnlyOwnerCollection. However, when the function is called, it mints an NFT via the internal function _mint(...). This is not a safe approach, as the contract should ensure that the recipient can manage NFTs.
For that purpose, the _safeMint(...) should be used to check if the receiver can handle NFTs. This is a good practice to mitigate any possible lock of NFT in some contracts.
Recommendation
Use _safeMint instead of _mint to mitigate any possible lock of NFT in the recipient contract.
Resolution
Pending solution, might delete this contract completely soon.
Software documentation refers to the written or visual information that describes the functionality, architecture, design, and implementation of software. It provides a comprehensive overview of the software system and helps users, developers, and stakeholders understand how the software works, how to use it, and how to maintain it. Software documentation can take different forms, such as user manuals, system manuals, technical specifications, requirements documents, design documents, and code comments. Software documentation is critical in software development, enabling effective communication between developers, testers, users, and other stakeholders. It helps to ensure that everyone involved in the development process has a shared understanding of the software system and its functionality. Moreover, software documentation can improve software maintenance by providing a clear and complete understanding of the software system, making it easier for developers to maintain, modify, and update the software over time. Smart contracts can use various types of software documentation. Some of the most common types include:
These types of documentation are essential for smart contract development and maintenance. They help ensure that the contract is properly designed, implemented, and tested, and they provide a reference for developers who need to modify or maintain the contract in the future.
Documentation, mainly in the form of Natspec and comments, was found within the contracts. Additionally, the Blockframe team participated in several meetings to facilitate our understanding of the protocol. However, the documentation for the reviewed contracts lacks completeness and details, falling short of providing a comprehensive understanding.
| 1Tests passed | 0Failed |
The complete test output is in the full report.
As auditors, we recommend that any changes or updates made to the audited codebase undergo a re-audit or security review to address potential vulnerabilities or risks introduced by the modifications. By conducting a re-audit or security review of the modified codebase, you can significantly enhance the overall security of your system and reduce the likelihood of exploitation. However, we do not possess the authority or right to impose obligations or restrictions on our clients regarding codebase updates, modifications, or subsequent audits. Accordingly, the decision to seek a re-audit or security review lies solely with you.
This report is based on the scope of materials and documentation provided by you to Nethermind in order that Nethermind could conduct the security review outlined in 1. Executive Summary and 2. Audited Files. The results set out in this report may not be complete nor inclusive of all vulnerabilities. Nethermind has provided the review and this report on an as-is, where-is, and as-available basis. You agree that your access and/or use, including but not limited to any associated services, products, protocols, platforms, content, and materials, will be at your sole risk. Blockchain technology remains under development and is subject to unknown risks and flaws. The review does not extend to the compiler layer, or any other areas beyond the programming language, or other programming aspects that could present security risks. This report does not indicate the endorsement of any particular project or team, nor guarantee its security. No third party should rely on this report in any way, including for the purpose of making any decisions to buy or sell a product, service or any other asset. To the fullest extent permitted by law, Nethermind disclaims any liability in connection with this report, its content, and any related services and products and your use thereof, including, without limitation, the implied warranties of merchantability, fitness for a particular purpose, and non-infringement. Nethermind does not warrant, endorse, guarantee, or assume responsibility for any product or service advertised or offered by a third party through the product, any open source or third-party software, code, libraries, materials, or information linked to, called by, referenced by or accessible through the report, its content, and the related services and products, any hyperlinked websites, any websites or mobile applications appearing on any advertising, and Nethermind will not be a party to or in any way be responsible for monitoring any transaction between you and any third-party providers of products or services. As with the purchase or use of a product or service through any medium or in any environment, you should use your best judgment and exercise caution where appropriate. FOR AVOIDANCE OF DOUBT, THE REPORT, ITS CONTENT, ACCESS, AND/OR USAGE THEREOF, INCLUDING ANY ASSOCIATED SERVICES OR MATERIALS, SHALL NOT BE CONSIDERED OR RELIED UPON AS ANY FORM OF FINANCIAL, INVESTMENT, TAX, LEGAL, REGULATORY, OR OTHER ADVICE.
The Leading Engineers of Blockchain Infrastructure