CVE-2024-55565: Nanoid Predictable Results Vulnerability
MODERATECVE-2024-55565 is a MODERATE (CVSS 4.3) predictable results vulnerability (CWE-835: Loop with Unreachable Exit Condition ('Infinite Loop')) affecting Nanoid libraries in the npm ecosystem. The issue involves predictable results in nanoid generation when given non-integer values. Remediation is available by upgrading affected packages to version 5.0.9, 3.3.8.
CVE-2024-55565 at a Glance
Security Impact
CVSS: 4.3
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:N).
How to Fix CVE-2024-55565
To remediate this vulnerability, upgrade all affected Nanoid dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
npm install nanoid@5.0.9
npm install nanoid@3.3.8
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls nanoid
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2024-55565, inspect your project dependencies using npm:
npm ls nanoid
Analyze the terminal output to locate any version of Nanoid in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 5.0.9), your application is affected.
Note: The npm ls nanoid 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-835: Loop with Unreachable Exit Condition ('Infinite Loop'), where the product contains an iteration or loop with an exit condition that cannot be reached, i.e., an infinite loop. In Nanoid, 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
CVE-2024-55565 Affected Nanoid Versions
2 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
nanoid
|
npm |
≥ 4.0.0
< 5.0.9
|
5.0.9
|
|
nanoid
|
npm |
< 3.3.8
|
3.3.8
|
References
Frequently Asked Questions
What is CVE-2024-55565?
Which Nanoid versions are affected?
What version fixes CVE-2024-55565?
Is nanoid affected?
What is the CVSS score of CVE-2024-55565?
What CWE is associated with CVE-2024-55565?
How can I check npm dependencies for CVE-2024-55565?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-mwcw-c2x4-8c55",
"modified" : "2025-11-04T16:54:54Z",
"published" : "2024-12-09T03:30:59Z",
"aliases" : [ "CVE-2024-55565" ],
"summary" : "Predictable results in nanoid generation when given non-integer values",
"details" : "When nanoid is called with a fractional value, there were a number of undesirable effects:\n\n1. in browser and non-secure, the code infinite loops on while (size--)\n2. in node, the value of poolOffset becomes fractional, causing calls to nanoid to return zeroes until the pool is next filled\n3. if the first call in node is a fractional argument, the initial buffer allocation fails with an error\n\nVersion 3.3.8 and 5.0.9 are fixed.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "nanoid"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "4.0.0"
}, {
"fixed" : "5.0.9"
} ]
} ]
}, {
"package" : {
"ecosystem" : "npm",
"name" : "nanoid"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "3.3.8"
} ]
} ]
} ],
"references" : [ {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-55565"
}, {
"type" : "WEB",
"url" : "https://github.com/ai/nanoid/pull/510"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/ai/nanoid"
}, {
"type" : "WEB",
"url" : "https://github.com/ai/nanoid/compare/3.3.7...3.3.8"
}, {
"type" : "WEB",
"url" : "https://github.com/ai/nanoid/releases/tag/5.0.9"
}, {
"type" : "WEB",
"url" : "https://lists.debian.org/debian-lts-announce/2024/12/msg00025.html"
}, {
"type" : "WEB",
"url" : "https://lists.debian.org/debian-lts-announce/2025/01/msg00006.html"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-835" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2024-12-09T22:42:43Z",
"nvd_published_at" : "2024-12-09T02:15:19Z"
}
}