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

- Severity: Critical (CVSS:4.0, scored by GitHub) `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`
- Known to be exploited: not in CISA's catalogue, which lists only what CISA has confirmed
- Published: 2025-12-24T12:00:00.000Z
- Modified: 2026-02-03T03:06:53.944Z
- Also known as: RUSTSEC-2025-0143
- Weaknesses: CWE-758

## 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.

(As written by GitHub Advisory Database.)

## Affected

- capnp (crates.io): before 0.24.0; from 0.0.0-0 before 0.24.0

## References

- <https://github.com/capnproto/capnproto-rust/issues/605> (report, web)
- <https://github.com/capnproto/capnproto-rust/commit/7b981f4c75a975c80444cd38729bcdf12bf3eabf> (web)
- <https://github.com/capnproto/capnproto-rust/commit/e3aeec213e6d1b30a182bf61682a370f20d8a02c> (web)
- <https://github.com/capnproto/capnproto-rust> (package)
- <https://rustsec.org/advisories/RUSTSEC-2025-0143.html> (advisory, web)
- <https://crates.io/crates/capnp> (package)

## Sources

- GitHub Advisory Database: [GHSA-5w5r-mf82-595p](https://github.com/advisories/GHSA-5w5r-mf82-595p), CC-BY-4.0, modified 2026-02-03
- RustSec Advisory Database: [RUSTSEC-2025-0143](https://rustsec.org/advisories/RUSTSEC-2025-0143.html), CC0-1.0, modified 2026-01-29

---

Page: https://cve.day/GHSA-5w5r-mf82-595p · Whole record: https://cve.day/GHSA-5w5r-mf82-595p.json · Rebuilt by cve.day 2026-11-25T22:56:43.289Z
