CVE-2024-55565: Nanoid Predictable Results Vulnerability

MODERATE
Advisory Identifier: GHSA-mwcw-c2x4-8c55
CVSS 4.3
CWE-835
Published
Advisory Summary

CVE-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

CVE Identifier CVE-2024-55565
GHSA Identifier GHSA-mwcw-c2x4-8c55
Severity MODERATE
CVSS v3.1 Base Score 4.3
CWE Classification CWE-835: Loop with Unreachable Exit Condition ('Infinite Loop')
Affected Product Nanoid
Package Ecosystem npm
Published Date
Last Updated

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).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity Low (I:L)
Availability None (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.

nanoid fixed: 5.0.9
npm install nanoid@5.0.9
nanoid fixed: 3.3.8
npm install nanoid@3.3.8
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 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

When nanoid is called with a fractional value, there were a number of undesirable effects: 1. in browser and non-secure, the code infinite loops on while (size--) 2. in node, the value of poolOffset becomes fractional, causing calls to nanoid to return zeroes until the pool is next filled 3. if the first call in node is a fractional argument, the initial buffer allocation fails with an error Version 3.3.8 and 5.0.9 are fixed.

CVE-2024-55565 Affected Nanoid Versions

2 component(s)
Fixed Versions:
5.0.93.3.8
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?
CVE-2024-55565 is a security vulnerability in Nanoid involving Predictable results in nanoid generation when given non-integer values under CWE-835: Loop with Unreachable Exit Condition ('Infinite Loop').
Which Nanoid versions are affected?
Affected versions include releases prior to 5.0.9, 3.3.8 across affected packages: nanoid.
What version fixes CVE-2024-55565?
Upgrading to 5.0.9, 3.3.8 (or the latest patched release for your respective branch) resolves the vulnerability.
Is nanoid affected?
Yes, nanoid is affected in releases prior to 5.0.9, 3.3.8. Upgrade your dependency to 5.0.9, 3.3.8 or later.
What is the CVSS score of CVE-2024-55565?
CVE-2024-55565 has a CVSS v3.1 base score of 4.3 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:N.
What CWE is associated with CVE-2024-55565?
CVE-2024-55565 is classified under CWE-835: Loop with Unreachable Exit Condition ('Infinite Loop') (The product contains an iteration or loop with an exit condition that cannot be reached, i.e., an infinite loop.).
How can I check npm dependencies for CVE-2024-55565?
Run the dependency tree command: 'npm ls nanoid'. 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-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"
  }
}