Skip to content
OpenAdvisories
Critical GHSA-5w5r-mf82-595p RUSTSEC-2025-0143

Cap'n Proto has Undefined Behavior in constant::Reader and StructSchema

Published Jan 28, 2026 · Updated Feb 3, 2026 · Assigned by GHSA

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<<T as Owned>::Reader<'static>> {
// ...
// 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.

Affected packages

EcosystemPackageAffectedFixedRecord
crates.io capnp < 0.24.0 0.24.0 GHSA-5w5r-mf82-595p
crates.io capnp >= 0.0.0-0, < 0.24.0 0.24.0 RUSTSEC-2025-0143

References