Packages / nanoid / Security

HighVulnerabilityGHSA-2v37-7h3g-55p8CVE-2026-67213Published 29 Jul 2026

nanoid: custom generators can loop indefinitely when size is zero

Affected releases · nanoid

  • 5.x5.0.0 – 5.1.5Fixed in 5.1.6
  • 4.x4.0.0 – 4.0.2No fix on this line yet
  • 3.x3.0.0 – 3.3.17Fixed in 3.3.18
  • 2.x and older0.1.0 – 2.1.11No fix, no longer updated

On 5.x, the newest line:

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

    6.0.0 – 6.0.2

    3 releases, latest

5.x
  1. Affected

    5.0.0 – 5.1.5

    16 releases

  2. Fixed

    5.1.6 – 5.1.16

    11 releases

4.x
  1. Affected

    4.0.0 – 4.0.2

    3 releases

3.x
  1. Affected

    3.0.0 – 3.3.17

    55 releases

  2. Fixed

    3.3.18 – 3.3.20

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