Skip to content

Commit 6a04d5a

Browse files
shinmaodjc
authored andcommitted
Add advisory for capnp unsoundness
1 parent 163b420 commit 6a04d5a

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

crates/capnp/RUSTSEC-0000-0000.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
```toml
2+
[advisory]
3+
id = "RUSTSEC-0000-0000"
4+
package = "capnp"
5+
date = "2025-12-24"
6+
url = "https://github.com/capnproto/capnproto-rust/issues/605"
7+
categories = ["memory-corruption"]
8+
keywords = ["unsoundness", "undefined-behavior"]
9+
10+
[affected.functions]
11+
"capnp::constant::Reader::get" = ["< 0.24.0"]
12+
"capnp::schema::StructSchema::new" = ["< 0.24.0"]
13+
14+
[versions]
15+
patched = [">= 0.24.0"]
16+
```
17+
18+
# Unsound APIs of public `constant::Reader` and `StructSchema`
19+
20+
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.
21+
22+
## `Reader::get`
23+
24+
```rust
25+
pub fn get(&self) -> Result<<T as Owned>::Reader<'static>> {
26+
// ...
27+
// UNSAFE: access `words` without validation
28+
}
29+
```
30+
31+
## `StructSchema::new`
32+
33+
```rust
34+
pub fn new(builder: RawBrandedStructSchema) -> StructSchema {
35+
// ...
36+
// UNSAFE: access encoded nodes without validation
37+
}
38+
```
39+
40+
This vulnerability allows safe Rust code to trigger UB, which violates Rust's safety guarantees.
41+
42+
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.

0 commit comments

Comments
 (0)