GitHub Advisoryadvisory · crates.io

GHSA-5w5r-mf82-595p Cap'n Proto has Undefined Behavior in constant::Reader and StructSchema

CRITICAL Published 2026-01-28 Modified 2026-01-28 Official page ↗
Ecosystem
crates.io
Packages
capnp
Severity
Critical
CVSS vector
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N
Weaknesses
CWE-758
Reviewed
2026-01-28

Affected packages

• crates.io capnp: < 0.24.0 → fixed in 0.24.0

Description

The safe API functions `constant::Reader::get` and `StructSchema::new` rely on `PointerReader::get_root_unchecked`, which can cause undefined behavior (UB) by constructing arbitrary words or schemas. `Reader::get` ```rust pub fn get(&self) -> Result::Reader> { // ... // UNSAFE: access `words` without validation } ``` `StructSchema::new` ```rust pub fn new(builder: RawBrandedStructSchema) -> StructSchema { // ... // UNSAFE: access encoded nodes without validation } ``` This vulnerability allows safe Rust code to trigger UB, which violates Rust's safety guarantees. The issue is resolved in version `0.24.0` by making constructor functions unsafe and mark the fields of struct as visible only in the crate.

Related

Weakness · CWE (1)

  • CWE-758 Reliance on Undefined, Unspecified, or Implementation-Defined Behavior weakness

References