Introduction
We express our gratitude to the NF3x team for the collaborative engagement that enabled the execution of this Smart Contract Security Assessment.
Nf3x is a multi-asset swaps and options platform to barter, reserve & exchange your favourite NFT collections, entirely peer-to-peer.
| title | content |
|---|---|
| Platform | EVM |
| Language | Solidity |
| Tags | Airdrop, EIP712 |
| Timeline | 07/05/2023 - 23/06/2023 |
| Methodology | https://hackenio.cc/sc_methodology→ |
Review Scope | |
|---|---|
| Repository | https://github.com/NF3Labs/contracts-V2→ |
| Commit | a69718e71ba8a6e220ff8665c2799abd8cad8327 |
Review Scope
- Repository
- https://github.com/NF3Labs/contracts-V2→
- Commit
- a69718e71ba8a6e220ff8665c2799abd8cad8327
Audit Summary
10/10
72.73%
10/10
10/10
The system users should acknowledge all the risks summed up in the risks section of the report
Document Information
This report may contain confidential information about IT systems and the intellectual property of the Customer, as well as information about potential vulnerabilities and methods of their exploitation.
The report can be disclosed publicly after prior consent by another Party. Any subsequent publication of this report shall be without mandatory consent.
Document | |
|---|---|
| Name | Smart Contract Code Review and Security Analysis Report for NF3x |
| Audited By | Hacken |
| Website | https://nf3.exchange/→ |
| Changelog | 12/05/2023 - Initial Review |
| 31/05/2023 - Second Review | |
| 23/06/2023 - Third Review |
Document
- Name
- Smart Contract Code Review and Security Analysis Report for NF3x
- Audited By
- Hacken
- Website
- https://nf3.exchange/→
- Changelog
- 12/05/2023 - Initial Review
- 31/05/2023 - Second Review
- 23/06/2023 - Third Review
System Overview
The audit scope consists of individual helper contracts for an NFT swapping platform that handles signature verification, validations for certain inputs, variable storage, Airdrops, and data types used in the platform. This audit covers only part of the project that includes 2 functionalities.
Airdrop. The protocol wants to allow users to benefit from airdrops even when their NFTs are locked in DEX contracts.
Signatures. The protocol wants to implement the EIP-712 standard for signatures.
The files in the scope:
SigningUtil.sol: Handles the signature verifications in the platform by using the EIP712 standard.
AirdropClaim.sol: The contract to claim airdrops using NFTs that are reserved and locked in the vault. This allows users to continue receiving airdrops even if their NFTs are locked.
ValidationUtils.sol: Contract to validate complex inputs in the system and ensure that the inputs are not corrupted.
StorageRegistry.sol: The interface that defines all the functions related to storage for the protocol.
DataTypes.sol: The contract that defines complex structs used in the system.
IStorageRegistry.sol: Interface for the StorageRegistry.sol contract.
LoanDataTypes.sol: The contract that defines complex structs related to Loans in the system.
ISigningUtils.sol: Interface for the SigningUtil.sol contract.
ERC2771ContextUpgradeable.sol: The upgradeable implementation of the EIP2721 Meta transactions standard, which is implemented by Openzeppellin.
IAirdropClaim.sol: Interface for the AirdropClaim.sol contract.
IWhitelist.sol: The interface that defines all the functions related to the whitelisting of tokens. The implementation of the interface is out of scope.
Privileged roles
AirdropClaim :
Reserve contract :
Can claim an airdrop.
Can transfer ownership and complete reservation.
Owner :
Can withdraw assets.
StorageRegistry :
only approved (swap contract, reserve contract or loan contract) :
Can set the nonce.
Can set the claim contract address.
Owner :
Can set the market address.
Can set the vault address.
Can set the reserve address.
Can set the whitelist address.
Can set the swap address.
Can set the loan address.
Can set the signing util address.
Can set the airdrop claim address.
Can set the position token address.
Signer: The address that creates signatures to be validated using the SigningUtil.sol contract.
Executive Summary
Documentation quality
The total Documentation quality score is 10 out of 10.
Functional requirements are present for the functionalities covered in this audit.
Technical description of the contracts is present.
Development environment description is present.
NatSpecs are satisfactory.
Code quality
The total Code quality score is 10 out of 10.
The development environment is configured.
Test coverage
Code coverage of the project is 72.73% (branch coverage).
Deployment and basic user interactions are covered with tests.
Some cases are not covered with tests.
Interactions by several users are not tested thoroughly.
Security score
Upon auditing, the code was found to contain 2 critical, 1 high, 4 medium, and 4 low severity issues. Out of these, 10 issues have been addressed and resolved, leading to a Security score of 10 out of 10.
All identified issues are detailed in the “Findings” section of this report.
Summary
The comprehensive audit of the customer's smart contract yields an overall score of 9. This score reflects the combined evaluation of documentation, code quality, test coverage, and security aspects of the project.
Risks
The SigningUtils.sol contract follows the EIP712 standard correctly; however, it does not have the functionality to automatically update nonce values and provide protection against signature replay attacks. The nonce variable should be updated correctly after signature verification is completed on chain. This functionality is out of the scope of this audit.
The airdrop and ownership transfer is done in AirdropClaim.sol through Reserve.sol. Reserve.sol is out of the scope of this audit. However, it has critical function access inside the scope.
The scope has an ERC2771 contract for Gas forwarding; however, there is no documentation on how this logic will be implemented off-chain.
Findings
Code ― | Title | Status | Severity | |
|---|---|---|---|---|
| F-2023-0721 | Invalid Initialization | fixed | Critical | |
| F-2023-0720 | Unverifiable Logic - External Call to Untrusted Address | mitigated | Critical | |
| F-2023-0722 | Undocumented Functionality | fixed | High | |
| F-2023-0726 | Data Consistency | fixed | Medium | |
| F-2023-0725 | Highly Permissive Role Access - Unverifiable Logic | fixed | Medium | |
| F-2023-0724 | Highly Permissive Role Access | fixed | Medium | |
| F-2023-0723 | NatSpec Contradiction | fixed | Medium | |
| F-2023-0730 | Variable Shadowing | fixed | Low | |
| F-2023-0729 | Missing Zero Address Validation | fixed | Low | |
| F-2023-0728 | Duplicate Code | fixed | Low |
Appendix 1. Severity Definitions
When auditing smart contracts, Hacken is using a risk-based approach that considers Likelihood, Impact, Exploitability and Complexity metrics to evaluate findings and score severities.
Reference on how risk scoring is done is available through the repository in our Github organization:
Severity | Description |
|---|---|
Critical | Critical vulnerabilities are usually straightforward to exploit and can lead to the loss of user funds or contract state manipulation. |
High | High vulnerabilities are usually harder to exploit, requiring specific conditions, or have a more limited scope, but can still lead to the loss of user funds or contract state manipulation. |
Medium | Medium vulnerabilities are usually limited to state manipulations and, in most cases, cannot lead to asset loss. Contradictions and requirements violations. Major deviations from best practices are also in this category. |
Low | Major deviations from best practices or major Gas inefficiency. These issues will not have a significant impact on code execution, do not affect security score but can affect code quality score. |
Severity
- Critical
Description
- Critical vulnerabilities are usually straightforward to exploit and can lead to the loss of user funds or contract state manipulation.
Severity
- High
Description
- High vulnerabilities are usually harder to exploit, requiring specific conditions, or have a more limited scope, but can still lead to the loss of user funds or contract state manipulation.
Severity
- Medium
Description
- Medium vulnerabilities are usually limited to state manipulations and, in most cases, cannot lead to asset loss. Contradictions and requirements violations. Major deviations from best practices are also in this category.
Severity
- Low
Description
- Major deviations from best practices or major Gas inefficiency. These issues will not have a significant impact on code execution, do not affect security score but can affect code quality score.
Appendix 2. Scope
The scope of the project includes the following smart contracts from the provided repository:
Scope Details | |
|---|---|
| Repository | https://github.com/NF3Labs/contracts-V2→ |
| Commit | a69718e71ba8a6e220ff8665c2799abd8cad8327 |
| Whitepaper | Not provided |
| Requirements | Provided (NF3x ContractsV2 Flows) |
| Technical Requirements | Provided (NF3x Technical Documentation) |
Scope Details
- Repository
- https://github.com/NF3Labs/contracts-V2→
- Commit
- a69718e71ba8a6e220ff8665c2799abd8cad8327
- Whitepaper
- Not provided
- Requirements
- Provided (NF3x ContractsV2 Flows)
- Technical Requirements
- Provided (NF3x Technical Documentation)