nanoid

Ecosystem: npm

Downloads: 1.22 Bln

Vulnerabilities from the last (months)
  • 0CriticalAffects 0 versions
  • 3HighAffects 6 versions
  • 0MediumAffects 0 versions
  • 2ModerateAffects 3 versions
  • 0LowAffects 0 versions
Severity distribution (all time)
5vulnerabilities
  • Critical0 (0.0%)
  • High3 (60.0%)
  • Medium0 (0.0%)
  • Moderate2 (40.0%)
  • Low0 (0.0%)

Monthly breakdown

  • Critical
  • High
  • Medium
  • Moderate
  • Low
  • 1 vulnerabilities
    • Critical: 0
    • High: 1
    • Medium: 0
    • Moderate: 0
    • Low: 0
  • 2 vulnerabilities
    • Critical: 0
    • High: 2
    • Medium: 0
    • Moderate: 0
    • Low: 0
  • 1 vulnerabilities
    • Critical: 0
    • High: 0
    • Medium: 0
    • Moderate: 1
    • Low: 0
  • 1 vulnerabilities
    • Critical: 0
    • High: 0
    • Medium: 0
    • Moderate: 1
    • Low: 0

Vulnerabilities (5)

Known vulnerabilities affecting nanoid, based on data from OSV.

Vulnerabilities affecting nanoid
IDSeveritySummaryAffected versionsPublishedSource
GHSA-xwg4-73v4-xw9wHighnanoid: Integer Overflow or Wraparound### Summary An integer overflow in `nanoid(size)` permanently corrupts the process-wide CSPRNG pool, causing all subsequent ID generation to return the deterministic string `"uuuuuuuuuuuuuuuuuuuuu"`. Any application that passes user-influenced values to the `size` parameter loses all randomness guarantees for session tokens, CSRF tokens, and unique identifiers until process restart. ### Details `nanoid()` at [`index.js:101`](https://github.com/ai/nanoid/blob/main/index.js#L101) coerces the `size` parameter with `size |= 0`, which converts it to a signed 32-bit integer. When `size >= 2^31` (
  • < 3.3.12
  • >= 4.0.0, < 5.1.11
GitHub (opens in a new tab)
GHSA-28wg-ghj8-5hjvHighnanoid: non-secure generators can loop indefinitely with negative sizenanoid (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.
  • < 3.3.16
  • >= 4.0.0, < 5.1.16
GitHub (opens in a new tab)
GHSA-2v37-7h3g-55p8Highnanoid: custom generators can loop indefinitely when size is zeronanoid (Nano ID) before 5.1.6 contains an infinite loop in the customAlphabet and customRandom functions. When these functions are configured with a size of 0, the internal generation loop never satisfies its exit condition and spins indefinitely, hanging the calling thread. An application that passes an unvalidated, attacker-controlled size of 0 to these functions is exposed to a denial-of-service condition.
  • < 3.3.18
  • >= 4.0.0, < 5.1.6
GitHub (opens in a new tab)
GHSA-mwcw-c2x4-8c55ModeratePredictable results in nanoid generation when given non-integer valuesWhen 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.
  • >= 4.0.0, < 5.0.9
  • < 3.3.8
GitHub (opens in a new tab)
GHSA-qrpm-p2h7-hrv2ModerateExposure of Sensitive Information to an Unauthorized Actor in nanoidThe package nanoid from 3.0.0, before 3.1.31, are vulnerable to Information Exposure via the valueOf() function which allows to reproduce the last id generated.
  • >= 3.0.0, < 3.1.31
GitHub (opens in a new tab)
  • GHSA-xwg4-73v4-xw9wHigh
    nanoid: Integer Overflow or Wraparound
    • < 3.3.12
    • >= 4.0.0, < 5.1.11

    ### Summary An integer overflow in `nanoid(size)` permanently corrupts the process-wide CSPRNG pool, causing all subsequent ID generation to return the deterministic string `"uuuuuuuuuuuuuuuuuuuuu"`. Any application that passes user-influenced values to the `size` parameter loses all randomness guarantees for session tokens, CSRF tokens, and unique identifiers until process restart. ### Details `nanoid()` at [`index.js:101`](https://github.com/ai/nanoid/blob/main/index.js#L101) coerces the `size` parameter with `size |= 0`, which converts it to a signed 32-bit integer. When `size >= 2^31` (

    CVE: CVE-2026-73086

  • GHSA-28wg-ghj8-5hjvHigh
    nanoid: non-secure generators can loop indefinitely with negative size
    • < 3.3.16
    • >= 4.0.0, < 5.1.16

    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.

    CVE: CVE-2026-67214

  • GHSA-2v37-7h3g-55p8High
    nanoid: custom generators can loop indefinitely when size is zero
    • < 3.3.18
    • >= 4.0.0, < 5.1.6

    nanoid (Nano ID) before 5.1.6 contains an infinite loop in the customAlphabet and customRandom functions. When these functions are configured with a size of 0, the internal generation loop never satisfies its exit condition and spins indefinitely, hanging the calling thread. An application that passes an unvalidated, attacker-controlled size of 0 to these functions is exposed to a denial-of-service condition.

    CVE: CVE-2026-67213

  • GHSA-mwcw-c2x4-8c55Moderate
    Predictable results in nanoid generation when given non-integer values
    • >= 4.0.0, < 5.0.9
    • < 3.3.8

    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.

    CVE: CVE-2024-55565

  • GHSA-qrpm-p2h7-hrv2Moderate
    Exposure of Sensitive Information to an Unauthorized Actor in nanoid
    • >= 3.0.0, < 3.1.31

    The package nanoid from 3.0.0, before 3.1.31, are vulnerable to Information Exposure via the valueOf() function which allows to reproduce the last id generated.

    CVE: CVE-2021-23566

Showing 1-5 of 5 vulnerabilities