Rust Crate `rand` 0.9.0 Security Update Patches Critical Unsoundness Vulnerability (GHSA-cq8v-f236-94qc)
A critical security vulnerability in the widely used Rust crate `rand` has been patched in version 0.9.0. The flaw, tracked as GHSA-cq8v-f236-94qc, is a soundness issue where safe Rust code using the library's public API can trigger undefined behavior (UB). This represents a fundamental breach of Rust's memory safety guarantees, potentially leading to crashes or exploitable conditions in applications that rely on the affected functionality.
The vulnerability manifests under a specific but plausible set of conditions. It requires that the `log` and `thread_rng` features are enabled, a custom logger is implemented, and that logger accesses `rand::rng()` (formerly `rand::thread_rng()`) and calls `TryRng` methods on the `ThreadRng` instance. The undefined behavior occurs when the `ThreadRng` attempts to reseed itself while being called from within the custom logger's context. This interaction between logging and random number generation creates a concurrency hazard that the library's safety checks failed to prevent.
The update to `rand` 0.9.0 resolves this unsoundness. The advisory indicates the issue was reported by GitHub user @lopopolo. This patch is mandatory for any project using `rand` with the implicated features, as it corrects a core library guarantee. Developers must update their dependencies promptly to mitigate the risk of unpredictable application behavior or potential security exploits stemming from this memory safety violation.