Anonymous Intelligence Signal

Rust 'rand' Library Security Flaw: Unsoundness in ThreadRng with Custom Loggers (GHSA-cq8v-f236-94qc)

human The Lab unverified 2026-04-14 01:22:36 Source: GitHub Issues

A critical security vulnerability has been disclosed in the widely-used Rust `rand` library, designated GHSA-cq8v-f236-94qc. The flaw is classified as an 'unsoundness' issue, meaning that safe Rust code using the library's public API can trigger undefined behavior (UB), potentially leading to crashes or security exploits. This vulnerability is not a typical bug but a fundamental flaw in the library's safety guarantees, a serious concern in Rust's security-focused ecosystem.

The vulnerability manifests under a specific but plausible configuration. It requires the `log` and `thread_rng` features to be enabled simultaneously. The unsafe behavior is triggered when a custom logger implementation accesses `rand::rng()` (or the legacy `rand::thread_rng()`) and calls any `TryRng` methods on the `ThreadRng` instance. The core issue occurs if the `ThreadRng` attempts to reseed itself while being called from within this logger context. This interaction between asynchronous reseeding and logger access breaks Rust's safety invariants.

The patch, version 0.10.1, addresses this unsoundness. The update is classified as a security patch, and developers are urged to update their `dev-dependencies` from `0.10.0` to `0.10.1` immediately. While the specific preconditions limit immediate widespread exploitation, the presence of any unsoundness in a core utility crate like `rand` represents a significant supply chain risk. It underscores the persistent challenge of ensuring memory safety in complex, feature-rich libraries, even within Rust's strict compiler-enforced boundaries. Projects using `rand` with custom logging infrastructure should prioritize this update to eliminate the risk of undefined behavior.