Read the docs
TI-2026-66564 Aliases GHSA-cq8v-f236-94qc

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

Priority LOW 38CWE-20Published · Updated

Key facts

Attack vector
—
Privileges required
—
User interaction
—
Attack complexity
—
Impact type
—
Confidentiality · integrity · availability
—
Fix status
Fixed

No CVSS vector from any source. Fix status from GitHub.

Summary

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.

Why it matters now

Fix Fixed rand (crates.io): 0.9.3, 0.10.1, 0.8.6

SSVC decision points

Not available: CISA has not published SSVC decision points for this record.

Affected products

VendorProductAffected versionsFixed inStatusSource
—rand (crates.io)0.9.0 to before 0.9.30.9.3Patch availableGHSA-cq8v-f236-94qc
—rand (crates.io)0.10.0 to before 0.10.10.10.1Patch availableGHSA-cq8v-f236-94qc
—rand (crates.io)0.7.0 to before 0.8.60.8.6Patch availableGHSA-cq8v-f236-94qc
  • rand (crates.io) Vendor— Affected 0.9.0 to before 0.9.3 Fixed in 0.9.3 Patch available GHSA-cq8v-f236-94qc
  • rand (crates.io) Vendor— Affected 0.10.0 to before 0.10.1 Fixed in 0.10.1 Patch available GHSA-cq8v-f236-94qc
  • rand (crates.io) Vendor— Affected 0.7.0 to before 0.8.6 Fixed in 0.8.6 Patch available GHSA-cq8v-f236-94qc

Remediation

  • Fix · GHSA-cq8v-f236-94qc rand (crates.io) Fixed in 0.9.3 Advisory →
  • Fix · GHSA-cq8v-f236-94qc rand (crates.io) Fixed in 0.10.1 Advisory →
  • Fix · GHSA-cq8v-f236-94qc rand (crates.io) Fixed in 0.8.6 Advisory →

Timeline

  1. 2026-10-03 Threatist record created from GHSA-cq8v-f236-94qc

References

Sources

This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences