js-yaml: maxTotalMergeKeys does not limit CPU use for empty merge sources
A vulnerability in js-yaml versions 5.0.0 up to but not including 5.4.1 allows an attacker to cause excessive CPU consumption by exploiting how empty merge source mappings are counted. The maxTotalMergeKeys setting does not count empty mappings, enabling an attacker to craft YAML documents that cause the loader to perform O(N*K) work, leading to prolonged CPU usage. This can result in denial of service due to resource exhaustion. A patch is available that adjusts the counting method to include every merge source mapping as one budget unit.
AI Analysis
Technical Summary
The js-yaml library's maxTotalMergeKeys configuration is intended to limit CPU usage by restricting the total number of merge keys processed. However, empty mappings are not counted towards this limit. An attacker can exploit this by repeatedly merging large sequences of empty mappings, causing the loader to iterate over all elements multiple times, resulting in O(N*K) CPU work while the limit remains unchanged. This leads to significant CPU consumption disproportionate to the configured limit. The issue affects versions >=5.0.0 and <5.4.1. The fix involves counting every merge source mapping as one budget unit in addition to counting its keys.
Potential Impact
An attacker can submit a crafted YAML document that triggers excessive CPU consumption during parsing, potentially causing denial of service by exhausting CPU resources. The vulnerability does not affect confidentiality or integrity but impacts availability due to prolonged CPU usage. The CVSS score is 5.3 (medium severity) with an attack vector of network, low attack complexity, no privileges required, no user interaction, and impact limited to availability.
Mitigation Recommendations
A patch is available for js-yaml that fixes this issue by counting every merge source mapping as one budget unit. Users should upgrade to version 5.4.1 or later to mitigate this vulnerability. Until patched, be cautious when processing untrusted YAML documents with merge keys enabled.
js-yaml: maxTotalMergeKeys does not limit CPU use for empty merge sources
Description
A vulnerability in js-yaml versions 5.0.0 up to but not including 5.4.1 allows an attacker to cause excessive CPU consumption by exploiting how empty merge source mappings are counted. The maxTotalMergeKeys setting does not count empty mappings, enabling an attacker to craft YAML documents that cause the loader to perform O(N*K) work, leading to prolonged CPU usage. This can result in denial of service due to resource exhaustion. A patch is available that adjusts the counting method to include every merge source mapping as one budget unit.
CVSS v3.1
Score 5.3medium
Affected software
Run on your own infrastructure? Check whether these packages are installed with threat-finder — our free open-source scanner.
AI-Powered Analysis
Machine-generated threat intelligence
Technical Analysis
The js-yaml library's maxTotalMergeKeys configuration is intended to limit CPU usage by restricting the total number of merge keys processed. However, empty mappings are not counted towards this limit. An attacker can exploit this by repeatedly merging large sequences of empty mappings, causing the loader to iterate over all elements multiple times, resulting in O(N*K) CPU work while the limit remains unchanged. This leads to significant CPU consumption disproportionate to the configured limit. The issue affects versions >=5.0.0 and <5.4.1. The fix involves counting every merge source mapping as one budget unit in addition to counting its keys.
Potential Impact
An attacker can submit a crafted YAML document that triggers excessive CPU consumption during parsing, potentially causing denial of service by exhausting CPU resources. The vulnerability does not affect confidentiality or integrity but impacts availability due to prolonged CPU usage. The CVSS score is 5.3 (medium severity) with an attack vector of network, low attack complexity, no privileges required, no user interaction, and impact limited to availability.
Mitigation Recommendations
A patch is available for js-yaml that fixes this issue by counting every merge source mapping as one budget unit. Users should upgrade to version 5.4.1 or later to mitigate this vulnerability. Until patched, be cautious when processing untrusted YAML documents with merge keys enabled.
Technical Details
- Gcve Source
- db.gcve.eu
- Osv Id
- GHSA-r3ph-w7gj-g6xm
- Osv Schema Version
- 1.4.0
- Ecosystems
- ["npm"]
- Database Specific Severity
- MODERATE
- Cvss Version
- 3.1
Threat ID: 6abc27d2680226ef6846f930
Added to database: 09/29/2026, 21:04:18 UTC
Last enriched: 09/29/2026, 21:22:51 UTC
Last updated: 09/30/2026, 03:15:21 UTC
Views: 3
Community Reviews
0 reviewsCrowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.
Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.
Actions
Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.
Need more coverage?
Upgrade to Pro Console for AI refresh and higher limits.
For incident response and remediation, OffSeq services can help resolve threats faster.
Latest Threats
Check if your credentials are on the dark web
Instant breach scanning across billions of leaked records. Free tier available.