# CVE-2026-67213: nanoid infinite loop in customAlphabet and customRandom

Source: https://junglewise.ai/threats/cve-2026-67213-nanoid-infinite-loop-in-customalphabet-and-customrandom  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-07-29. Updated: 2026-09-25  
License: CC BY 4.0 with a link back

CVE-2026-67213 · Severity: medium · CVSS 5.9 · Published 2026-07-29

Nano ID is a popular JavaScript library for generating secure, unique identifiers. When the customAlphabet or customRandom functions are called with a size parameter of zero, the library enters an infinite loop that hangs the application thread, causing a denial-of-service. An attacker who can control the size parameter passed to these functions can crash applications using vulnerable versions.

Technologies: [nanoid (npm)](https://junglewise.ai/threats/technologies/nanoid). Vendors: [npm](https://junglewise.ai/threats/vendors/npm).

## Quick answers

**Is CVE-2026-67213 exploited in the wild?** No. Junglewise Threat Intelligence has no report of CVE-2026-67213 being exploited in the wild.

**How severe is CVE-2026-67213?** Medium severity, with a CVSS score of 5.9, published 29 July 2026.

**Which products and versions are affected?** nanoid (npm) SEMVER:introduced=0,fixed=3.3.18.

**Is there a fix for CVE-2026-67213?** Yes. nanoid (npm): upgrade to 3.3.18 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is CVE-2026-67213 attacked?** It is attacked over the network, in a software library.

**Am I affected by CVE-2026-67213?** Check whether you run Nano ID Project Nano ID or nanoid (npm) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## How to fix

- nanoid (npm): upgrade to 3.3.18 or later

  ```sh
  npm install nanoid@3.3.18
  ```


## Technical details

This vulnerability (CWE-835: Infinite Loop) exists in the customAlphabet and customRandom functions of the Nano ID library. The generation loop in these functions fails to handle a zero or negative size parameter, resulting in an exit condition that can never be satisfied. When an application passes an attacker-controlled size value of 0 to these functions without prior validation, the thread executing the function will hang indefinitely, consuming CPU resources and rendering the application unresponsive. The vulnerability affects all versions before 3.3.18 (for the 0.x–3.x branch) and before 5.1.6 (for the 4.x–5.x branch). Patches have been released that add explicit validation to reject zero and negative size parameters, either by throwing an error or returning an empty string depending on the code path.

## Affected products

- ai nanoid before 3.3.18 and 4.0.0 before 5.1.6

## Identifiers

- CVE-2026-67213
- GHSA-2v37-7h3g-55p8

## Timeline

- 2026-07-29: disclosed: Vulnerability published to advisories
- 2026-08-03: patched: Fixes released in versions 3.3.18 and 5.1.6

## References

- [https://github.com/ai/nanoid/commit/cb3626d0f3342fdf179cd425fd9c4fbb92c7d0e7](https://github.com/ai/nanoid/commit/cb3626d0f3342fdf179cd425fd9c4fbb92c7d0e7)
- [https://github.com/ai/nanoid/commit/e10f8d40ce9d1ab47f66d65a16b48086432730d0](https://github.com/ai/nanoid/commit/e10f8d40ce9d1ab47f66d65a16b48086432730d0)
- [https://github.com/ai/nanoid/commit/f9d13f150847d117877adee3460a46eceb0cf49b](https://github.com/ai/nanoid/commit/f9d13f150847d117877adee3460a46eceb0cf49b)
- [https://github.com/ai/nanoid](https://github.com/ai/nanoid)
- [https://github.com/ai/nanoid/releases/tag/3.3.17](https://github.com/ai/nanoid/releases/tag/3.3.17)
- [https://github.com/ai/nanoid/releases/tag/3.3.18](https://github.com/ai/nanoid/releases/tag/3.3.18)

## Related threats

- [nanoid integer overflow in CSPRNG pool](https://junglewise.ai/threats/cve-2026-73086-nanoid-integer-overflow-in-csprng-pool)
- [nanoid infinite loop in non-secure module](https://junglewise.ai/threats/cve-2026-67214-nanoid-infinite-loop-in-non-secure-module)
- [nanoid infinite loop and predictable ID generation with fractional size values](https://junglewise.ai/threats/cve-2024-55565-nanoid-infinite-loop-and-predictable-id-generation-with)
- [nanoid information exposure via valueOf](https://junglewise.ai/threats/cve-2021-23566-nanoid-information-exposure-via-valueof)
