Packages / nanoid / Security

HighVulnerabilityGHSA-28wg-ghj8-5hjvCVE-2026-67214Published 29 Jul 2026

nanoid: non-secure generators can loop indefinitely with negative size

Affected releases · nanoid

  • 5.x5.0.0 – 5.1.15Fixed in 5.1.16
  • 4.x4.0.0 – 4.0.2No fix on this line yet
  • 3.x3.0.0 – 3.3.15Fixed in 3.3.16
  • 2.x and older0.1.0 – 2.1.11No fix, no longer updated

On 5.x, the newest line:

npm install nanoid@5.1.16
6.x
  1. Not affected

    6.0.0 – 6.0.2

    3 releases, latest

5.x
  1. Affected

    5.0.0 – 5.1.15

    26 releases

  2. Fixed

    5.1.16

    1 release

4.x
  1. Affected

    4.0.0 – 4.0.2

    3 releases

3.x
  1. Affected

    3.0.0 – 3.3.15

    53 releases

  2. Fixed

    3.3.16 – 3.3.20

    5 releases

2.x
  1. Affected

    2.0.0 – 2.1.11

    17 releases

1.x
  1. Affected

    1.0.0 – 1.3.4

    22 releases

0.x
  1. Affected

    0.1.0 – 0.2.2

    5 releases

135 stable releases of nanoid, oldest to newest, one row per major.

Is your project affected?

Paste your package.json, or type the range you declare for nanoid. It is read in your browser and sent nowhere.

What happens

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.