Introduction
We express our gratitude to the KYOTO team for the collaborative engagement that enabled the execution of this Smart Contract Security Assessment.
KyotoProtocol is a carbon-negative blockchain designed to scale the Voluntary Carbon Market (VCM) and foster the growth of Regenerative Finance (ReFi) by leveraging Web3 technologies.
| title | content |
|---|---|
| Platform | EVM |
| Language | Solidity |
| Tags | Staking, Vesting |
| Timeline | 09/04/2024 - 16/04/2024 |
| Methodology | https://hackenio.cc/sc_methodology→ |
Review Scope | |
|---|---|
| Repository | https://github.com/KyotoCarbonCo/chain-contracts→ |
| Commit | 40b3c32 |
Review Scope
- Commit
- 40b3c32
Audit Summary
10/10
100%
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 KYOTO |
| Audited By | Niccolò Pozzolini |
| Approved By | Przemyslaw Swiatowiec |
| Website | https://kyotoprotocol.io→ |
| Changelog | 11/04/2024 - Preliminary Report; 16/04/2024 - Remediation Report |
Document
- Name
- Smart Contract Code Review and Security Analysis Report for KYOTO
- Audited By
- Niccolò Pozzolini
- Approved By
- Przemyslaw Swiatowiec
- Website
- https://kyotoprotocol.io→
- Changelog
- 11/04/2024 - Preliminary Report; 16/04/2024 - Remediation Report
System Overview
The scope is composed by the chain contracts of the project KyotoProtocol:
KyotoVault: Simple Vault contract that allows withdrawing funds by authorized addresses
KyotoVesting: contract used to prevent migrated funds from flooding Kyoto Network with liquidity. After migration, tokens are put in the vesting contract and released accordingly to the vesting schedule - linearly each day over 18 months.
MigrationStorage: contract used to handle the migration process for transferring funds to a vesting contract making sure that the same migration isn't processed twice.
NodeNFTRegistry: an ERC721 NFT collection contract, used to represent ownership of Kyoto Network Nodes.
NodeNFTStaking: staking contract for NFTs. Users can stake their NFTs in the contract and receive Kyoto in exchange at a fixed rate. It can be unstaked at any time with no penalties.
RewardsCollector: contract that can receive Kyoto and distribute it to a configured set of targets with different weights.
StakingPool: staking contract for Kyoto, with limits on how much can be staked at any time.
ValidatorManager: contract that manages the validators of Kyoto Chain.
Privileged roles
KyotoVault
DEFAULTADMINROLE: can manage roles
WITHDRAWER_ROLE: can withdraw funds
KyotoVesting
DEFAULTADMINROLE: can manage roles
MIGRATOR_ROLE: can create new vesting schedules
MigrationStorage
MIGRATOR_ROLE: can start the migration process
NodeNFTRegistry
DEFAULTADMINROLE: can manage roles and act as NODEMANAGERROLE
NODEMANAGERROLE: can mint new NFTs and change URI config
NodeNFTStaking
DEFAULTADMINROLE : can manage roles
MANAGER_ROLE: can change NFT collection that can be staked in the contract
RewardsCollector
DEFAULTADMINROLE: can update targets and percentages
StakingPool
DEFAULTADMINROLE: can manage roles
MANAGER_ROLE: can change financial parameters of the contract
ValidatorManager
owner: can update the validators set
Executive Summary
Documentation quality
The total Documentation Quality score is 10 out of 10.
Functional requirements are complete.
Technical description is provided.
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 100% (branch coverage).
Deployment and basic user interactions are covered with tests.
Negative cases are covered.
Interactions by several users are tested thoroughly.
Security score
Upon auditing, the code was found to contain 0 critical, 1 high, 0 medium, and 2 low severity issues, 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 10. This score reflects the combined evaluation of documentation, code quality, test coverage, and security aspects of the project.
Risks
Dependency on Unaudited External Libraries: The project utilizes libraries or contracts without security audits, potentially introducing vulnerabilities. This compromises the security of the audited system, making it susceptible to attacks exploiting these external weaknesses. Libray used: PRBMath.
Findings
Code ― | Title | Status | Severity | |
|---|---|---|---|---|
| F-2024-2099 | Faulty rewards accountancy logic in staking contract | fixed | High | |
| F-2024-2102 | Missed pull over push pattern in RewardsCollector | mitigated | Low | |
| F-2024-2100 | Potential locking of staked NFTs due to changeable NFT address | fixed | Low | |
| F-2024-2104 | Lack of Parameter Validation in setValidators Function | fixed | Observation | |
| F-2024-2103 | Hardcoded APY in _rewardsPerTick function | fixed | Observation | |
| F-2024-2101 | Redundant math in stake function | fixed | Observation | |
| F-2024-2098 | Redundant assignment in MigrationStorage's constructor | fixed | Observation |
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/KyotoCarbonCo/chain-contracts→ |
| Commit | 40b3c3292e7bccf8cc04c0608dbe224e75a83789 |
| Requirements | kyoto-flows.pdf |
| Technical Requirements | kyoto-flows.pdf, readme.md |
Scope Details
- Commit
- 40b3c3292e7bccf8cc04c0608dbe224e75a83789
- Requirements
- kyoto-flows.pdf
- Technical Requirements
- kyoto-flows.pdf, readme.md