2024 Web3 Security ReportAccess control exploits account for nearly 80% of crypto hacks in 2024.
Discover report insights
  • Hacken
  • Audits
  • civic-technologies-inc
  • [SCA] Civic Technologies / Digital Identity Platform / Apr2023
Civic Technologies, Inc. logo

Civic Technologies, Inc.

Audit name:

[SCA] Civic Technologies / Digital Identity Platform / Apr2023

Date:

Jun 28, 2023

Table of Content

Introduction
Audit Summary
Document Information
System Overview
Executive Summary
Risks
Findings
Appendix 1. Severity Definitions
Appendix 2. Scope
Disclaimer

Want a comprehensive audit report like this?

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.

titlecontent
PlatformSolana
LanguageRust
TagsDigital Identity Platform
Timeline12/04/2023 - 28/06/2023
Methodologyhttps://hackenio.cc/sc_methodology

    Review Scope

    Repositoryhttps://github.com/identity-com/on-chain-identity-gateway
    Commitd94bfee1a35b533583efc1b2151a9224b1a4b305

    Audit Summary

    Total9.38/10
    Security Score

    10/10

    Test Coverage

    91%

    Code Quality Score

    9/10

    Documentation Quality Score

    9/10

    14Total Findings
    11Resolved
    0Accepted
    0Mitigated

    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

    NameSmart Contract Code Review and Security Analysis Report for Civic Technologies, Inc.
    Audited ByHacken
    Websitehttps://www.civic.com/
    Changelog19/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
      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 in program::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-0982Denial Of Service State
    fixed

    High
    F-2023-0983Improper Account Funding
    fixed

    Medium
    F-2023-0995Confusing Code
    unfixed

    Low
    F-2023-0994Unfinalized Code
    unfixed

    Low
    F-2023-0993 Missing Documentation
    fixed

    Low
    F-2023-0992Unsafe Rust Code
    fixed

    Low
    F-2023-0991Best Practices Violation
    fixed

    Low
    F-2023-0990Best Practices Violation
    unfixed

    Low
    F-2023-0989Best Practices Violation
    fixed

    Low
    F-2023-0988Floating Language Version
    fixed

    Low
    1-10 of 14 findings

    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

    Repositoryhttps://github.com/identity-com/on-chain-identity-gateway
    Commitd94bfee1a35b533583efc1b2151a9224b1a4b305
    WhitepaperProvided
    RequirementsProvided
    Technical RequirementsProvided

    Contracts in Scope

    solana
    program
    src
    borsh.rs - solana/program/src/borsh.rs
    entrypoint.rs - solana/program/src/entrypoint.rs
    error.rs - solana/program/src/error.rs
    instruction.rs - solana/program/src/instruction.rs
    lib.rs - solana/program/src/lib.rs
    networks.rs - solana/program/src/networks.rs
    processor.rs - solana/program/src/processor.rs
    state.rs - solana/program/src/state.rs

    Disclaimer