{"id":"GHSA-5w5r-mf82-595p","aliases":["GHSA-5w5r-mf82-595p","RUSTSEC-2025-0143"],"related":[],"kind":"vulnerability","state":"published","title":"Cap'n Proto has Undefined Behavior in constant::Reader and StructSchema","summary":"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.\n\n## `Reader::get`\n\n```rust\npub fn get(&self) -> Result<<T as Owned>::Reader<'static>> {\n    // ...\n    // UNSAFE: access `words` without validation\n}\n```\n\n## `StructSchema::new`\n\n```rust\npub fn new(builder: RawBrandedStructSchema) -> StructSchema {\n    // ...\n    // UNSAFE: access encoded nodes without validation\n}\n```\n\nThis vulnerability allows safe Rust code to trigger UB, which violates Rust's safety guarantees.\n\nThe 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.","summaryFormat":"markdown","summarySource":"ghsa","descriptions":[{"lang":"en","text":"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.\n\n## `Reader::get`\n\n```rust\npub fn get(&self) -> Result<<T as Owned>::Reader<'static>> {\n    // ...\n    // UNSAFE: access `words` without validation\n}\n```\n\n## `StructSchema::new`\n\n```rust\npub fn new(builder: RawBrandedStructSchema) -> StructSchema {\n    // ...\n    // UNSAFE: access encoded nodes without validation\n}\n```\n\nThis vulnerability allows safe Rust code to trigger UB, which violates Rust's safety guarantees.\n\nThe 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.","format":"markdown","source":"ghsa"}],"published":"2025-12-24T12:00:00.000Z","modified":"2026-02-03T03:06:53.944Z","severity":{"scorer":"GitHub","scheme":"CVSS:4.0","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","rating":"CRITICAL"},"severities":[{"scorer":"GitHub","scheme":"CVSS:4.0","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","rating":"CRITICAL"}],"cwes":["CWE-758"],"affected":[{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"0.24.0"}],"ecosystem":"crates.io","package":"capnp","purl":"pkg:cargo/capnp","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0.0.0-0","status":"affected","fixed":"0.24.0"}],"ecosystem":"crates.io","package":"capnp","purl":"pkg:cargo/capnp","source":"rustsec"}],"references":[{"url":"https://github.com/capnproto/capnproto-rust/issues/605","tags":["report","web"],"sources":["ghsa","rustsec"]},{"url":"https://github.com/capnproto/capnproto-rust/commit/7b981f4c75a975c80444cd38729bcdf12bf3eabf","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/capnproto/capnproto-rust/commit/e3aeec213e6d1b30a182bf61682a370f20d8a02c","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/capnproto/capnproto-rust","tags":["package"],"sources":["ghsa"]},{"url":"https://rustsec.org/advisories/RUSTSEC-2025-0143.html","tags":["advisory","web"],"sources":["ghsa","rustsec"]},{"url":"https://crates.io/crates/capnp","tags":["package"],"sources":["rustsec"]}],"credits":[],"sources":[{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-5w5r-mf82-595p","url":"https://github.com/advisories/GHSA-5w5r-mf82-595p","licence":"CC-BY-4.0","modified":"2026-02-03T03:06:53.944Z"},{"source":"rustsec","name":"RustSec Advisory Database","id":"RUSTSEC-2025-0143","url":"https://rustsec.org/advisories/RUSTSEC-2025-0143.html","licence":"CC0-1.0","modified":"2026-01-29T06:11:15.854Z"}],"updatedAt":"2026-11-25T22:56:43.289Z"}