Uninitialized memory exposure in any_as_u8_slice
Reported October 21, 2025 Issued October 22, 2025 Package borrowck_sacrifices (crates.io) Type INFO Unsound Categories
-
memory-exposure Keywords #uninitialized-memory #soundness References
-
https://github.com/alexpyattaev/borrowck_sacrifices/issues/1 Patched
-
>=0.2.0
Affected Functions Version borrowck_sacrifices::unsafe_casts::any_as_u8_slice
<0.2.0
Description
The safe function `any…
Uninitialized memory exposure in any_as_u8_slice
Reported October 21, 2025 Issued October 22, 2025 Package borrowck_sacrifices (crates.io) Type INFO Unsound Categories
-
memory-exposure Keywords #uninitialized-memory #soundness References
-
https://github.com/alexpyattaev/borrowck_sacrifices/issues/1 Patched
-
>=0.2.0
Affected Functions Version borrowck_sacrifices::unsafe_casts::any_as_u8_slice
<0.2.0
Description
The safe function any_as_u8_slice can create byte slices that reference uninitialized memory when used with types containing padding bytes.
The function uses slice::from_raw_parts to create a &[u8] covering the entire size of a type, including padding bytes. According to Rust’s documentation, from_raw_parts requires all bytes to be properly initialized, but padding bytes in structs are not guaranteed to be initialized. This violates the safety contract and causes undefined behavior.
Advisory available under CC0-1.0 license.