GHSA-cq8v-f236-94qc: Rand :rng() Vulnerability

LOW
CWE-20
Published
Advisory Summary

GHSA-cq8v-f236-94qc is a LOW :rng() vulnerability (CWE-20: Improper Input Validation) affecting Rand libraries in the crates.io ecosystem. The issue involves :rng(). Remediation is available by upgrading affected packages to version 0.9.3, 0.10.1, 0.8.6.

GHSA-cq8v-f236-94qc at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-cq8v-f236-94qc
Severity LOW
CVSS v3.1 Base Score N/A
CWE Classification CWE-20: Improper Input Validation
Affected Product Rand
Package Ecosystem crates.io
Published Date
Last Updated

How to Fix GHSA-cq8v-f236-94qc

To remediate this vulnerability, upgrade all affected Rand dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

rand fixed: 0.9.3
Upgrade rand to 0.9.3
rand fixed: 0.10.1
Upgrade rand to 0.10.1
rand fixed: 0.8.6
Upgrade rand to 0.8.6
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for rand

How to Check if You Are Affected

To determine whether your application is affected by GHSA-cq8v-f236-94qc, inspect your project dependencies for Rand:

inspect dependencies for rand

Analyze the terminal output to locate any version of Rand in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.9.3), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-20: Improper Input Validation, where the product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly. In Rand, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

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.

GHSA-cq8v-f236-94qc Affected Rand Versions

3 component(s)
Fixed Versions:
0.9.30.10.10.8.6
Product / Package Ecosystem Affected Versions Fixed Version
rand
crates.io
≥ 0.9.0
< 0.9.3
0.9.3
rand
crates.io
≥ 0.10.0
< 0.10.1
All 1 versions
0.10.0
0.10.1
rand
crates.io
≥ 0.7.0
< 0.8.6
0.8.6

References

Frequently Asked Questions

What is GHSA-cq8v-f236-94qc?
GHSA-cq8v-f236-94qc is a security vulnerability in Rand involving :rng() under CWE-20: Improper Input Validation.
Which Rand versions are affected?
Affected versions include releases prior to 0.9.3, 0.10.1, 0.8.6 across affected packages: rand.
What version fixes GHSA-cq8v-f236-94qc?
Upgrading to 0.9.3, 0.10.1, 0.8.6 (or the latest patched release for your respective branch) resolves the vulnerability.
Is rand affected?
Yes, rand is affected in releases prior to 0.9.3, 0.10.1, 0.8.6. Upgrade your dependency to 0.9.3, 0.10.1, 0.8.6 or later.
What CWE is associated with GHSA-cq8v-f236-94qc?
GHSA-cq8v-f236-94qc is classified under CWE-20: Improper Input Validation (The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.).
How can I check crates.io dependencies for GHSA-cq8v-f236-94qc?
Run the dependency tree command: 'inspect dependencies for rand'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-cq8v-f236-94qc",
  "modified" : "2026-04-22T20:13:40Z",
  "published" : "2026-04-14T01:03:36Z",
  "aliases" : [ ],
  "summary" : "Rand is unsound with a custom logger using rand::rng()",
  "details" : "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:\n\n- The `log` and `thread_rng` features are enabled\n- A [custom logger](https://docs.rs/log/latest/log/#implementing-a-logger) is defined\n- The custom logger accesses `rand::rng()` (previously `rand::thread_rng()`) and calls any `TryRng` (previously `RngCore`) methods on `ThreadRng`\n- The `ThreadRng` (attempts to) reseed while called from the custom logger (this happens every 64 kB of generated data)\n- 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\n\n`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.",
  "severity" : [ ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "rand"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0.9.0"
      }, {
        "fixed" : "0.9.3"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "rand"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0.10.0"
      }, {
        "fixed" : "0.10.1"
      } ]
    } ],
    "versions" : [ "0.10.0" ]
  }, {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "rand"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0.7.0"
      }, {
        "fixed" : "0.8.6"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/rust-random/rand/pull/1763"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/rust-random/rand"
  }, {
    "type" : "WEB",
    "url" : "https://rustsec.org/advisories/RUSTSEC-2026-0097.html"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-20" ],
    "severity" : "LOW",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-04-14T01:03:36Z",
    "nvd_published_at" : null
  }
}