CVE-2026-73086: nanoid Integer Overflow Or Wraparound Vulnerability

HIGH
Advisory Identifier: GHSA-xwg4-73v4-xw9w
CVSS 7.4
CWE-190
Published
Advisory Summary

CVE-2026-73086 is a HIGH (CVSS 7.4) integer overflow or wraparound vulnerability (CWE-190: Integer Overflow or Wraparound) affecting nanoid libraries in the npm ecosystem. The issue involves integer overflow or wraparound. Remediation is available by upgrading affected packages to version 3.3.12, 5.1.11.

CVE-2026-73086 at a Glance

CVE Identifier CVE-2026-73086
GHSA Identifier GHSA-xwg4-73v4-xw9w
Severity HIGH
CVSS v3.1 Base Score 7.4
CWE Classification CWE-190: Integer Overflow or Wraparound
Affected Product nanoid
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 7.4

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:N).

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability None (A:N)

How to Fix CVE-2026-73086

To remediate this vulnerability, upgrade all affected nanoid dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

nanoid fixed: 3.3.12
npm install nanoid@3.3.12
nanoid fixed: 5.1.11
npm install nanoid@5.1.11
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls nanoid

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2026-73086, inspect your project dependencies using npm:

npm ls nanoid

Analyze the terminal output to locate any version of nanoid in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.3.12), your application is affected.

Note: The npm ls nanoid command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-190: Integer Overflow or Wraparound, where the product performs a calculation that can produce an integer overflow or wraparound when the logic assumes that the resulting value will always be larger than the original value. this occurs when an integer value is incremented to a value that is too large to store in the associated representation. when this occurs, the value may become a very small or negative number. In nanoid, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### 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` (e.g., `2147483648`), this wraps to `-2147483648`. The negative value is passed to `fillPool()` ([`index.js:15`](https://github.com/ai/nanoid/blob/main/index.js#L15)): ```javascript function fillPool(bytes) { if (!pool || pool.length < bytes) { // false: pool exists, -2B < pool.length pool = Buffer.allocUnsafe(bytes * POOL_SIZE_MULTIPLIER) crypto.getRandomValues(pool) poolOffset = 0 } else if (poolOffset + bytes > pool.length) { // false: poolOffset + (-2B) < pool.length crypto.getRandomValues(pool) poolOffset = 0 } poolOffset += bytes // poolOffset += -2147483648 → deeply negative } ``` Neither branch triggers, so the pool is never refreshed. `poolOffset` becomes ~-2.1 billion. Subsequent `nanoid()` calls execute: ```javascript for (let i = poolOffset - size; i < poolOffset; i++) { id += scopedUrlAlphabet[pool[i] & 63] } ``` `pool[negative_index]` returns `undefined`. `undefined & 63` evaluates to `0`. `urlAlphabet[0]` is `'u'`. Every ID becomes `"uuuuuuuuuuuuuuuuuuuuu"`. The corruption is **persistent** — it affects all subsequent calls in the process until ~100 million calls eventually wrap `poolOffset` back to positive, or the process restarts. ### PoC ```javascript import { nanoid } from 'nanoid' // Step 1: Normal operation console.log(nanoid()) // e.g., "V1StGXR8_Z5jdHi6B-myT" // Step 2: Trigger overflow (e.g., from an API parameter) try { nanoid(2147483648) } catch(e) {} // Step 3: All subsequent IDs are deterministic console.log(nanoid()) // "uuuuuuuuuuuuuuuuuuuuu" console.log(nanoid()) // "uuuuuuuuuuuuuuuuuuuuu" console.log(nanoid()) // "uuuuuuuuuuuuuuuuuuuuu" // ... forever, process-wide ``` Run with: `node --experimental-vm-modules poc.mjs` Attack scenario: Any API endpoint that accepts a user-controlled length/size parameter (URL shortener slug length, configurable token size, etc.) and passes it to `nanoid(userInput)`. ### Impact **Complete loss of ID unpredictability and uniqueness, process-wide, from a single request.** - All session IDs, CSRF tokens, API keys, and database identifiers generated after the attack are identical and predictable - An attacker can predict all tokens issued to other users, enabling session hijacking and authentication bypass - The corruption is persistent (survives across requests) and affects all consumers of `nanoid` in the same process - No special privileges or preconditions required — a single unauthenticated request is sufficient - Affects any application that passes external input to the `size` parameter without validation

CVE-2026-73086 Affected nanoid Versions

2 component(s)
Fixed Versions:
3.3.125.1.11
Product / Package Ecosystem Affected Versions Fixed Version
nanoid
npm
< 3.3.12
3.3.12
nanoid
npm
≥ 4.0.0
< 5.1.11
5.1.11

References

Frequently Asked Questions

What is CVE-2026-73086?
CVE-2026-73086 is a security vulnerability in nanoid involving Integer Overflow or Wraparound under CWE-190: Integer Overflow or Wraparound.
Which nanoid versions are affected?
Affected versions include releases prior to 3.3.12, 5.1.11 across affected packages: nanoid.
What version fixes CVE-2026-73086?
Upgrading to 3.3.12, 5.1.11 (or the latest patched release for your respective branch) resolves the vulnerability.
Is nanoid affected?
Yes, nanoid is affected in releases prior to 3.3.12, 5.1.11. Upgrade your dependency to 3.3.12, 5.1.11 or later.
What is the CVSS score of CVE-2026-73086?
CVE-2026-73086 has a CVSS v3.1 base score of 7.4 (HIGH) with vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:N.
What CWE is associated with CVE-2026-73086?
CVE-2026-73086 is classified under CWE-190: Integer Overflow or Wraparound (The product performs a calculation that can produce an integer overflow or wraparound when the logic assumes that the resulting value will always be larger than the original value. This occurs when an integer value is incremented to a value that is too large to store in the associated representation. When this occurs, the value may become a very small or negative number.).
How can I check npm dependencies for CVE-2026-73086?
Run the dependency tree command: 'npm ls nanoid'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-xwg4-73v4-xw9w",
  "modified" : "2026-09-01T19:23:45Z",
  "published" : "2026-09-01T19:23:45Z",
  "aliases" : [ "CVE-2026-73086" ],
  "summary" : "nanoid: Integer Overflow or Wraparound",
  "details" : "### Summary\n\nAn 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.\n\n### Details\n\n`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` (e.g., `2147483648`), this wraps to `-2147483648`.\n\nThe negative value is passed to `fillPool()` ([`index.js:15`](https://github.com/ai/nanoid/blob/main/index.js#L15)):\n\n```javascript\nfunction fillPool(bytes) {\n  if (!pool || pool.length < bytes) {       // false: pool exists, -2B < pool.length\n    pool = Buffer.allocUnsafe(bytes * POOL_SIZE_MULTIPLIER)\n    crypto.getRandomValues(pool)\n    poolOffset = 0\n  } else if (poolOffset + bytes > pool.length) {  // false: poolOffset + (-2B) < pool.length\n    crypto.getRandomValues(pool)\n    poolOffset = 0\n  }\n  poolOffset += bytes  // poolOffset += -2147483648 → deeply negative\n}\n```\n\nNeither branch triggers, so the pool is never refreshed. `poolOffset` becomes ~-2.1 billion.\n\nSubsequent `nanoid()` calls execute:\n```javascript\nfor (let i = poolOffset - size; i < poolOffset; i++) {\n  id += scopedUrlAlphabet[pool[i] & 63]\n}\n```\n\n`pool[negative_index]` returns `undefined`. `undefined & 63` evaluates to `0`. `urlAlphabet[0]` is `'u'`. Every ID becomes `\"uuuuuuuuuuuuuuuuuuuuu\"`.\n\nThe corruption is **persistent** — it affects all subsequent calls in the process until ~100 million calls eventually wrap `poolOffset` back to positive, or the process restarts.\n\n### PoC\n\n```javascript\nimport { nanoid } from 'nanoid'\n\n// Step 1: Normal operation\nconsole.log(nanoid())  // e.g., \"V1StGXR8_Z5jdHi6B-myT\"\n\n// Step 2: Trigger overflow (e.g., from an API parameter)\ntry { nanoid(2147483648) } catch(e) {}\n\n// Step 3: All subsequent IDs are deterministic\nconsole.log(nanoid())  // \"uuuuuuuuuuuuuuuuuuuuu\"\nconsole.log(nanoid())  // \"uuuuuuuuuuuuuuuuuuuuu\"\nconsole.log(nanoid())  // \"uuuuuuuuuuuuuuuuuuuuu\"\n// ... forever, process-wide\n```\n\nRun with: `node --experimental-vm-modules poc.mjs`\n\nAttack scenario: Any API endpoint that accepts a user-controlled length/size parameter (URL shortener slug length, configurable token size, etc.) and passes it to `nanoid(userInput)`.\n\n### Impact\n\n**Complete loss of ID unpredictability and uniqueness, process-wide, from a single request.**\n\n- All session IDs, CSRF tokens, API keys, and database identifiers generated after the attack are identical and predictable\n- An attacker can predict all tokens issued to other users, enabling session hijacking and authentication bypass\n- The corruption is persistent (survives across requests) and affects all consumers of `nanoid` in the same process\n- No special privileges or preconditions required — a single unauthenticated request is sufficient\n- Affects any application that passes external input to the `size` parameter without validation",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "nanoid"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "3.3.12"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "nanoid"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "4.0.0"
      }, {
        "fixed" : "5.1.11"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/ai/nanoid/security/advisories/GHSA-xwg4-73v4-xw9w"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-73086"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/ai/nanoid/commit/7087969281cab8ba8ae3babf1894e819068b3bb4"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/ai/nanoid/commit/821dfed7b5db7f88e92f56c60eef32c8135077c3"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/ai/nanoid/commit/b0036ed60dc9facd7f1191a50dfb3076500202ac"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/ai/nanoid"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/ai/nanoid/releases/tag/3.3.12"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/ai/nanoid/releases/tag/5.1.11"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-190" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-09-01T19:23:45Z",
    "nvd_published_at" : "2026-08-11T17:19:16Z"
  }
}