Description
nanoid (Nano ID) before 3.3.16 and 5.1.16 contains an infinite loop in the customAlphabet and nanoid functions of its non-secure module (nanoid/non-secure). When these functions are given a negative size, the loop counter is decremented from a negative value and never reaches its termination condition, spinning indefinitely and hanging the calling thread. An application that passes an unvalidated, attacker-controlled negative size to these functions is exposed to a denial-of-service condition.
Published: 2026-07-29
Score: 8.2 High
EPSS: < 1% Very Low
KEV: No
Impact: n/a
Action: n/a
AI Analysis

Impact

The nanoid library contains an infinite loop in its non-secure customAlphabet and nanoid functions when a negative size is supplied. The loop counter starts with a negative value and is decremented, never meeting the termination condition, which causes the calling thread to spin indefinitely and eventually hang the application. This results in a denial‑of‑service condition for any process that imports the vulnerable module and passes an unvalidated, attacker‑controlled negative size argument.

Affected Systems

The vulnerability applies to Node.js applications that import the nanoid library, specifically the nanoid/non-secure module. Versions of nanoid prior to 3.3.16 and 5.1.16 are affected; these releases contain the infinite loop flaw. All code that invokes customAlphabet or nanoid with a size value that could be negative is at risk.

Risk and Exploitability

The CVSS score of 8.2 classifies this issue as high impact, while the EPSS score of less than 1% indicates a low probability of exploitation. The flaw is not listed in CISA’s KEV catalog. The likely attack vector is inferred to be remote if the application accepts network input that can influence the size parameter, or local if the size comes from a local source. A successful exploitation would cause a thread to hang and could exhaust resources, leading to service degradation or outage.

Generated by OpenCVE AI on August 22, 2026 at 11:03 UTC.

Remediation

No vendor fix or workaround currently provided.

OpenCVE Recommended Actions

  • Upgrade nanoid to version 3.3.16 or later, or to 5.1.16 or later, to remove the infinite loop.
  • If available, replace usage of the non‑secure module with the secure module (nanoid/secure) which does not contain the vulnerable logic.
  • Validate all size arguments passed to customAlphabet or nanoid to ensure they are non‑negative before invoking the library functions.

Generated by OpenCVE AI on August 22, 2026 at 11:03 UTC.

Tracking

Sign in to view the affected projects.

Advisories
Source ID Title
Github GHSA Github GHSA GHSA-28wg-ghj8-5hjv nanoid: non-secure generators can loop indefinitely with negative size
History

Wed, 19 Aug 2026 20:45:00 +0000

Type Values Removed Values Added
Description nanoid (Nano ID) before 5.1.16 contains an infinite loop in the customAlphabet and nanoid functions of its non-secure module (nanoid/non-secure). When these functions are given a negative size, the loop counter is decremented from a negative value and never reaches its termination condition, spinning indefinitely and hanging the calling thread. An application that passes an unvalidated, attacker-controlled negative size to these functions is exposed to a denial-of-service condition. nanoid (Nano ID) before 3.3.16 and 5.1.16 contains an infinite loop in the customAlphabet and nanoid functions of its non-secure module (nanoid/non-secure). When these functions are given a negative size, the loop counter is decremented from a negative value and never reaches its termination condition, spinning indefinitely and hanging the calling thread. An application that passes an unvalidated, attacker-controlled negative size to these functions is exposed to a denial-of-service condition.
Title nanoid before 5.1.16 Infinite Loop via Negative Size in non-secure module nanoid Infinite Loop via Negative Size in non-secure module
References

Wed, 29 Jul 2026 15:30:00 +0000

Type Values Removed Values Added
Metrics ssvc

{'options': {'Automatable': 'no', 'Exploitation': 'none', 'Technical Impact': 'partial'}, 'version': '2.0.3'}


Wed, 29 Jul 2026 14:00:00 +0000

Type Values Removed Values Added
Description nanoid (Nano ID) before 5.1.16 contains an infinite loop in the customAlphabet and nanoid functions of its non-secure module (nanoid/non-secure). When these functions are given a negative size, the loop counter is decremented from a negative value and never reaches its termination condition, spinning indefinitely and hanging the calling thread. An application that passes an unvalidated, attacker-controlled negative size to these functions is exposed to a denial-of-service condition.
Title nanoid before 5.1.16 Infinite Loop via Negative Size in non-secure module
First Time appeared Nanoid Project
Nanoid Project nanoid
Weaknesses CWE-835
CPEs cpe:2.3:a:nanoid_project:nanoid:*:*:*:*:*:node.js:*:*
Vendors & Products Nanoid Project
Nanoid Project nanoid
References
Metrics cvssV3_1

{'score': 5.9, 'vector': 'CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H'}

cvssV4_0

{'score': 8.2, 'vector': 'CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N'}


Subscriptions

Nanoid Project Nanoid
cve-icon MITRE

Status: PUBLISHED

Assigner: VulnCheck

Published:

Updated: 2026-08-19T20:26:45.093Z

Reserved: 2026-07-28T18:13:39.684Z

Link: CVE-2026-67214

cve-icon Vulnrichment

Updated: 2026-07-29T14:37:15.476Z

cve-icon NVD

Status : Analyzed

Published: 2026-07-29T14:16:35.043

Modified: 2026-08-26T17:53:53.367

Link: CVE-2026-67214

cve-icon Redhat

No data.

cve-icon OpenCVE Enrichment

Updated: 2026-08-22T11:15:04Z

Weaknesses
  • CWE-835

    Loop with Unreachable Exit Condition ('Infinite Loop')