This repository contains CodeQL security checks for Zetachain's smart contracts and protocol code. These queries help identify potential security issues, non-deterministic constructs, and platform-dependent vulnerabilities in Zetachain's consensus-critical code.
The repository is organized as follows:
├── zeta-protocol-checks
│ └── queries # CodeQL queries for Zetachain protocol security checks
└── zeta-sc-checks
└── queries # CodeQL queries for Zetachain smart contract checks
Each subdirectory focuses on a specific aspect of Zetachain’s security:
-
zeta-protocol-checks
:
Contains CodeQL queries for Zetachain protocol-level security checks, focusing on consensus-critical code, non-deterministic constructs, and platform-dependent types. -
zeta-sc-checks
:
Focuses on CodeQL queries for Zetachain smart contract security, addressing common vulnerabilities like reentrancy, integer overflow, access control issues, and unsafe external calls.
-
Setup CodeQL CLI:
Install the CodeQL CLI and ensure it’s available in your$PATH
. -
Clone the Repository:
git clone https://github.com/zetachain/codeql-security-rules.git cd codeql-security-rules
-
Analyze the Codebase:
Run the queries on your Go or Solidity codebase using CodeQL:codeql query run --database=/path/to/your-database zeta-protocol-checks/queries/*.ql codeql query run --database=/path/to/your-database zeta-sc-checks/queries/*.ql
-
Compile and Verify the Queries:
To compile the queries and check for errors:codeql query compile zeta-protocol-checks/queries/*.ql
Detects non-deterministic iterations over Go maps in consensus-critical code.
Reference: Go Map Iteration Order
Identifies usage of platform-dependent types (int
, uint
, uintptr
) that may cause non-determinism.
Reference: Go Spec - Numeric Types
We welcome contributions! To add a new query or improve existing ones:
- Create a new branch.
- Add your query in the appropriate directory (
zeta-protocol-checks
orzeta-sc-checks
). - Submit a pull request for review.
This repository is licensed under the MIT License. See the LICENSE
file for details.