H1 2025 Web3 Security Report$3.1B in losses, DeFi hit hardest, AI threats on the rise
Read the full report
  • Hacken
  • Audits
  • binance
  • [PoR] Binance | PoR Code Audit | Feb2023

Audit name:

[PoR] Binance | PoR Code Audit | Feb2023

Date:

Feb 14, 2023

Table of Content

Introduction
Audit Summary
Findings
Appendix 1. Severity Definitions
Appendix 2. Scope
Disclaimer

Want a comprehensive audit report like this?

Introduction

We express our gratitude to the Binance team for the collaborative engagement that enabled the execution of this Independent Security Assessment.

On February 10th, Binance revealed a new and improved Proof of Reserves (PoR) verification system that leverages the power of both Merkle Trees and zk-SNARKs which marks a significant upgrade from the previous system that solely relied on plain Merkle Trees.

Document

NameIndependent Security Analysis Report for Binance
Audited ByLuciano Ciattaglia ([email protected])
Bartosz Barwikowski ([email protected])
Yaroslav Bratashchuk ([email protected])
Sofiane Akermoun ([email protected])
Websitehttps://www.binance.com/
Changelog14/02/2023 - Final Report
PlatformBNB Chain
LanguageGO, Python
TagsZK, PoR, Verifications

Review Scope

Repositoryhttps://github.com/binance/zkmerkle-proof-of-solvency
Commitc1884aae22cd17af023ac4424b4e6623eb0ea9dd

Audit Summary

6Total Findings
3Resolved
3Accepted
0Mitigated

System Overview

Introduction

On February 10th, Binance revealed a new and improved Proof of Reserves (PoR) verification system that leverages the power of both Merkle Trees and zk-SNARKs which marks a significant upgrade from the previous system that solely relied on plain Merkle Trees.

The integration of zk-proofs enhances the system's security by addressing previous vulnerabilities, such as the possibility of negative balances in fake accounts while preserving user privacy during the verification process.

Hacken conducted an independent technical assessment on the recently released verification system and discovered a critical vulnerability that could lead to the creation of fake debt. This issue has been reported and promptly fixed.

Project Summary

In the project we identified 1 critical issue which allows to fake the total debt amount in the zero knowledge proof circuit, 1 medium severity issue and 2 other low severity issues. The critical and medium severity issues have been already fixed. However, any proof generated before those issues were fixed cannot be verified to be valid, as the critical one allowed for the total debt amount to be tampered. Although the proofs may appear to be valid, it is not possible to ensure that they were not modified due to the vulnerability. The other low severity issues are very unlikely to be abused and do not need to be addressed immediately.

The project has 1157 dependencies, all of them with checksum verification. There were found 42 vulnerabilities within all dependencies, with 16 of them having public exploits available. 22 with high severity and 20 with medium. None of the vulnerable functions are currently being used in the project.

It uses a forked version of gnark made on Sep 2022 for the circuits and Poseidon with BN254 hash function to hash the user information and the Sparse Merkle Tree (SMT) data structure to store the hashes. The SMT is implemented using the BSMT library, and its maximum depth is set to be 28, which means that this Proof Of Solvency approach may be used for more than 250M users.

The code quality is clean and organized.

The README.md contains instructions on how to run tools one by one, and motivation behind the circuits is also detailed .

The Panic is used for main function error handling, so all the tools crash with a stack trace in case of an error.

The sample user data (balance sheets) is provided in order to test tools manually. There is a way to fetch (probably production) Postgres configuration from the AWS storage if the remotepasswordconfig flag is provided to the tools that use Postgres.

There was a function to generate fake accounts in the witness service, which was commented out but still left in the code (probably for manual testing purposes). EmptyAccounts are generated in the witness , and they are used in case the last account's batch size is less than 864.

The git history log has been modified several times, and as a result, the git metadata is mixed in some places.

References

Findings

Code
Title
Status
Severity
F-2024-5327TotalDebt manipulation vulnerability caused by overflow of BasePrice
fixed

Critical
F-2024-5330TotalDebt value underflow caused by integer overflow
fixed

Medium
F-2024-5358Merkle Root hash integrity
accepted

Low
F-2024-5357Potential omission of users
accepted

Low
F-2024-5360Vulnerabilities in dependencies
fixed

Observation
F-2024-5359Total amount of users inference
accepted

Observation
1-6 of 6 findings

Uncover findings like these to secure your project.

Appendix 1. Severity Definitions

When performing security audits, Hacken is using a risk-based approach that considers Likelihood and Impact metrics to evaluate findings and score severities.

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.

Disclaimer