The Hacken 2025 Yearly Security ReportCovers major Web3 breaches, their root causes, prevention insights, and key regulatory trends for 2026.
Learn more

Audit name:

[SCA] DOP | SmartLogic | Apr2024

Date:

May 22, 2024

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 DOP (Data Ownership Protocol) team for the collaborative engagement that enabled the execution of this Smart Contract Security Assessment.

The Data Ownership Protocol (DOP) is a groundbreaking privacy-centric system on Ethereum L1 that utilizes zero-knowledge proofs to ensure adaptable transparency.

titlecontent
PlatformEVM
LanguageSolidity
TagsWallet; ZK; Upgradable
Timeline22/04/2024 - 13/05/2024
Methodologyhttps://hackenio.cc/sc_methodology

    Review Scope

    Repositoryhttps://github.com/dop-labs/protocol-contracts
    Commit4bb31d3

    Audit Summary

    Total9.7/10
    Security Score

    10/10

    Test Coverage

    95.45%

    Code Quality Score

    10/10

    Documentation Quality Score

    9/10

    8Total Findings
    4Resolved
    3Accepted
    1Mitigated

    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 DOP (Data Ownership Protocol)
    Audited ByIvan Bondar, Ataberk Yavuzer
    Approved ByGrzegorz Trawinski
    Websitehttps://dop.org/
    Changelog06/05/2024 - Preliminary Report
    13/05/2024 - Final Report
    • Document

      Name
      Smart Contract Code Review and Security Analysis Report for DOP (Data Ownership Protocol)
      Audited By
      Ivan Bondar, Ataberk Yavuzer
      Approved By
      Grzegorz Trawinski
      Changelog
      06/05/2024 - Preliminary Report
      13/05/2024 - Final Report

    System Overview

    The Data Ownership Protocol (DOP) is a groundbreaking privacy-centric system on Ethereum L1 that utilizes zero-knowledge proofs to ensure adaptable transparency. DOP allows users and DApps to securely store and transact assets while maintaining control over their data, providing a means to selectively disclose token holdings and transaction histories. The protocol supports private transactions involving any ERC-20 token or NFT via a 0zk address system, where asset details remain hidden until users choose to decrypt them back to public addresses.

    DOP integrates with a Merkle Tree framework to track and validate UTXOs, ensuring privacy and preventing double-spending. It also employs a token blocklist to exclude incompatible tokens and a list of sanctioned addresses to enhance security. The protocol generates revenue through fees for encryption, transferring, and decryption of assets, all aimed at fostering a secure, private, and efficient blockchain environment.

    The files in the scope:

    • Commitments.sol - Manages the secure and private storage of cryptographic commitments using a Merkle Tree structure. It allows for adding new leaves to the tree, automatically transitioning to a new tree when needed, and maintaining a history of tree roots for verification purposes.

    • DOPLogic.sol - This contract serves as the core processing unit for the Data Ownership Protocol (DOP), handling the cryptographic and transactional logic necessary for the protocol’s operation. It manages encryption and decryption fees, the integrity of transactions, and interactions with the blockchain’s state, such as Merkle root validations and the handling of fees to the treasury.

    • DOPSmartWallet.sol - Acts as a private smart wallet for the Data Ownership Protocol, handling encrypted transactions and interactions within the protocol. It integrates complex functionalities like creating commitments, encrypting tokens, and managing private transactions with snark proofs, playing a critical role in maintaining user privacy and transaction integrity.

    • Globals.sol - Defines constants, errors, and data structures used across the Data Ownership Protocol (DOP). It includes the SNARK scalar field used in cryptographic calculations, various error messages for contract interactions, and standard addresses like the verification bypass address. Additionally, it sets up complex structures for encryption, token management, and SNARK-based proofs, vital for the protocol's functionality.

    • PoseidonT3.sol - Provides a cryptographic hash function using the Poseidon algorithm, specifically for inputs of two elements.

    • PoseidonT4.sol - Similar to PoseidonT3.sol, this library implements the Poseidon hash function but for three-element inputs.

    • Protection.sol -  Manages a list of sanctioned addresses to enhance security within the Data Ownership Protocol. This interface provides functionality to check if an address is sanctioned, aiding in regulatory compliance and risk management.

    • Snark.sol - Provides cryptographic operations for SNARKs, facilitating secure and efficient zero-knowledge proof verifications in the Data Ownership Protocol. It supports operations like negation, addition, scalar multiplication of G1 points, and pairing checks for G2 points, crucial for verifying the integrity and authenticity of proofs within the system.

    • TokenBlocklist.sol - Manages a blocklist of tokens deemed incompatible with the Data Ownership Protocol. This contract allows for adding and removing tokens from the blocklist, ensuring that only compatible assets are used within the system.

    • Verifier.sol - Manages the verification of SNARK proofs for transactions within the Data Ownership Protocol, utilizing various cryptographic tools provided by the Snark library. This contract stores and retrieves verification keys and ensures that each transaction adheres to the protocol's privacy and security standards.

    • IDOPSessionAdapter.sol - Defines an interface for session adapters within the Data Ownership Protocol. It specifies a method for accepting or rejecting sessions based on a predefined magic value.

    • INativeAssetWrapper.sol - An interface for wrapping and unwrapping native blockchain assets like ETH into a tokenized form (e.g., WETH). It extends the ERC20 standard to allow deposit and withdrawal operations, facilitating the use of native assets in the encrypted and transactional environment of the DOP.

    • Relayer.sol - Functions as a multicall contract enabling batched operations and relaying within the Data Ownership Protocol, handling everything from token encryption and transfer to executing complex transaction sets. It ensures that actions are performed atomically and efficiently, reducing transaction costs and complexity for users.

    • Treasury.sol - Serves as the financial hub for the Data Ownership Protocol, managing and safeguarding the protocol's treasury funds. It supports basic treasury operations such as transferring ETH and ERC20 tokens under strict access control to ensure funds are handled securely.

    Privileged roles

    • DOPSmartWallet.sol:

      • owner:

        • Can add or remove tokens from the blocklist. This role is crucial for maintaining the integrity and functionality of the protocol by managing which tokens can be encrypted.

        • Can set and update verification keys tailored to specific configurations of nullifiers and commitments.

        • Can change treasury addresses, modify protection lists, adjust fees, enable decryption, and update safety vectors.

    • Relayer.sol:

      • onlySelfIfExecuting:

        • Implies a mechanism to restrict certain actions to the contract itself or during specific execution states, enhancing security and control over batch operations.

    • Treasury.sol:

      • TRANSFER_ROLE:

        • Designated roles that can execute fund transfers, ensuring controlled access to treasury assets.

    Executive Summary

    Documentation quality

    The total Documentation Quality score is 9 out of 10.

    • Functional requirements are detailed.

      • Project overview is detailed

      • All roles in the system are described.

      • Use cases are described and detailed.

      • For each contract, all futures are described.

      • All interactions are described.

    • Technical description is limited.

      • Run instructions are not provided.

      • Technical specification is provided.

      • The NatSpec documentation is sufficient.

    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 95.45% (branch coverage).

    • Deployment and basic user interactions are covered with tests.

    • Negative cases coverage are partially missed.

    • Interactions by several users are tested.

    Security score

    Upon auditing, the code was found to contain 0 critical, 0 high, 0 medium, and 1 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 9.7. This score reflects the combined evaluation of documentation, code quality, test coverage, and security aspects of the project.

    Risks

    Solidity Version Compatibility and Cross-Chain Deployment: The project utilizes Solidity version 0.8.23, which includes the introduction of the PUSH0 (0x5f) opcode. This opcode is currently supported on the Ethereum mainnet but may not be universally supported across other blockchain networks. Consequently, deploying the contract on chains other than the Ethereum mainnet, such as certain Layer 2 (L2) chains or alternative networks, might lead to compatibility issues or execution errors due to the lack of support for the PUSH0 opcode. In scenarios where deployment on various chains is anticipated, selecting an appropriate Ethereum Virtual Machine (EVM) version that is widely supported across these networks is crucial to avoid potential operational disruptions or deployment failures.

    Flexibility and Risk in Contract Upgrades: The project's contracts are upgradable, allowing the administrator to update the contract logic at any time. While this provides flexibility in addressing issues and evolving the project, it also introduces risks if upgrade processes are not properly managed or secured, potentially allowing for unauthorized changes that could compromise the project's integrity and security.

    Absence of Upgrade Window Constraints: The contract suite allows for immediate upgrades without a mandatory review or waiting period, increasing the risk of rapid deployment of malicious or flawed code, potentially compromising the system's integrity and user assets.

    Cryptography and Data Integrity: Dependence on SNARKs and Merkle Trees: While SNARKs and Merkle Trees provide strong privacy guarantees and scalability benefits, they also introduce specific risks. Faults in the cryptographic setup, incorrect parameter choices, or implementation errors can compromise data integrity and the security of zero-knowledge proofs.

    External Contracts: Some contracts in the scope were found to interact with external contracts that were not audited by the Hacken team. Therefore, we cannot guarantee safety against these external contracts.

    Undocumented Verification Bypass: The VERIFICATION_BYPASS variable is declared in the Globals.sol file. However, purpose of this variable is not clearly explained in documentation.

    Decrypt Feature Disabled by Default: The decrypt functionality of the system is disabled by default, restricting users from decrypting tokens until explicitly enabled by the contract owner. Users can still encrypt or transfer tokens between 0zk addresses without decryption capability, but cannot convert encrypted tokens back to their original form, limiting full utilization of the protocol's features until decryption is enabled.

    Sanction Check Dependency: The system integrates a Protection interface to identify sanctioned addresses, which plays a crucial role in determining the legitimacy of transactions. This dependency introduces a risk if the implementation behind the interface fails to update or inaccurately identifies addresses, potentially leading to wrongful blocking or allowance of transactions. As this list is managed externally and the implementation details are not audited or controlled within the project, there's a risk associated with the reliability and accuracy of the sanctions check

    Findings

    Code
    Title
    Status
    Severity
    F-2024-1536Lack of Upper Limit for Transfer Fees May Lead to Arbitrary Fee Increases
    mitigated

    Low
    F-2024-1546Missing checks for address(0)
    fixed

    Observation
    F-2024-1543Unnecessary initializations of integer variable to 0
    accepted

    Observation
    F-2024-1542Redundant Initialization of Boolean Variables
    accepted

    Observation
    F-2024-1541Unused error definition
    fixed

    Observation
    F-2024-1539The public functions not called by the contract should be declared external instead
    accepted

    Observation
    F-2024-1538Absence of Event Emission in Key Function
    fixed

    Observation
    F-2024-1535Outdated OpenZeppelin Contract Dependencies
    fixed

    Observation
    1-8 of 8 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/dop-labs/protocol-contracts
    Commit4bb31d343a1b70be259f3ad7b46b7ca1efe5f69e
    Whitepaperhttps://dop.org/DOP_Whitepaper_V2.1.pdf
    RequirementsDOP Contracts.pdf; NatSpec
    Technical RequirementsNatSpec

    Contracts in Scope

    contracts
    logic
    Commitments.sol - contracts › logic › Commitments.sol
    DOPLogic.sol - contracts › logic › DOPLogic.sol
    DOPSmartWallet.sol - contracts › logic › DOPSmartWallet.sol
    Globals.sol - contracts › logic › Globals.sol
    PoseidonT3.sol - contracts › logic › PoseidonT3.sol
    PoseidonT4.sol - contracts › logic › PoseidonT4.sol
    Protection.sol - contracts › logic › Protection.sol
    Snark.sol - contracts › logic › Snark.sol
    TokenBlocklist.sol - contracts › logic › TokenBlocklist.sol
    Verifier.sol - contracts › logic › Verifier.sol
    relayer
    IDOPSessionAdapter.sol - contracts › relayer › IDOPSessionAdapter.sol
    INativeAssetWrapper.sol - contracts › relayer › INativeAssetWrapper.sol
    Relayer.sol - contracts › relayer › Relayer.sol
    treasury
    Treasury.sol - contracts › treasury › Treasury.sol

    Disclaimer