Introduction
We express our gratitude to the Kresus team for the collaborative engagement that enabled the execution of this Smart Contract Security Assessment.
Kresus is a user-friendly crypto & Web3 wallet complete with total recoverability.
| title | content |
|---|---|
| Platform | EVM |
| Language | Solidity |
| Tags | Storage Vault |
| Timeline | 02/03/2023 - 21/04/2023 |
| Methodology | https://hackenio.cc/sc_methodology→ |
Review Scope | |
|---|---|
| Repository | https://github.com/Kresus-Labs-Inc/vault-mpc/tree/feat/mpc→ |
| Commit | 38db3f4 |
Review Scope
- Commit
- 38db3f4
Audit Summary
10/10
98.94%
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 Kresus |
| Audited By | Hacken |
| Website | https://www.kresus.com/→ |
| Changelog | 09/03/2023 - Initial Review |
| 03/04/2023 - Second Review | |
| 21/04/2023 - Third Review |
Document
- Name
- Smart Contract Code Review and Security Analysis Report for Kresus
- Audited By
- Hacken
- Website
- https://www.kresus.com/→
- Changelog
- 09/03/2023 - Initial Review
- 03/04/2023 - Second Review
- 21/04/2023 - Third Review
System Overview
Kresus Vault is a blockchain-based secure storage facility for digital assets like cryptocurrency, NFTs, and other tokens. The system consists from the following contracts:
BaseModule — an abstract contract for a module, containing mainly internal view functions.
Utils \- a library which contains helper methods dealing with signatures and function selectors.
KresusModule \- a contract representing a module i.e. a vault of valuables.
KresusRelayer \- an abstract contract with methods for executing transactions signed by accounts outside of Ethereum.
SecurityManager \- an abstract contract dealing with security features of the KresusModule i.e. guardians, lock, recovery etc.
TransactionManager \- an abstract contract for executing transactions in sequence or calling third-party contracts.
Storage \- a contract containing methods on voting, setting locks and assigning guardians.
Proxy \- a contract which delegated all calls to another fixed contract.
Factory \- a contract which deploys new vaults against a set deployer, which can be changed.
Privileged roles
The Module in Storage contract can set locks, toggle votings, add/revoke guardians, add/revoke heirs.
The Deployer of the Factory contract can set a new deployer address and deploy a new vault.
The KresusGuardian in the KresusModule contract can revoke guardian from a specific vault, lock or unlock vault. When voting is enabled - KresusGuardian signature is also required to revoke guardian.
The Guardian in the KresusModule contract can revoke guardian. During voting guardian signature is also required to enable ERC1155 token receiver, add new module, add new guardian, transfer vault ownership, revoke guardian, lock vault, perform multicall, toggle voting and set time delay.
The Owner’s signature in the KresusModule can be necessary for certain types of transactions.
The Module in the BaseVault can authorize modules, enable static calls, set an owner, or invoke a generic transaction.
Executive Summary
Documentation quality
The total Documentation quality score is 10 out of 10.
No Whitepaper is provided.
Functional and technical requirements are provided and well describe the project.
The NatSpec comments are extensive.
Code quality
The total Code quality score is 10 out of 10.
The code is well structured with separation of concerns.
The development environment is configured, though it requires manually setting environment variables from the developer.
Test coverage
Code coverage of the project is 98.94% (branch coverage).
Deployment and basic user interactions are covered with tests.
Only a few negative cases are covered.
Interactions by several users are not tested thoroughly.
Security score
Upon auditing, the code was found to contain 0 critical, 7 high, 7 medium, and 36 low severity issues. Out of these, 44 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.9. This score reflects the combined evaluation of documentation, code quality, test coverage, and security aspects of the project.
Risks
Front-end may receive zero address as a valid return value instead of an error.
The systems rely heavily on low-level calls using function selectors, which may lead to vulnerabilities and unexpected behavior.
Findings
Code ― | Title | Status | Severity | |
|---|---|---|---|---|
| F-2023-0359 | Undocumented Behavior | fixed | High | |
| F-2023-0358 | EIP Standard Violation | fixed | High | |
| F-2023-0357 | Requirements Violation | mitigated | High | |
| F-2023-0356 | Requirements Violation | fixed | High | |
| F-2023-0355 | Requirements Violation | fixed | High | |
| F-2023-0354 | Undocumented Behavior; Requirements Violation | fixed | High | |
| F-2023-0353 | Requirements Violation | fixed | High | |
| F-2023-0366 | Interface Mismatch | fixed | Medium | |
| F-2023-0365 | Possible False-Negative Validation | mitigated | Medium | |
| F-2023-0364 | Unclear Behavior | mitigated | Medium |
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/Kresus-Labs-Inc/vault-mpc/tree/feat/mpc→ |
| Commit | 38db3f4 |
| Whitepaper | Not provided |
| Requirements | Provided (Readme document) |
| Technical Requirements | Provided (Readme document + NatSpec in the code) |
Scope Details
- Commit
- 38db3f4
- Whitepaper
- Not provided
- Requirements
- Provided (Readme document)
- Technical Requirements
- Provided (Readme document + NatSpec in the code)