Skip to content
NOUMENResearch
Network
Engineering
, home page

IntelligenceAdvisoriesAdvisory

GHSA-cq8v-f236-94qc

Rand is unsound with a custom logger using rand::rng()

In short

What to know.

Package
  • rand crates.iofrom 0.7.0 before 0.8.6
What to do
Upgrade rand to 0.8.6 or later.
Source's rating
LowNoumen has not assessed it.
Noumen finding
NMN-2026-0176Candidate. Severity unknown, confidence high.

3 December 2026

Source

  1. OSV record GHSA-cq8v-f236-94qcosv.devRetrieved 3 December 2026

Full record

Identifier
GHSA-cq8v-f236-94qc
Aliases
RUSTSEC-2026-0097
Severity
Low, as rated by the source. Noumen has not assessed it.
Fixed versions
0.9.3, 0.10.1, 0.8.6
Published
14 April 2026
Modified
10 September 2026
Source
OSV record GHSA-cq8v-f236-94qc, retrieved 3 December 2026, 00:00 UTC

Affected packages and ranges

Affected packages
PackageAffected versionsFixed in
rand
crates.io
from 0.7.0 before 0.8.60.8.6

Affected means inside a published range, not that the code path is reachable in your project.

Details, as published by the source
As published by the source
It has been reported (by @lopopolo) that the `rand` library is [unsound](https://rust-lang.github.io/unsafe-code-guidelines/glossary.html#soundness-of-code--of-a-library) (i.e. that safe code using the public API can cause Undefined Behaviour) when all the following conditions are met: - The `log` and `thread_rng` features are enabled - A [custom logger](https://docs.rs/log/latest/log/#implementing-a-logger) is defined - The custom logger accesses `rand::rng()` (previously `rand::thread_rng()`) and calls any `TryRng` (previously `RngCore`) methods on `ThreadRng` - The `ThreadRng` (attempts to) reseed while called from the custom logger (this happens every 64 kB of generated data) - Trace-level logging is enabled or warn-level logging is enabled and the random source (the `getrandom` crate) is unable to provide a new seed `TryRng` (previously `RngCore`) methods for `ThreadRng` use `unsafe` code to cast `*mut BlockRng<ReseedingCore>` to `&mut BlockRng<ReseedingCore>`. When all the above conditions are met this results in an aliased mutable reference, violating the Stacked Borrows rules. Miri is able to detect this violation in sample code. Since construction of [aliased mutable references is Undefined Behaviour](https://doc.rust-lang.org/stable/nomicon/references.html), the behaviour of optimized builds is hard to predict.