VYPR
Critical severityNVD Advisory· Published Aug 31, 2022· Updated Apr 23, 2025

Account takeover via cryptographically weak PRNG in NodeBB Forum

CVE-2022-36045

Description

NodeBB Forum Software is powered by Node.js and supports either Redis, MongoDB, or a PostgreSQL database. It utilizes web sockets for instant interactions and real-time notifications. 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. 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. The vulnerability has been patched in version 2.x and 1.19.x. There is no known workaround, but the patch sets listed above will fully patch the vulnerability.

AI Insight

LLM-synthesized narrative grounded in this CVE's description and references.

NodeBB's `utils.generateUUID` used `Math.random()`, allowing attackers to predict password reset tokens and take over any account.

Vulnerability

Analysis

NodeBB, a Node.js-based forum software, contained a critical vulnerability in its utils.generateUUID helper function, which was used to generate password reset tokens. The function relied on Math.random(), a cryptographically insecure pseudo-random number generator (PRNG), making generated tokens predictable. This issue affected all NodeBB versions as far back as v1.0.1 and potentially earlier [1][4].

Exploitation

Scenario

An attacker could exploit this vulnerability by triggering multiple password reset requests for a target account and analyzing the generated tokens. By crafting a script that predicts the sequence of Math.random() values, the attacker could calculate a valid reset code without any knowledge of the user's password. The attack requires knowledge of the victim's email address, which is a protected value in NodeBB by default, but may be exposed or guessable in some configurations [4].

Impact

Successful exploitation allows an attacker to take over any account without any interaction from the victim. This is a severe impact, as it enables full account compromise, including access to private messages, moderation tools, and administrative functions if the target is an admin. The vulnerability requires no authentication and can be executed remotely over the network [1][4].

Mitigation

The vulnerability has been patched in NodeBB versions 2.x and 1.19.x. The fix replaces Math.random() with crypto.randomBytes() for generating UUIDs, ensuring cryptographic randomness [3]. Users should upgrade immediately or cherry-pick the fix from commit e802fab (for v2.x) or 81e3c1b (for v1.19.x). No workarounds are available [1][4]. This vulnerability is not currently listed on CISA's Known Exploited Vulnerabilities (KEV) catalog.

AI Insight generated on May 21, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.

Affected packages

Versions sourced from the GitHub Security Advisory.

PackageAffected versionsPatched versions
nodebbnpm
< 1.19.81.19.8
nodebbnpm
>= 2.0.0, < 2.0.12.0.1

Affected products

2
  • ghsa-coords
    Range: < 1.19.8
  • NodeBB/NodeBBv5
    Range: < 1.19.8

Patches

2
81e3c1ba488d

fix: get rid of math.random in generateUUID

https://github.com/NodeBB/NodeBBBarış Soner UşaklıMay 26, 2022via ghsa
2 files changed · +19 7
  • public/src/utils.js+5 7 modified
    @@ -290,13 +290,11 @@
     
     	const utils = {
     		generateUUID: function () {
    -			/* eslint-disable no-bitwise */
    -			return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
    -				const r = Math.random() * 16 | 0;
    -				const v = c === 'x' ? r : ((r & 0x3) | 0x8);
    -				return v.toString(16);
    -			});
    -			/* eslint-enable no-bitwise */
    +			// from https://github.com/tracker1/node-uuid4/blob/master/browser.js
    +			const temp_url = URL.createObjectURL(new Blob());
    +			const uuid = temp_url.toString();
    +			URL.revokeObjectURL(temp_url);
    +			return uuid.split(/[:\/]/g).pop().toLowerCase(); // remove prefixes
     		},
     		// https://github.com/substack/node-ent/blob/master/index.js
     		decodeHTMLEntities: function (html) {
    
  • src/utils.js+14 0 modified
    @@ -1,3 +1,17 @@
     'use strict';
     
    +const crypto = require('crypto');
    +
     module.exports = require('../public/src/utils');
    +
    +module.exports.generateUUID = function () {
    +	// from https://github.com/tracker1/node-uuid4/blob/master/index.js
    +	let rnd = crypto.randomBytes(16);
    +	/* eslint-disable no-bitwise */
    +	rnd[6] = (rnd[6] & 0x0f) | 0x40;
    +	rnd[8] = (rnd[8] & 0x3f) | 0x80;
    +	/* eslint-enable no-bitwise */
    +	rnd = rnd.toString('hex').match(/(.{8})(.{4})(.{4})(.{4})(.{12})/);
    +	rnd.shift();
    +	return rnd.join('-');
    +};
    \ No newline at end of file
    
e802fab87f94

fix: get rid of math.random in utils.generateUUID

https://github.com/NodeBB/NodeBBBarış Soner UşaklıMay 26, 2022via ghsa
3 files changed · +23 9
  • public/src/utils.common.js+0 9 modified
    @@ -274,15 +274,6 @@ const HTMLEntities = Object.freeze({
     
     /* eslint-disable no-redeclare */
     const utils = {
    -	generateUUID: function () {
    -		/* eslint-disable no-bitwise */
    -		return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
    -			const r = Math.random() * 16 | 0;
    -			const v = c === 'x' ? r : ((r & 0x3) | 0x8);
    -			return v.toString(16);
    -		});
    -		/* eslint-enable no-bitwise */
    -	},
     	// https://github.com/substack/node-ent/blob/master/index.js
     	decodeHTMLEntities: function (html) {
     		return String(html)
    
  • public/src/utils.js+8 0 modified
    @@ -73,4 +73,12 @@ utils.assertPasswordValidity = (password) => {
     	}
     };
     
    +utils.generateUUID = function () {
    +	// from https://github.com/tracker1/node-uuid4/blob/master/browser.js
    +	const temp_url = URL.createObjectURL(new Blob());
    +	const uuid = temp_url.toString();
    +	URL.revokeObjectURL(temp_url);
    +	return uuid.split(/[:\/]/g).pop().toLowerCase(); // remove prefixes
    +};
    +
     module.exports = utils;
    
  • src/utils.js+15 0 modified
    @@ -1,5 +1,7 @@
     'use strict';
     
    +const crypto = require('crypto');
    +
     process.profile = function (operation, start) {
     	console.log('%s took %d milliseconds', operation, process.elapsedTimeSince(start));
     };
    @@ -14,4 +16,17 @@ utils.getLanguage = function () {
     	const meta = require('./meta');
     	return meta.config && meta.config.defaultLang ? meta.config.defaultLang : 'en-GB';
     };
    +
    +utils.generateUUID = function () {
    +	// from https://github.com/tracker1/node-uuid4/blob/master/index.js
    +	let rnd = crypto.randomBytes(16);
    +	/* eslint-disable no-bitwise */
    +	rnd[6] = (rnd[6] & 0x0f) | 0x40;
    +	rnd[8] = (rnd[8] & 0x3f) | 0x80;
    +	/* eslint-enable no-bitwise */
    +	rnd = rnd.toString('hex').match(/(.{8})(.{4})(.{4})(.{4})(.{12})/);
    +	rnd.shift();
    +	return rnd.join('-');
    +};
    +
     module.exports = utils;
    

Vulnerability mechanics

Generated on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.

References

5

News mentions

0

No linked articles in our index yet.