CVE-2022-36045: Nodebb Cryptographically Weak PRNG Vulnerability

CRITICAL
Advisory Identifier: GHSA-p4cc-w597-6cpm
CVSS 9.8
CWE-338 CWE-330
Published
Advisory Summary

CVE-2022-36045 is a CRITICAL (CVSS 9.8) cryptographically weak prng vulnerability (CWE-338: Use of Cryptographically Weak Pseudo-Random Number Generator (PRNG)) affecting Nodebb libraries in the npm ecosystem. The issue involves cryptographically weak prng in `utils.generateuuid`. Remediation is available by upgrading affected packages to version 1.19.8, 2.0.1.

CVE-2022-36045 at a Glance

CVE Identifier CVE-2022-36045
GHSA Identifier GHSA-p4cc-w597-6cpm
Severity CRITICAL
CVSS v3.1 Base Score 9.8
CWE Classification CWE-338: Use of Cryptographically Weak Pseudo-Random Number Generator (PRNG)
Affected Product Nodebb
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 9.8

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

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

How to Fix CVE-2022-36045

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

nodebb fixed: 1.19.8
npm install nodebb@1.19.8
nodebb fixed: 2.0.1
npm install nodebb@2.0.1
Verify Direct and Transitive Dependencies

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

npm ls nodebb

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2022-36045, inspect your project dependencies using npm:

npm ls nodebb

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

Note: The npm ls nodebb command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

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 Nodebb, 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 Brief `utils.generateUUID`, a helper function available in essentially all versions of NodeBB (as far back as v1.0.1 and potentially earlier) used a cryptographically insecure Pseudo-random number generator (`Math.random()`), which meant that a specially crafted script combined with multiple invocations of the password reset functionality could enable an attacker to correctly calculate the reset code for an account they do not have access to. ### Impact This vulnerability impacts all installations of NodeBB. The vulnerability allows for an attacker to take over any account without the involvement of the victim, and as such, the remediation should be applied immediately (either via NodeBB upgrade or cherry-pick of the specific changeset. Patches have been provided for both active branches of NodeBB (v2.x and v1.19.x)—please see below. If you are already on v2.0.0 or v1.19.7, you can upgrade with no ill effects. The new version contains only the patch for this vulnerability. The impact of this vulnerability is slightly lessened by the requirement that the target's email address must be known, **and** user emails are protected values in NodeBB. However, since NodeBB can be configured to display email addresses if the admin so wishes, and as email addresses can often by derived from other sources and/or guessed, the impact of this vulnerability is still fairly high. ### Patches #### v2.x The vulnerability has been patched in https://github.com/NodeBB/NodeBB/commit/e802fab87f94a13f397f04cfe6068f2f7ddf7888. You can cherry-pick this directly into your codebase. #### v1.19.x The vulnerability has been patched in 81e3c1ba488d03371a5ce8d0ebb5c5803026e0f9. You can cherry-pick this directly into your codebase. ### Workarounds There is no known workaround, but the patch sets listed above will fully patch the vulnerability. ### References * [CWE-338: Use of Cryptographically Weak Pseudo-Random Number Generator (PRNG)](http://cwe.mitre.org/data/definitions/338.html) ### For more information If you have any questions or comments about this advisory: * Discuss it on [our community forum](community.nodebb.org/) * Email us at [support@nodebb.org](mailto:support@nodebb.org)

CVE-2022-36045 Affected Nodebb Versions

2 component(s)
Fixed Versions:
1.19.82.0.1
Product / Package Ecosystem Affected Versions Fixed Version
nodebb
npm
< 1.19.8
1.19.8
nodebb
npm
≥ 2.0.0
< 2.0.1
All 1 versions
2.0.0
2.0.1

References

Frequently Asked Questions

What is CVE-2022-36045?
CVE-2022-36045 is a security vulnerability in Nodebb involving Cryptographically weak PRNG in `utils.generateUUID` under CWE-338: Use of Cryptographically Weak Pseudo-Random Number Generator (PRNG).
Which Nodebb versions are affected?
Affected versions include releases prior to 1.19.8, 2.0.1 across affected packages: nodebb.
What version fixes CVE-2022-36045?
Upgrading to 1.19.8, 2.0.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is nodebb affected?
Yes, nodebb is affected in releases prior to 1.19.8, 2.0.1. Upgrade your dependency to 1.19.8, 2.0.1 or later.
What is the CVSS score of CVE-2022-36045?
CVE-2022-36045 has a CVSS v3.1 base score of 9.8 (CRITICAL) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2022-36045?
CVE-2022-36045 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 npm dependencies for CVE-2022-36045?
Run the dependency tree command: 'npm ls nodebb'. 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-p4cc-w597-6cpm",
  "modified" : "2022-09-08T14:13:22Z",
  "published" : "2022-08-30T20:38:10Z",
  "aliases" : [ "CVE-2022-36045" ],
  "summary" : "Cryptographically weak PRNG in `utils.generateUUID`",
  "details" : "### In Brief\n`utils.generateUUID`, a helper function available in essentially all versions of NodeBB (as far back as v1.0.1 and potentially earlier) used a cryptographically insecure Pseudo-random number generator (`Math.random()`), which meant that a specially crafted script combined with multiple invocations of the password reset functionality could enable an attacker to correctly calculate the reset code for an account they do not have access to.\n\n### Impact\nThis vulnerability impacts all installations of NodeBB. The vulnerability allows for an attacker to take over any account without the involvement of the victim, and as such, the remediation should be applied immediately (either via NodeBB upgrade or cherry-pick of the specific changeset. Patches have been provided for both active branches of NodeBB (v2.x and v1.19.x)—please see below.\n\nIf you are already on v2.0.0 or v1.19.7, you can upgrade with no ill effects. The new version contains only the patch for this vulnerability.\n\nThe impact of this vulnerability is slightly lessened by the requirement that the target's email address must be known, **and** user emails are protected values in NodeBB. However, since NodeBB can be configured to display email addresses if the admin so wishes, and as email addresses can often by derived from other sources and/or guessed, the impact of this vulnerability is still fairly high.\n\n### Patches\n\n#### v2.x\nThe vulnerability has been patched in https://github.com/NodeBB/NodeBB/commit/e802fab87f94a13f397f04cfe6068f2f7ddf7888. You can cherry-pick this directly into your codebase.\n\n#### v1.19.x\nThe vulnerability has been patched in 81e3c1ba488d03371a5ce8d0ebb5c5803026e0f9. You can cherry-pick this directly into your codebase.\n\n### Workarounds\nThere is no known workaround, but the patch sets listed above will fully patch the vulnerability.\n\n### References\n* [CWE-338: Use of Cryptographically Weak Pseudo-Random Number Generator (PRNG)](http://cwe.mitre.org/data/definitions/338.html)\n\n### For more information\nIf you have any questions or comments about this advisory:\n* Discuss it on [our community forum](community.nodebb.org/)\n* Email us at [support@nodebb.org](mailto:support@nodebb.org)\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "nodebb"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.19.8"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "nodebb"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "2.0.0"
      }, {
        "fixed" : "2.0.1"
      } ]
    } ],
    "versions" : [ "2.0.0" ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/NodeBB/NodeBB/security/advisories/GHSA-p4cc-w597-6cpm"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-36045"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/NodeBB/NodeBB/commit/81e3c1ba488d03371a5ce8d0ebb5c5803026e0f9"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/NodeBB/NodeBB/commit/e802fab87f94a13f397f04cfe6068f2f7ddf7888"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/NodeBB/NodeBB"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-330", "CWE-338" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-08-30T20:38:10Z",
    "nvd_published_at" : "2022-08-31T15:15:00Z"
  }
}