Introduction
We express our gratitude to the Nonco team for the collaborative engagement that enabled the execution of this Smart Contract Security Assessment.
Nonco swap system is a secure, owner-controlled token swap infrastructure that enforces strict address and asset-level whitelisting. It ensures that only pre-approved token pairs and wallet addresses can participate in token swap operations through a central Swap contract. The system comprises three core contracts: AddressWhitelist, AssetsWhitelist, and Swap.
Document | |
|---|---|
| Name | Smart Contract Code Review and Security Analysis Report for Nonco |
| Audited By | Kaan Caglan |
| Approved By | Ivan Bondar |
| Website | https://nonco.com→ |
| Changelog | 31/03/2025 - Preliminary Report |
| 03/04/2025 - Final Report | |
| Platform | EVM |
| Language | Solidity |
| Tags | Swaps |
| Methodology | https://hackenio.cc/sc_methodology→ |
Document
- Name
- Smart Contract Code Review and Security Analysis Report for Nonco
- Audited By
- Kaan Caglan
- Approved By
- Ivan Bondar
- Website
- https://nonco.com→
- Changelog
- 31/03/2025 - Preliminary Report
- 03/04/2025 - Final Report
- Platform
- EVM
- Language
- Solidity
- Tags
- Swaps
- Methodology
- https://hackenio.cc/sc_methodology→
Review Scope | |
|---|---|
| Repository | AssetsWhitelist→ |
| AddressWhitelist→ | |
| Swap→ | |
| Commit | N/A |
| Retest | AddressWhitelist→ |
| AssetWhitelist→ | |
| Swap→ |
Review Scope
- Repository
- AssetsWhitelist→
- Commit
- N/A
- Retest
- AddressWhitelist→
Audit Summary
The system users should acknowledge all the risks summed up in the risks section of the report
Documentation quality
Functional requirements are partially missed.
Technical description is not provided.
Natspec is not sufficient.
Code quality
Best practices are followed.
The development environment is configured.
Test coverage
Code coverage of the project is 96.74% (branch coverage).
Deployment and basic user interactions are covered with tests.
System Overview
Nonco Swap is a secure, owner-controlled token swap infrastructure that enforces strict address and asset-level whitelisting. It ensures that only pre-approved token pairs and wallet addresses can participate in token swap operations through a central Swap contract. The system comprises three core contracts: AddressWhitelist, AssetsWhitelist, and Swap.
CONTRACTS:
1\. AddressWhitelist
Purpose: Manages a whitelist of addresses permitted to perform swaps with each other.
Core Features:
Add or remove addresses to/from an allowlist.
Lock/unlock the whitelist functionality (
lockdown).Authorize one external contract (the
Swapcontract) to access whitelisting checks.Restricts calls to the
isAddressAllowedfunction to either the contract owner or the authorized swap contract.
Key Variables:
allowList: List of approved addresses.isAllowed: Mapping to check if an address is approved.isLocked: When true, disables all whitelist checks.swapContractId: Authorized contract allowed to perform whitelist checks.
2\. AssetsWhitelist
Purpose: Maintains a whitelist of token pairs allowed to be swapped.
Core Features:
Approve or remove allowed token swap pairs symmetrically.
Lock/unlock whitelist checking for token pairs.
Authorize one external contract (the
Swapcontract) to perform allowed token checks.Uses string concatenation of token addresses to track allowed pairs.
Key Variables:
allowedTokens: Mapping from a token to its allowed swap partners.isAllowedToken: Mapping of concatenated token pair strings to boolean values for fast lookup.isLocked: Global switch to disable token pair checks.swapContractId: Authorized contract allowed to check token pairs.
3\. Swap
Purpose: Facilitates token swaps between two addresses and tokens, ensuring compliance with both address and token whitelisting.
Core Features:
Calls
AssetsWhitelistandAddressWhitelistbefore allowing a swap.Verifies token balances and allowances for both parties.
Executes symmetric token transfer between sender and receiver using
SafeTransferLib.Maintains a sequential message number (
msgSeqNum) for tracking or replay protection.
Key Variables:
assetsWhitelist: Interface to theAssetsWhitelistcontract.addressWhitelist: Interface to theAddressWhitelistcontract.msgSeqNum: An incremental message sequence number, potentially for anti-replay logic.
ATTRIBUTES:
There are no tokens defined with typical ERC20 attributes such as name, symbol, decimals, or totalSupply in this system. The architecture is focused on swap logic and access control via whitelisting, not token issuance.
PRIVILEGED ROLES:
Owner (via Ownable)
Can:
Add or remove addresses and tokens from the whitelist.
Enable/disable whitelist enforcement via lockdown mechanisms.
Set the authorized swap contract in both whitelist contracts.
Initiate swap transactions and update the sequence number.
Contracts where owner role is critical: AddressWhitelist, AssetsWhitelist, Swap.
Potential Risks
Single Points of Failure and Control: The project is fully or partially centralized, introducing single points of failure and control. This centralization can lead to vulnerabilities in decision-making and operational processes, making the system more susceptible to targeted attacks or manipulation.
Administrative Key Control Risks: The digital contract architecture relies on administrative keys for critical operations. Centralized control over these keys presents a significant security risk, as compromise or misuse can lead to unauthorized actions or loss of funds.
Findings
msgSeqNum Allows Arbitrary State Manipulationaddress(0) Code ― | Title | Status | Severity | |
|---|---|---|---|---|
| F-2025-9470 | Insecure Handling of msgSeqNum Allows Arbitrary State Manipulation | accepted | Low | |
| F-2025-9465 | High Risk Centralization and Unlimited Fund Drain via safeTransfer Function | accepted | Low | |
| F-2025-9512 | Missing Events | accepted | Observation | |
| F-2025-9511 | Owner Can Renounce Ownership | fixed | Observation | |
| F-2025-9463 | Revert String Size Optimization | fixed | Observation | |
| F-2025-9462 | Floating Pragma | fixed | Observation | |
| F-2025-9461 | Unneeded initializations of uint256 and bool variable to 0/false | fixed | Observation | |
| F-2025-9459 | Cache State Variable Array Length In For Loop | fixed | Observation | |
| F-2025-9457 | Missing checks for address(0) | fixed | Observation |
Appendix 1. Definitions
Severities
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. |
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.
Potential Risks
The "Potential Risks" section identifies issues that are not direct security vulnerabilities but could still affect the project’s performance, reliability, or user trust. These risks arise from design choices, architectural decisions, or operational practices that, while not immediately exploitable, may lead to problems under certain conditions. Additionally, potential risks can impact the quality of the audit itself, as they may involve external factors or components beyond the scope of the audit, leading to incomplete assessments or oversight of key areas. This section aims to provide a broader perspective on factors that could affect the project's long-term security, functionality, and the comprehensiveness of the audit findings.
Appendix 2. Scope
The scope of the project includes the following smart contracts from the provided repository:
Scope Details | |
|---|---|
| Repository | AssetsWhitelist→ |
| AddressWhitelist→ | |
| Swap→ | |
| Commit | N/A |
| Retest | AddressWhitelist→ |
| AssetWhitelist→ | |
| Swap→ | |
| Whitepaper | N/A |
| Requirements | N/A |
| Technical Requirements | N/A |
Scope Details
- Repository
- AssetsWhitelist→
- Commit
- N/A
- Retest
- AddressWhitelist→
- Whitepaper
- N/A
- Requirements
- N/A
- Technical Requirements
- N/A
Assets in Scope
Appendix 3. Additional Valuables
Verification of System Invariants
During the audit of Nonco Swap, Hacken followed its methodology by performing fuzz-testing on the project's main functions. Echidna →, a tool used for fuzz-testing, was employed to check how the protocol behaves under various inputs. Due to the complex and dynamic interactions within the protocol, unexpected edge cases might arise. Therefore, it was important to use fuzz-testing to ensure that several system invariants hold true in all situations.
Fuzz-testing allows the input of many random data points into the system, helping to identify issues that regular testing might miss. A specific Echidna fuzzing suite was prepared for this task, and throughout the assessment, 7 invariants were tested over 5,000,000 runs. This thorough testing ensured that the system works correctly even with unexpected or unusual inputs.
Invariant | Test Result | Run Count |
|---|---|---|
| echidnaassetsWhitelistmutual | Passed | 1M+ |
| echidnaassetsWhitelistconcatenation | Passed | 1M+ |
| echidnaaddressWhitelistadded | Passed | 1M+ |
| echidnaaddressWhitelistconsistency | Passed | 1M+ |
| echidnaswapseqnum | Passed | 1M+ |
| echidnaaddressWhitelistnoDuplicates | Passed | 1M+ |
| echidnalockdownstate | Passed | 1M+ |
Invariant
- echidnaassetsWhitelistmutual
Test Result
- Passed
Run Count
- 1M+
Invariant
- echidnaassetsWhitelistconcatenation
Test Result
- Passed
Run Count
- 1M+
Invariant
- echidnaaddressWhitelistadded
Test Result
- Passed
Run Count
- 1M+
Invariant
- echidnaaddressWhitelistconsistency
Test Result
- Passed
Run Count
- 1M+
Invariant
- echidnaswapseqnum
Test Result
- Passed
Run Count
- 1M+
Invariant
- echidnaaddressWhitelistnoDuplicates
Test Result
- Passed
Run Count
- 1M+
Invariant
- echidnalockdownstate
Test Result
- Passed
Run Count
- 1M+
Additional Recommendations
The smart contracts in the scope of this audit could benefit from the introduction of automatic emergency actions for critical activities, such as unauthorized operations like ownership changes or proxy upgrades, as well as unexpected fund manipulations, including large withdrawals or minting events. Adding such mechanisms would enable the protocol to react automatically to unusual activity, ensuring that the contract remains secure and functions as intended.
To improve functionality, these emergency actions could be designed to trigger under specific conditions, such as:
Detecting changes to ownership or critical permissions.
Monitoring large or unexpected transactions and minting events.
Pausing operations when irregularities are identified.
These enhancements would provide an added layer of security, making the contract more robust and better equipped to handle unexpected situations while maintaining smooth operations.