GitHub Advisoryadvisory · crates.io
GHSA-fp5x-7m4q-449f Direct Ring Buffer has uninitialized memory exposure in create_ring_buffer
LOW
Official page ↗
- Ecosystem
- crates.io
- Packages
- direct_ring_buffer
- Severity
- Low
- CVSS vector
- CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N/E:P
- Weaknesses
- CWE-908
- Reviewed
- 2025-10-21
Affected packages
• crates.io direct_ring_buffer: < 0.2.2 → fixed in 0.2.2
Description
The safe function `create_ring_buffer` allocates a buffer using `Vec::with_capacity` followed by `set_len`, creating a `Box` containing uninitialized memory.
This leads to undefined behavior when functions like `write_slices` create typed slices (e.g., `&mut [bool]`) over the uninitialized memory, violating Rust's validity invariants. The issue has been confirmed using Miri.
Fixed in version 0.2.2 by using `resize_with` to properly initialize the buffer with `T::default()`, adding a `T: Default` bound to ensure sound initialization.
Related
Weakness · CWE (1)
- CWE-908 Use of Uninitialized Resource weakness