CVE-2020-35926: Nanorand Improper Random Number Generation Vulnerability

MODERATE
Advisory Identifier: GHSA-m9m5-cg5h-r582
CVSS 5.1
CWE-338
Published
Advisory Summary

CVE-2020-35926 is a MODERATE (CVSS 5.1) improper random number generation vulnerability (CWE-338: Use of Cryptographically Weak Pseudo-Random Number Generator (PRNG)) affecting Nanorand libraries in the crates.io ecosystem. The issue involves improper random number generation in nanorand. Remediation is available by upgrading affected packages to version 0.5.1.

CVE-2020-35926 at a Glance

CVE Identifier CVE-2020-35926
GHSA Identifier GHSA-m9m5-cg5h-r582
Severity MODERATE
CVSS v3.1 Base Score 5.1
CWE Classification CWE-338: Use of Cryptographically Weak Pseudo-Random Number Generator (PRNG)
Affected Product Nanorand
Package Ecosystem crates.io
Published Date
Last Updated

Security Impact

CVSS: 5.1

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N).

Attack Vector Local (AV:L)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality Low (C:L)
Integrity Low (I:L)
Availability None (A:N)

How to Fix CVE-2020-35926

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

nanorand fixed: 0.5.1
Upgrade nanorand to 0.5.1
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 nanorand

How to Check if You Are Affected

To determine whether your application is affected by CVE-2020-35926, inspect your project dependencies for Nanorand:

inspect dependencies for nanorand

Analyze the terminal output to locate any version of Nanorand in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.5.1), 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-338: Use of Cryptographically Weak Pseudo-Random Number Generator (PRNG), where the product uses a pseudo-random number generator (prng) in a security context, but the prng's algorithm is not cryptographically strong. In Nanorand, 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

In versions of nanorand prior to 0.5.1, RandomGen implementations for standard unsigned integers could fail to properly generate numbers, due to using bit-shifting to truncate a 64-bit number, rather than just an as conversion. This often manifested as RNGs returning nothing but 0, including the cryptographically secure ChaCha random number generator.

CVE-2020-35926 Affected Nanorand Versions

1 component(s)
Fixed Versions:
0.5.1
Product / Package Ecosystem Affected Versions Fixed Version
nanorand
crates.io
< 0.5.1
0.5.1

References

Frequently Asked Questions

What is CVE-2020-35926?
CVE-2020-35926 is a security vulnerability in Nanorand involving Improper random number generation in nanorand under CWE-338: Use of Cryptographically Weak Pseudo-Random Number Generator (PRNG).
Which Nanorand versions are affected?
Affected versions include releases prior to 0.5.1 across affected packages: nanorand.
What version fixes CVE-2020-35926?
Upgrading to 0.5.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is nanorand affected?
Yes, nanorand is affected in releases prior to 0.5.1. Upgrade your dependency to 0.5.1 or later.
What is the CVSS score of CVE-2020-35926?
CVE-2020-35926 has a CVSS v3.1 base score of 5.1 (MODERATE) with vector string CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N.
What CWE is associated with CVE-2020-35926?
CVE-2020-35926 is classified under CWE-338: Use of Cryptographically Weak Pseudo-Random Number Generator (PRNG) (The product uses a Pseudo-Random Number Generator (PRNG) in a security context, but the PRNG's algorithm is not cryptographically strong.).
How can I check crates.io dependencies for CVE-2020-35926?
Run the dependency tree command: 'inspect dependencies for nanorand'. 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-m9m5-cg5h-r582",
  "modified" : "2023-06-13T20:01:40Z",
  "published" : "2021-08-25T20:50:24Z",
  "aliases" : [ "CVE-2020-35926" ],
  "summary" : "Improper random number generation in nanorand",
  "details" : "In versions of nanorand prior to 0.5.1, RandomGen implementations for standard unsigned integers could fail to properly generate numbers, due to using bit-shifting to truncate a 64-bit number, rather than just an as conversion. This often manifested as RNGs returning nothing but 0, including the cryptographically secure ChaCha random number generator.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "nanorand"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.5.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2020-35926"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Absolucy/nanorand-rs/commit/5ba218ac29df4786b002d7d12b47fa0c04a331f2"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/Absolucy/nanorand-rs"
  }, {
    "type" : "WEB",
    "url" : "https://rustsec.org/advisories/RUSTSEC-2020-0089.html"
  }, {
    "type" : "WEB",
    "url" : "https://twitter.com/aspenluxxxy/status/1336684692284772352"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-338" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-08-19T18:55:41Z",
    "nvd_published_at" : null
  }
}