Infinite loop Affecting nanoid package, versions <3.3.16>=4.0.0 <5.1.16


Severity

Recommended
0.0
high
0
10

CVSS assessment by Snyk's Security Team. Learn more

Threat Intelligence

EPSS
0.32% (25th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
  • Snyk IDSNYK-JS-NANOID-18506894
  • published2 Aug 2026
  • disclosed29 Jul 2026
  • creditsajdakabir

Introduced: 29 Jul 2026

NewCVE-2026-67214  (opens in a new tab)
CWE-835  (opens in a new tab)

How to fix?

Upgrade nanoid to version 3.3.16, 5.1.16 or higher.

Overview

Affected versions of this package are vulnerable to Infinite loop through the customAlphabet and nanoid functions in nanoid/non-secure. An attacker can hang the calling thread by supplying a negative size to either function, causing the loop counter to decrement from a negative value and never reach its termination condition. This affects applications that pass unvalidated attacker-controlled size values into the non-secure ID generator, where a single malicious request can spin the process indefinitely and stop the service from responding.

Notes

  • The vulnerable code path is in the nanoid/non-secure entry point, so bundles or consumers that import the non-secure module directly are the ones exposed; the secure/default package path is a separate export.
  • The denial-of-service only shows up when callers pass a negative size into these APIs, which the advisory’s regression tests treat as returning an empty string rather than looping.

References

CVSS Base Scores

version 4.0
version 3.1