Introduction
We express our gratitude to the Constellation Network team for the collaborative engagement that enabled the execution of this Smart Contract Security Assessment.
Document | |
|---|---|
| Name | Smart Contract Code Review and Security Analysis Report for Constellation Network |
| Audited By | Hacken |
| Approved By | Hacken |
| Changelog | 29/07/2021 – 09/07/2021 |
| Platform | Ethereum |
| Language | Solidity |
| Tags | Staking Pool |
| Methodology | https://hackenio.cc/sc_methodology→ |
Document
- Name
- Smart Contract Code Review and Security Analysis Report for Constellation Network
- Audited By
- Hacken
- Approved By
- Hacken
- Changelog
- 29/07/2021 – 09/07/2021
- Platform
- Ethereum
- Language
- Solidity
- Tags
- Staking Pool
- Methodology
- https://hackenio.cc/sc_methodology→
Review Scope | |
|---|---|
| Deployed contract | https://etherscan.io/address/0x74299a718b2c44483a27325d7725f0b2646de3b1#code→ |
Review Scope
System Overview
PROJECT_NAME is a staking protocol with the following contracts:
Token — simple ERC-20 token that mints all initial supply to a deployer. Additional minting is not allowed.
It has the following attributes:
Name: TokenName
Symbol: TST
Decimals: 18
Total supply: 100m tokens.
Staking — a contract that rewards users for staking their tokens. APY depends on the tokens provided by the owner and could not be calculated before reward tokens are deposited.
Privileged roles
The owner of the contract can arbitrarily add, delete and modify the addresses stored. It is therefore entitled to impersonate or change the logic of critical components of the system at will.
The owner can revoke a vesting if upon creation such a parameter was provided. On revoking all vested tokens till the moment are automatically released to the beneficiary account.
Potential Risks
Iterating over a dynamic array populated with custom tokenId can lead to gas limit denial of service if the number of tokenId goes out of control.
Findings
Code ― | Title | Status | Severity | |
|---|---|---|---|---|
| F-2021-0107 | Possible unreachable view function | fixed | Medium | |
| F-2021-010 | Multiple access to state variable | fixed | Low | |
| I-2021-010 | Maximum line size | unfixed | Observation | |
| I-2021-010 | Code optimization | fixed | Observation | |
| I-2021-0101 | Boolean equality | 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 | https://github.com/hknio→ |
| Commit | f185c31beaace0671972d1c2c5be6ea67a8a55e9 |
| Whitepaper | https://hackenio.cc/hacken-methodologies→ |
| Requirements | |
| Technical Requirements |
Scope Details
- Repository
- https://github.com/hknio→
- Commit
- f185c31beaace0671972d1c2c5be6ea67a8a55e9
- Requirements
- Technical Requirements
Assets in Scope
Appendix 3. Additional Valuables
Verification of System Invariants
During the audit of Project/Client Name], 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, [Number of Invariants] 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 |
|---|---|---|
| Debt should never decrease on open | Passed | 1M+ |
| Debt should never increase on close | Passed | 2M+ |
| Total position must decrease accordingly on close | Failed | 2M+ |
| Close should never decrease user reserve balances | Failed | 1M+ |
| Expiry must be in the future | Passed | 2M+ |
Invariant
- Debt should never decrease on open
Test Result
- Passed
Run Count
- 1M+
Invariant
- Debt should never increase on close
Test Result
- Passed
Run Count
- 2M+
Invariant
- Total position must decrease accordingly on close
Test Result
- Failed
Run Count
- 2M+
Invariant
- Close should never decrease user reserve balances
Test Result
- Failed
Run Count
- 1M+
Invariant
- Expiry must be in the future
Test Result
- Passed
Run Count
- 2M+
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.