Node.js `tar` Package Symlink Path Traversal — CVE-2026-29786
by Rohitberiwala · 2026-07-05
- Severity
- High
- CVE
- CVE-2026-29786
- Category
- misc
- Affected product
- tar npm package (Node.js)
- Affected versions
- tar@7.5.9 (vulnerable version used in the PoC)
- Disclosed
- 2026-07-05
- Patch status
- unpatched
Tags
Archive entry
intelseclab/poc-archiveMetadata
| Field | Value |
|---|---|
| Date Added | 2026-07-05 |
| Last Updated | 2026-03 |
| Author / Researcher | Rohitberiwala |
| CVE / Advisory | CVE-2026-29786 |
| Category | misc |
| Severity | High |
| CVSS Score | Not specified in source |
| Status | PoC |
| Tags | node-tar, path-traversal, symlink, archive-extraction, arbitrary-file-write, nodejs, supply-chain |
| Related | N/A |
Affected Target
| Field | Value |
|---|---|
| Software / System | tar npm package (Node.js) |
| Versions Affected | tar@7.5.9 (vulnerable version used in the PoC) |
| Language / Platform | JavaScript / Node.js (CommonJS) |
| Authentication Required | No |
| Network Access Required | No (local file processing; exploitable wherever a victim extracts an attacker-supplied archive) |
Summary
The tar package’s extraction engine does not sufficiently validate destination paths when an archive entry is of type symlink. An attacker can craft a tarball containing a symlink entry that points outside the intended extraction directory (e.g. to /etc/shadow or an application config file). When a victim extracts the malicious archive, the extraction engine follows the symlink and subsequent writes are redirected to the attacker-chosen target path, resulting in arbitrary file overwrite outside the extraction root — a classic tar symlink path-traversal issue.
Vulnerability Details
Root Cause
tar’s extraction logic does not properly validate/normalize the resolved destination of symlink entries against the extraction root, allowing symlink targets to escape the intended output directory.
Attack Vector
- Attacker crafts a malicious tarball containing a
symlink-type entry that targets a path outside the extraction directory. - Attacker delivers the tarball to a victim (e.g. via a package, download, or upload feature that later extracts archives).
- Victim extracts the archive using a vulnerable
tarversion. - The extraction engine follows the symlink and any subsequent write attributed to that entry is redirected to the attacker’s target path, overwriting sensitive files.
Impact
Arbitrary file write/overwrite outside the intended extraction directory, potentially leading to configuration tampering, privilege escalation, or code execution depending on which file is overwritten.
Environment / Lab Setup
Target: Node.js application using tar@7.5.9 to extract untrusted archives
Attacker: Node.js runtime, `poc.cjs` script
Proof of Concept
PoC Script
See
poc.cjsin this folder.
| |
poc.cjs builds a malicious tarball containing a symlink entry that escapes the extraction directory, then extracts it using the vulnerable tar package to demonstrate the out-of-bounds file write.
Detection & Indicators of Compromise
Signs of compromise:
- Unexpected modification timestamps on files outside an application’s designated extraction directory
- Archive-extraction logs showing symlink entries with
..-style or absolute targets - File-integrity monitoring alerts correlated with archive upload/extraction endpoints
Remediation
| Action | Detail |
|---|---|
| Primary fix | Upgrade tar to a patched version that validates symlink targets against the extraction root |
| Interim mitigation | Avoid extracting untrusted archives; if unavoidable, extract in a sandboxed/chrooted environment and reject archives containing symlink entries |
References
Notes
Mirrored from https://github.com/Rohitberiwala/NodeJS-Tar-Symlink-Exploit-CVE-2026-29786 on 2026-07-05.