# CVE-2024-55565: nanoid infinite loop and predictable ID generation with fractional size values

Source: https://junglewise.ai/threats/cve-2024-55565-nanoid-infinite-loop-and-predictable-id-generation-with  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2024-12-09. Updated: 2026-09-25  
License: CC BY 4.0 with a link back

CVE-2024-55565 · Severity: low · CVSS 3.1 · Published 2024-12-09

nanoid is a widely-used JavaScript library for generating unique identifiers used in web applications and services. When the library is called with non-integer size values, it causes severe degradation: applications may hang in infinite loops (browser environments), return only zeros (Node.js), or crash during initialization. An attacker or buggy code can trigger this by passing fractional values, disrupting application availability.

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

## Quick answers

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

**How severe is CVE-2024-55565?** Low severity, with a CVSS score of 3.1, published 9 December 2024.

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

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

**How is CVE-2024-55565 attacked?** It is attacked with local access, in a software library.

**Am I affected by CVE-2024-55565?** Check whether you run 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 5.0.9 or later

  ```sh
  npm install nanoid@5.0.9
  ```


## Technical details

The vulnerability is an input validation flaw (CWE-835, infinite loop) in nanoid's size parameter handling. When nanoid is called with a fractional value instead of an integer: in browser/non-secure environments, the while(size--) loop never terminates; in Node.js, poolOffset becomes fractional, causing arithmetic operations to yield undefined values (pool[i] & 63 → undefined & 63 → 0), resulting in only zeros being returned; in some cases, initial buffer allocation fails entirely. The attack vector is local/same-origin (requires calling code to pass fractional size), with no authentication or network requirement. Fix is available in nanoid v3.3.8 and v5.0.9 with explicit integer casting (|0 operator) added to the size parameter.

## Affected products

- ai nanoid 0 to 3.3.7; 4.0.0 to 5.0.8

## Identifiers

- CVE-2024-55565
- GHSA-mwcw-c2x4-8c55

## Timeline

- 2024-12-09: disclosed
- 2024-11-26: patched: Fix merged in PR #510; releases 3.3.8 and 5.0.9

## References

- [https://github.com/ai/nanoid/pull/510](https://github.com/ai/nanoid/pull/510)

## 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 in customAlphabet and customRandom](https://junglewise.ai/threats/cve-2026-67213-nanoid-infinite-loop-in-customalphabet-and-customrandom)
- [nanoid information exposure via valueOf](https://junglewise.ai/threats/cve-2021-23566-nanoid-information-exposure-via-valueof)
