Introduction
We express our gratitude to the Neurashi team for the collaborative engagement that enabled the execution of this Smart Contract Security Assessment.
Neurashi is a BEP-20 token.
Document | |
|---|---|
| Name | Smart Contract Code Review and Security Analysis Report for Neurashi |
| Audited By | Turgay Arda Usman |
| Approved By | Przemyslaw Swiatowiec |
| Website | - |
| Changelog | 20/12/2024 - Preliminary Report |
| Platform | BNB Smart Chain (BSC) |
| Language | Solidity |
| Tags | BEP20 |
| Methodology | https://hackenio.cc/sc_methodology→ |
Document
- Name
- Smart Contract Code Review and Security Analysis Report for Neurashi
- Audited By
- Turgay Arda Usman
- Approved By
- Przemyslaw Swiatowiec
- Website
- -
- Changelog
- 20/12/2024 - Preliminary Report
- Platform
- BNB Smart Chain (BSC)
- Language
- Solidity
- Tags
- BEP20
- Methodology
- https://hackenio.cc/sc_methodology→
Review Scope | |
|---|---|
| Repository | https://github.com/Neurashi/NeurashiToken→ |
| Commit | d112a9a |
Review Scope
- Commit
- d112a9a
Audit Summary
The system users should acknowledge all the risks summed up in the risks section of the report
Documentation quality
Functional requirements are not provided.
Technical description is not provided.
Code quality
The code duplicates commonly known contracts instead of reusing them.
Several template code patterns were found.
The development environment is not configured.
Test coverage
Code coverage of the project is 0.00% (branch coverage).
Tests are not provided
System Overview
Neruashi is a BEP-20 tokenl with the following contracts:
NeurashiToken — simple BEP-20 token that mints all initial supply to a deployer. Additional minting is not allowed.
It has the following attributes:
Name: Neurashi
Symbol: NEI
Decimals: 18
Total supply: 45B tokens.
BEP20Basic — Defines the basic interface for a BEP-20 token, including balanceOf and transfer functions with the Transfer event.
BasicToken — Implements basic token functionality like transferring tokens and checking balances, with safety checks for valid recipients and sufficient balances.
StandardToken — Extends BasicToken to include allowance-based spending using approve, transferFrom, and related functionality for managing and checking allowances.
IBEP20 — An abstract interface extending BEP20Basic, defining allowance-related methods like allowance, approve, and transferFrom.
IBEP677 — Adds functionality for transferring tokens with additional data via transferAndCall, allowing contracts to handle token transfers.
BEP677Receiver — An interface for contracts to handle tokens received with transferAndCall, ensuring proper handling of the transferred data.
SmartToken — Combines StandardToken and IBEP677 to enable transferAndCall functionality, including support for interacting with other contracts during token transfers.
Potential Risks
The project concentrates minting tokens in a single address, raising the risk of fund mismanagement or theft, especially if key storage security is compromised.
Restricting approvals to the token contract, by rejecting address(this) in validRecipient, may cause usability issues, limiting functionality for staking, automated transfers, or integrations, potentially hindering broader adoption.
The transferAndCall function's use of contractFallback introduces a reentrancy risk, which could be exploited during certain integrations or user interactions, compromising the security of token transfers.
Findings
Code ― | Title | Status | Severity | |
|---|---|---|---|---|
| F-2024-7853 | Multiple Contracts in a Single File | unfixed | Observation | |
| F-2024-7842 | Incompatibility of _isContract with Proxy Patterns | unfixed | Observation | |
| F-2024-7840 | Redundant Function | unfixed | Observation | |
| F-2024-7839 | Use of Abstract Contract Instead of Interface | unfixed | 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 | https://github.com/Neurashi/NeurashiToken→ |
| Commit | d112a9a |
| Whitepaper | n/a |
| Requirements | n/a |
| Technical Requirements | n/a |
Scope Details
- Commit
- d112a9a
- 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 Neurashi AI, 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, 8 invariants were tested over 8,000,000 runs. This thorough testing ensured that the system works correctly even with unexpected or unusual inputs.
Invariant | Test Result | Run Count |
|---|---|---|
| Total supply of tokens should always remain constant and match the initialized value. | Passed | 1M |
| The sum of all token balances should never exceed the total supply. | Passed | 1M |
| Token balances should never be negative for any account. | Passed | 1M |
The allowance for a spender should correctly increase when increaseAllowance is called. | Passed | 1M |
The allowance for a spender should correctly decrease, but not go below zero, when decreaseAllowance is called. | Passed | 1M |
| The token name should always return "Neurashi". | Passed | 1M |
| The token symbol should always return "NEI". | Passed | 1M |
| The token decimals should always return 18. | Passed | 1M |
Invariant
- Total supply of tokens should always remain constant and match the initialized value.
Test Result
- Passed
Run Count
- 1M
Invariant
- The sum of all token balances should never exceed the total supply.
Test Result
- Passed
Run Count
- 1M
Invariant
- Token balances should never be negative for any account.
Test Result
- Passed
Run Count
- 1M
Invariant
- The allowance for a spender should correctly increase when
increaseAllowanceis called. Test Result
- Passed
Run Count
- 1M
Invariant
- The allowance for a spender should correctly decrease, but not go below zero, when
decreaseAllowanceis called. Test Result
- Passed
Run Count
- 1M
Invariant
- The token name should always return "Neurashi".
Test Result
- Passed
Run Count
- 1M
Invariant
- The token symbol should always return "NEI".
Test Result
- Passed
Run Count
- 1M
Invariant
- The token decimals should always return 18.
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.