Introduction
We express our gratitude to the Civic Technologies, Inc. team for the collaborative engagement that enabled the execution of this Smart Contract Security Assessment.
Civic is a leading provider of identity and access management tools.
title | content |
---|---|
Platform | Solana |
Language | Rust |
Tags | Digital Identity Platform |
Timeline | 12/04/2023 - 28/06/2023 |
Methodology | https://hackenio.cc/sc_methodology→ |
Review Scope | |
---|---|
Repository | https://github.com/identity-com/on-chain-identity-gateway→ |
Commit | d94bfee1a35b533583efc1b2151a9224b1a4b305 |
Review Scope
- Commit
- d94bfee1a35b533583efc1b2151a9224b1a4b305
Audit Summary
10/10
91%
9/10
9/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 Civic Technologies, Inc. |
Audited By | Hacken |
Website | https://www.civic.com/→ |
Changelog | 19/04/2023 - Initial Review |
19/05/2023 - Second Review | |
28/06/2023 - Third Review |
Document
- Name
- Smart Contract Code Review and Security Analysis Report for Civic Technologies, Inc.
- Audited By
- Hacken
- Website
- https://www.civic.com/→
- Changelog
- 19/04/2023 - Initial Review
- 19/05/2023 - Second Review
- 28/06/2023 - Third Review
System Overview
On-chain Identity Gateway is a platform that implements auth token creation and management. The main purpose of the system is to allow other smart contracts to validate the user’s identity (for example, KYC verification, reCAPTCHA, etc.).
The domain model has the following key entities: “gatekeeper network”, “gatekeeper”, and “gateway token”. A gatekeeper network can add/remove gatekeepers to itself. Gatekeepers can create gateway tokens within their network for arbitrary parties. A gateway token represents a credential that is meant to be used by client systems to authenticate their users. A party may be granted many gateway tokens at the same time, including many tokens from the same network. A gateway token may have an expiration time, which can be increased or decreased arbitrarily by any gatekeeper in the network. A gateway token may be paused/unpaused (only by the issuing gatekeeper), revoked or removed by any gatekeeper in the network. A network may add/remove features to itself. Currently, the only feature is self-expiration, which allows a grantee of a gateway token to make the token expire immediately. The platform supports several blockchains.
The platform implementation designed for the Solana blockchain is in the audit scope.
In-scope files:
./solana/program/ (also referred to as the
program
crate) — the folder contains a Rust crate that defines the operations that gatekeepers can perform on the Solana blockchain, and the client-side code for interacting with the program../solana/program/src/entrypoint.rs — the file contains the program entrypoint and performs a redirect to the processor.
./solana/program/src/lib.rs — the file contains module declarations, the program ID declaration, and reading/validation utilities for gateway tokens.
./solana/program/src/processor.rs — the file contains the implementation of fundamental operations over the domain entities.
./solana/program/src/state.rs — the file contains the program state data structures definitions and helper functions to work with the state.
./solana/program/src/borsh.rs — the file contains Borsh helpers to work with data slices.
./solana/program/src/error.rs — the file contains the protocol error declarations.
./solana/program/src/instruction.rs — the file contains the program instruction signatures and the functions constructing calls into the respective program APIs.
/solana/program/src/networks.rs — the file contains official gateway network addresses.
Privileged roles
The owner of the account that contains the program - as allowed in Solana - can modify the account, including the program code, if it was not deployed as immutable.
Within the program, there are no universal high-privileged roles. Each gateway network is a root of an isolated graph of entities. For each graph, the ultimate-privilege entity is the gateway network, which can spawn many gatekeepers that have second-class privileges. The details of the abilities of the privileged entities are described in the main body of the System Overview.
Executive Summary
Documentation quality
The total Documentation quality score is 9 out of 10.
README.md in the
program
crate as well as doc comments inprogram::instruction
state the need to pass the rent sysvar account to some instructions, but actually the instructions do not expect it.
Code quality
The total Code quality score is 9 out of 10.
There are minor cases of unfinalized or confusing code.
There are hardcoded generated values whose derivation is not validated properly.
See the Findings section for detailed issue descriptions
Test coverage
Code coverage of the project is 91% (branch coverage).
There is both positive and negative cases coverage.
All kinds of actors are tested.
program::processor::remove_feature_from_network
is not tested.
Security score
Upon auditing, the code was found to contain 0 critical, 1 high, 1 medium, and 12 low severity issues. Out of these, 11 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 10. This score reflects the combined evaluation of documentation, code quality, test coverage, and security aspects of the project.
Risks
Generally, in Solana, a program may be deployed as mutable, which could be used to change the implementation in an unexpected way; additionally, insufficient funding of the program-containing account may lead to the program going down.
The gatekeeper that issued a token is able to freeze it at any moment.
Any gatekeeper of the network that issued a token is able to revoke it, remove it, or render it expired at any moment.
A gatekeeper network may remove a gatekeeper at any moment.
Findings
Code ― | Title | Status | Severity | |
---|---|---|---|---|
F-2023-0982 | Denial Of Service State | fixed | High | |
F-2023-0983 | Improper Account Funding | fixed | Medium | |
F-2023-0995 | Confusing Code | unfixed | Low | |
F-2023-0994 | Unfinalized Code | unfixed | Low | |
F-2023-0993 | Missing Documentation | fixed | Low | |
F-2023-0992 | Unsafe Rust Code | fixed | Low | |
F-2023-0991 | Best Practices Violation | fixed | Low | |
F-2023-0990 | Best Practices Violation | unfixed | Low | |
F-2023-0989 | Best Practices Violation | fixed | Low | |
F-2023-0988 | Floating Language Version | fixed | Low |
Identify vulnerabilities in your smart contracts.
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/identity-com/on-chain-identity-gateway→ |
Commit | d94bfee1a35b533583efc1b2151a9224b1a4b305 |
Whitepaper | Provided→ |
Requirements | Provided→ |
Technical Requirements | Provided→ |
Contracts in Scope
solana/program/src/borsh.rs
solana/program/src/entrypoint.rs
solana/program/src/error.rs
solana/program/src/instruction.rs
solana/program/src/lib.rs
solana/program/src/networks.rs
solana/program/src/processor.rs
solana/program/src/state.rs