CVE-2026-59870: js-yaml Denial of Service Vulnerability

MODERATE
Advisory Identifier: GHSA-724g-mxrg-4qvm
CVSS 5.3
CWE-770 CWE-407
Published
Advisory Summary

CVE-2026-59870 is a MODERATE (CVSS 5.3) denial of service vulnerability (CWE-770: Allocation of Resources Without Limits or Throttling) affecting js-yaml libraries in the npm ecosystem. The issue involves quadratic-complexity (o(n^2)) dos via !!omap tag in yaml11_schema. Remediation is available by upgrading affected packages to version 5.2.1.

CVE-2026-59870 at a Glance

CVE Identifier CVE-2026-59870
GHSA Identifier GHSA-724g-mxrg-4qvm
Severity MODERATE
CVSS v3.1 Base Score 5.3
CWE Classification CWE-770: Allocation of Resources Without Limits or Throttling
Affected Product js-yaml
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 5.3

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

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

How to Fix CVE-2026-59870

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

js-yaml fixed: 5.2.1
npm install js-yaml@5.2.1
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 js-yaml

How to Check if You Are Affected

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

npm ls js-yaml

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

Note: The npm ls js-yaml 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-770: Allocation of Resources Without Limits or Throttling, where the product allocates a reusable resource or group of resources on behalf of an actor without imposing any intended restrictions on the size or number of resources that can be allocated. In js-yaml, 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 `js-yaml` v5.x introduces `YAML11_SCHEMA` support with the `!!omap` (ordered map) tag. The `omapTag.addItem()` function performs a linear O(n) scan for duplicate key detection on every insertion, resulting in O(n^2) total time to parse a document with n omap entries. An attacker can send a small crafted YAML document to trigger a multi-second CPU stall in any application that uses `yaml.load()` with `{ schema: yaml.YAML11_SCHEMA }`. ### Details In `src/tag/sequence/omap.ts` (compiled: `dist/js-yaml.cjs.js:510-525`): ```js var omapTag = defineSequenceTag('tag:yaml.org,2002:omap', { create: () => [], addItem: (container, item) => { // ... for (const existing of container) // O(n) per insertion! if (hasOwnProperty(existing, itemKeys[0])) return 'cannot resolve an ordered map item'; container.push(object); // n insertions → O(n^2) total return ''; } }); ``` For a document with `n` unique entries, insertion i scans i−1 existing entries, yielding 1+2+…+n = **O(n²)** total work. ### PoC (runtime-confirmed on v5.2.0) ```js const yaml = require('js-yaml'); function buildOmapPayload(n) { let p = '!!omap\n'; for (let i = 0; i < n; i++) p += '- key' + i + ': val' + i + '\n'; return p; } // Timing results on v5.2.0: // n=1000: 9ms // n=5000: 73ms (5x n → 8x time) // n=10000: 255ms (2x n → 3.5x time — supralinear) // n=20000: 997ms (2x n → 3.9x time — O(n²) confirmed) // n=50000: 10613ms ← blocks event loop for >10 seconds yaml.load(buildOmapPayload(50000), { schema: yaml.YAML11_SCHEMA }); ``` ### Impact Any application that parses untrusted YAML using `yaml.load(input, { schema: yaml.YAML11_SCHEMA })` is vulnerable to Denial of Service. A ~2 MB payload of 50,000 entries blocks the Node.js event loop for 10+ seconds. Smaller payloads (5,000 entries, ~100 KB) already cause noticeable slowdowns (73 ms per parse, amplified under concurrent load). This affects the newly released 5.x series (first published 2026-06-20) which adds YAML 1.1/1.2 schema support including `!!omap`. The 4.x series is unaffected (no `YAML11_SCHEMA` export). ### Fix Replace the O(n) linear scan in `addItem` with an O(1) `Set`-based lookup: ```js var omapTag = defineSequenceTag('tag:yaml.org,2002:omap', { create: () => ({ list: [], seen: new Set() }), addItem: (state, item) => { const key = Object.keys(item)[0]; if (state.seen.has(key)) return 'duplicate omap key'; state.seen.add(key); state.list.push(item); return ''; }, resolve: (state) => state.list }); ```

CVE-2026-59870 Affected js-yaml Versions

1 component(s)
Fixed Versions:
5.2.1
Product / Package Ecosystem Affected Versions Fixed Version
js-yaml
npm
≥ 5.0.0
< 5.2.1
5.2.1

References

Frequently Asked Questions

What is CVE-2026-59870?
CVE-2026-59870 is a security vulnerability in js-yaml involving Quadratic-complexity (O(n^2)) DoS via !!omap tag in YAML11_SCHEMA under CWE-770: Allocation of Resources Without Limits or Throttling.
Which js-yaml versions are affected?
Affected versions include releases prior to 5.2.1 across affected packages: js-yaml.
What version fixes CVE-2026-59870?
Upgrading to 5.2.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is js-yaml affected?
Yes, js-yaml is affected in releases prior to 5.2.1. Upgrade your dependency to 5.2.1 or later.
What is the CVSS score of CVE-2026-59870?
CVE-2026-59870 has a CVSS v3.1 base score of 5.3 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L.
What CWE is associated with CVE-2026-59870?
CVE-2026-59870 is classified under CWE-770: Allocation of Resources Without Limits or Throttling (The product allocates a reusable resource or group of resources on behalf of an actor without imposing any intended restrictions on the size or number of resources that can be allocated.).
How can I check npm dependencies for CVE-2026-59870?
Run the dependency tree command: 'npm ls js-yaml'. 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-724g-mxrg-4qvm",
  "modified" : "2026-07-20T21:18:51Z",
  "published" : "2026-07-20T21:18:51Z",
  "aliases" : [ "CVE-2026-59870" ],
  "summary" : "js-yaml: Quadratic-complexity (O(n^2)) DoS via !!omap tag in YAML11_SCHEMA",
  "details" : "### Summary\n`js-yaml` v5.x introduces `YAML11_SCHEMA` support with the `!!omap` (ordered map) tag. The `omapTag.addItem()` function performs a linear O(n) scan for duplicate key detection on every insertion, resulting in O(n^2) total time to parse a document with n omap entries. An attacker can send a small crafted YAML document to trigger a multi-second CPU stall in any application that uses `yaml.load()` with `{ schema: yaml.YAML11_SCHEMA }`.\n\n### Details\nIn `src/tag/sequence/omap.ts` (compiled: `dist/js-yaml.cjs.js:510-525`):\n```js\nvar omapTag = defineSequenceTag('tag:yaml.org,2002:omap', {\n    create: () => [],\n    addItem: (container, item) => {\n        // ...\n        for (const existing of container)   // O(n) per insertion!\n            if (hasOwnProperty(existing, itemKeys[0]))\n                return 'cannot resolve an ordered map item';\n        container.push(object);             // n insertions → O(n^2) total\n        return '';\n    }\n});\n```\nFor a document with `n` unique entries, insertion i scans i−1 existing entries, yielding 1+2+…+n = **O(n²)** total work.\n\n### PoC (runtime-confirmed on v5.2.0)\n```js\nconst yaml = require('js-yaml');\nfunction buildOmapPayload(n) {\n  let p = '!!omap\\n';\n  for (let i = 0; i < n; i++) p += '- key' + i + ': val' + i + '\\n';\n  return p;\n}\n// Timing results on v5.2.0:\n// n=1000:  9ms\n// n=5000:  73ms  (5x n → 8x time)\n// n=10000: 255ms (2x n → 3.5x time — supralinear)\n// n=20000: 997ms (2x n → 3.9x time — O(n²) confirmed)\n// n=50000: 10613ms          ← blocks event loop for >10 seconds\nyaml.load(buildOmapPayload(50000), { schema: yaml.YAML11_SCHEMA });\n```\n\n### Impact\nAny application that parses untrusted YAML using `yaml.load(input, { schema: yaml.YAML11_SCHEMA })` is vulnerable to Denial of Service. A ~2 MB payload of 50,000 entries blocks the Node.js event loop for 10+ seconds. Smaller payloads (5,000 entries, ~100 KB) already cause noticeable slowdowns (73 ms per parse, amplified under concurrent load).\n\nThis affects the newly released 5.x series (first published 2026-06-20) which adds YAML 1.1/1.2 schema support including `!!omap`. The 4.x series is unaffected (no `YAML11_SCHEMA` export).\n\n### Fix\nReplace the O(n) linear scan in `addItem` with an O(1) `Set`-based lookup:\n```js\nvar omapTag = defineSequenceTag('tag:yaml.org,2002:omap', {\n    create: () => ({ list: [], seen: new Set() }),\n    addItem: (state, item) => {\n        const key = Object.keys(item)[0];\n        if (state.seen.has(key)) return 'duplicate omap key';\n        state.seen.add(key);\n        state.list.push(item);\n        return '';\n    },\n    resolve: (state) => state.list\n});\n```",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "js-yaml"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "5.0.0"
      }, {
        "fixed" : "5.2.1"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 5.2.0"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/nodeca/js-yaml/security/advisories/GHSA-724g-mxrg-4qvm"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-59870"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/nodeca/js-yaml/commit/39f3211a2f01b3c6982710cf21434ab7060acefe"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/nodeca/js-yaml"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/nodeca/js-yaml/releases/tag/5.2.1"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-407", "CWE-770" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-07-20T21:18:51Z",
    "nvd_published_at" : "2026-07-08T16:16:33Z"
  }
}