CVE-2026-67213

nanoid before 5.1.6 Infinite Loop via Zero Size in customAlphabet and customRandom

Published Jul 29, 2026 CVSS 4.0 · 8.2 High EPSS < 1% KEV · Not listed
Description
nanoid (Nano ID) before 5.1.6 contains an infinite loop in the customAlphabet and customRandom functions. When these functions are configured with a size of 0, the internal generation loop never satisfies its exit condition and spins indefinitely, hanging the calling thread. An application that passes an unvalidated, attacker-controlled size of 0 to these functions is exposed to a denial-of-service condition.

Analysis

AI-generated

Technical impact

The nanoid library before version 5.1.6 suffers from an infinite loop in the customAlphabet and customRandom functions when the size argument is set to zero. The internal generation loop never satisfies its exit condition, causing the calling thread to hang indefinitely. This flaw represents a denial‑of‑service condition and is classified as CWE‑835, an infinite loop leading to resource exhaustion.

Affected Systems

The vulnerability affects the nanoid package from the nanoid project, a JavaScript/Node.js library used in server‑side code. Any installation of nanoid earlier than version 5.1.6 is vulnerable. The issue manifests when an application imports nanoid and calls customAlphabet or customRandom with a size value of zero.

Risk and Exploitability

The CVSS score of 8.2 indicates a high‑severity denial‑of‑service flaw. The EPSS probability is reported as < 1 %, suggesting that exploitation activity is currently limited, and the vulnerability is not listed in the CISA KEV catalog. Based on the description, the likely attack vector is an attacker‑controlled input that passes a size of 0 to nanoid’s custom functions, which may occur when the application forwards user‑supplied data to these functions without validation. A successful exploitation would cause the affected thread to hang, potentially disabling the service entirely.

Remediation

No solution or workaround provided in the CVE record.

OpenCVE Recommended Actions

  • Upgrade nanoid to version 5.1.6 or later, which fixes the infinite‑loop bug.
  • Validate any size argument passed to nanoid’s customAlphabet or customRandom functions, ensuring it is a positive integer before invoking the library.
  • Audit the codebase for direct calls to nanoid’s custom functions that may receive unvalidated size values, and implement defensive checks or input sanitization accordingly.

Generated by OpenCVE AI on August 4, 2026 at 12:29 UTC.

Tracking

Sign in to view the affected projects.

Advisories

Source ID Title
Github GHSA Github GHSA GHSA-2v37-7h3g-55p8 nanoid: custom generators can loop indefinitely when size is zero
History
Type Values Removed Values Added
Metrics ssvc

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

Type Values Removed Values Added
Description nanoid (Nano ID) before 5.1.6 contains an infinite loop in the customAlphabet and customRandom functions. When these functions are configured with a size of 0, the internal generation loop never satisfies its exit condition and spins indefinitely, hanging the calling thread. An application that passes an unvalidated, attacker-controlled size of 0 to these functions is exposed to a denial-of-service condition.
Title nanoid before 5.1.6 Infinite Loop via Zero Size in customAlphabet and customRandom
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'}

Weaknesses
  • CWE-835

    Loop with Unreachable Exit Condition ('Infinite Loop')

Sources

Status
PUBLISHED
Assigner
VulnCheck
Published
Updated
Oct 8, 2026, 3:24 PM
Reserved
Jul 28, 2026, 6:13 PM
Status
Analyzed
Published
Jul 29, 2026, 2:16 PM
Modified
Oct 23, 2026, 11:10 PM
Severity
Important
Public date
Jul 29, 2026, 1:32 PM