MediumGHSA-mwcw-c2x4-8c55CVE-2024-55565

Predictable results in nanoid generation when given non-integer values

Published 9 Dec 2024 · Updated 10 Sept 2026

Affected packages

Affected
>=4.0.0 <5.0.9
Fixed in
5.0.9
Update to the fixed version for your release line, for example:npm install nanoid@5.0.9
Affected
<3.3.8
Fixed in
3.3.8
Update to the fixed version for your release line, for example:npm install nanoid@3.3.8

Details

When nanoid is called with a fractional value, there were a number of undesirable effects:

1. in browser and non-secure, the code infinite loops on while (size--) 2. in node, the value of poolOffset becomes fractional, causing calls to nanoid to return zeroes until the pool is next filled 3. if the first call in node is a fractional argument, the initial buffer allocation fails with an error

Version 3.3.8 and 5.0.9 are fixed.

Is GHSA-mwcw-c2x4-8c55 in any of your client repos?

Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected nanoid, and gives you the command that fixes it.

References

Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.