CVE-2026-67214: nanoid: non-secure generators can loop indefinitely with negative size
High CVSS 5.9
- OSV id
- GHSA-28wg-ghj8-5hjv
- Also known as
- CVE-2026-67214
- 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 3.3.16 or later.
npm install nanoid@3.3.16
# 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 5.1.16 or later.
npm install nanoid@5.1.16
# 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
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.
References
- GHSA-28wg-ghj8-5hjv on OSV.dev
- Advisory: https://nvd.nist.gov/vuln/detail/CVE-2026-67214
- Web: https://github.com/ai/nanoid/pull/600
- Web: https://github.com/ai/nanoid/pull/601
- Web: https://github.com/ai/nanoid/commit/6ccc67bbaba71d3d77a21d9b636f4171a268ce49
- Web: https://github.com/ai/nanoid/commit/e835c9b71eab832bc6106944bdd26ea96cf2c66d
- Package: https://github.com/ai/nanoid
- Web: https://github.com/ai/nanoid/releases/tag/5.1.16
- Web: https://www.vulncheck.com/advisories/nanoid-before-infinite-loop-via-negative-size-in-non-secure-module
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.