GHSA-q669-2vfg-cxcg: Ckb Nervos CKB Unaligned Pointer Dereference Vulnerability

MODERATE
Published
Advisory Summary

GHSA-q669-2vfg-cxcg is a MODERATE nervos ckb unaligned pointer dereference vulnerability (General Security Weakness) affecting Ckb libraries in the crates.io ecosystem. The issue involves nervos ckb unaligned pointer dereference. Remediation is available by upgrading affected packages to version 0.31.1.

GHSA-q669-2vfg-cxcg at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-q669-2vfg-cxcg
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification General Security Weakness
Affected Product Ckb
Package Ecosystem crates.io
Published Date
Last Updated

How to Fix GHSA-q669-2vfg-cxcg

To remediate this vulnerability, upgrade all affected Ckb dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

ckb fixed: 0.31.1
Upgrade ckb to 0.31.1
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for ckb

How to Check if You Are Affected

To determine whether your application is affected by GHSA-q669-2vfg-cxcg, inspect your project dependencies for Ckb:

inspect dependencies for ckb

Analyze the terminal output to locate any version of Ckb in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.31.1), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under General Security Weakness. In Ckb, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

via bounty@nervos.org There are multiple type conversions in ckb that unsafely cast between byte pointers and other types of pointers. This results in unaligned pointers, which are not allowed by the Rust language, and are considered undefined behavior, meaning that the compiler is free to do anything with code. This can lead to unpredictable bugs that can become security vulnerabilities. Some of the bugs here could potentially lead to buffer overreads in malformed data (it's not clear to me as I haven't investigated the practical impact of these bugs). Two of these (in blockchain.rs) do not create unaligned data. They do though perform an unsafe operation that may not uphold the invariants of the safe function they are in, and could lead to undefined behavior and buffer overreads on malformed input. These are of the same nature as those in my previous report about the molecule crate. Patch attached for commit 1b09e37c8e1b7945495cd18d9782417fbe51e986 that fixes all cases I know of at this time. Please consider this report for reward under the terms of the bug bounty program. Related advisory: https://github.com/nervosnetwork/molecule/security/advisories/GHSA-rffv-8x7x-p7pw

GHSA-q669-2vfg-cxcg Affected Ckb Versions

1 component(s)
Fixed Versions:
0.31.1
Product / Package Ecosystem Affected Versions Fixed Version
ckb
crates.io
< 0.31.1
0.31.1

References

Frequently Asked Questions

What is GHSA-q669-2vfg-cxcg?
GHSA-q669-2vfg-cxcg is a security vulnerability in Ckb involving Nervos CKB Unaligned Pointer Dereference under General Security Weakness.
Which Ckb versions are affected?
Affected versions include releases prior to 0.31.1 across affected packages: ckb.
What version fixes GHSA-q669-2vfg-cxcg?
Upgrading to 0.31.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is ckb affected?
Yes, ckb is affected in releases prior to 0.31.1. Upgrade your dependency to 0.31.1 or later.
What CWE is associated with GHSA-q669-2vfg-cxcg?
GHSA-q669-2vfg-cxcg is classified under General Security Weakness.
How can I check crates.io dependencies for GHSA-q669-2vfg-cxcg?
Run the dependency tree command: 'inspect dependencies for ckb'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-q669-2vfg-cxcg",
  "modified" : "2024-02-02T20:59:17Z",
  "published" : "2024-02-02T20:59:17Z",
  "aliases" : [ ],
  "summary" : "Nervos CKB Unaligned Pointer Dereference",
  "details" : "via bounty@nervos.org\n\nThere are multiple type conversions in ckb that unsafely cast between byte pointers and other types of pointers. This results in unaligned pointers, which are not allowed by the Rust language, and are considered undefined behavior, meaning that the compiler is free to do anything with code. This can lead to unpredictable bugs that can become security vulnerabilities.\n\nSome of the bugs here could potentially lead to buffer overreads in malformed data (it's not clear to me as I haven't investigated the practical impact of these bugs).\n\nTwo of these (in blockchain.rs) do not create unaligned data. They do though perform an unsafe operation that may not uphold the invariants of the safe function they are in, and could lead to undefined behavior and buffer overreads on malformed input.\n\nThese are of the same nature as those in my previous report about the molecule crate.\n\nPatch attached for commit 1b09e37c8e1b7945495cd18d9782417fbe51e986 that fixes all cases I know of at this time.\n\nPlease consider this report for reward under the terms of the bug bounty program.\n\nRelated advisory: https://github.com/nervosnetwork/molecule/security/advisories/GHSA-rffv-8x7x-p7pw",
  "severity" : [ ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "ckb"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.31.1"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 0.31.0"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/nervosnetwork/ckb/security/advisories/GHSA-q669-2vfg-cxcg"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/nervosnetwork/ckb/commit/adf8f0d08bc058383a0df658ea2c2ef6e7950335"
  } ],
  "database_specific" : {
    "cwe_ids" : [ ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-02-02T20:59:17Z",
    "nvd_published_at" : null
  }
}