CVE-2024-55565: Predictable results in nanoid generation when given non-integer values
Medium CVSS 4.3
- OSV id
- GHSA-mwcw-c2x4-8c55
- Also known as
- CVE-2024-55565
- Published
- Last modified
Affected packages
Versions we track that it affects: nanoid 3.3.7; nanoid 3.3.7
How to fix it
nanoid (npm)
Upgrade nanoid to 5.0.9 or later.
npm install nanoid@5.0.9
# if it is an indirect dependency: npm update nanoid (or npm audit fix)
- If it is an indirect dependency, upgrade the package that depends on it, or force the version with "overrides" (npm), "resolutions" (Yarn) or "pnpm.overrides" (pnpm) in package.json.
- Check the changelog for breaking changes (especially across major versions), update the lockfile with the package manager, and run your tests.
nanoid (npm)
Upgrade nanoid to 3.3.8 or later.
npm install nanoid@3.3.8
# if it is an indirect dependency: npm update nanoid (or npm audit fix)
- If it is an indirect dependency, upgrade the package that depends on it, or force the version with "overrides" (npm), "resolutions" (Yarn) or "pnpm.overrides" (pnpm) in package.json.
- Check the changelog for breaking changes (especially across major versions), update the lockfile with the package manager, and run your tests.
Not sure whether your project uses an affected version? Check your lockfile below for free.
Details
When nanoid is called with a fractional value, there were a number of undesirable effects:
- in browser and non-secure, the code infinite loops on while (size--)
- in node, the value of poolOffset becomes fractional, causing calls to nanoid to return zeroes until the pool is next filled
- 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.
References
- GHSA-mwcw-c2x4-8c55 on OSV.dev
- Advisory: https://nvd.nist.gov/vuln/detail/CVE-2024-55565
- Web: https://github.com/ai/nanoid/pull/510
- Package: https://github.com/ai/nanoid
- Web: https://github.com/ai/nanoid/compare/3.3.7...3.3.8
- Web: https://github.com/ai/nanoid/releases/tag/5.0.9
- Web: https://lists.debian.org/debian-lts-announce/2024/12/msg00025.html
- Web: https://lists.debian.org/debian-lts-announce/2025/01/msg00006.html
Am I affected?
Upload or paste your lockfile. We check every package version in it against OSV.dev, this advisory included, and email you the vulnerable ones with the version that fixes them. Free, and no account needed.
About this data
Source: GitHub Advisory Database via OSV.dev (CC-BY 4.0). Severity comes from the advisory's own rating when it has one, else from its CVSS score.