node-tar Hardlink/Symlink Path Traversal Arbitrary File Overwrite (CVE-2026-23745)
by Joshua van Rijswijk (Jvr2022) · 2026-07-05
- Severity
- High
- CVE
- CVE-2026-23745 / GHSA-8qq5-rm4j-mr97
- Category
- misc
- Affected product
- node-tar (npm package tar)
- Affected versions
- < 7.5.2 (patched in 7.5.3)
- Disclosed
- 2026-07-05
- Patch status
- patched
Tags
References
Archive entry
intelseclab/poc-archiveMetadata
| Field | Value |
|---|---|
| Date Added | 2026-07-05 |
| Last Updated | 2026-01 |
| Author / Researcher | Joshua van Rijswijk (Jvr2022) |
| CVE / Advisory | CVE-2026-23745 / GHSA-8qq5-rm4j-mr97 |
| Category | misc |
| Severity | High |
| CVSS Score | Not specified in source |
| Status | PoC |
| Tags | node-tar, path-traversal, arbitrary-file-overwrite, hardlink, symlink, supply-chain, nodejs, tar-archive |
| Related | N/A |
Affected Target
| Field | Value |
|---|---|
| Software / System | node-tar (npm package tar) |
| Versions Affected | < 7.5.2 (patched in 7.5.3) |
| Language / Platform | JavaScript / Node.js |
| Authentication Required | No |
| Network Access Required | No |
Summary
node-tar fails to sanitize absolute paths supplied in the linkpath field of hardlink and symlink tar entries. In src/unpack.ts, the library resolves the link target with path.resolve(this.cwd, String(entry.linkpath)), but path.resolve() ignores the base cwd argument whenever the second argument is itself an absolute path. This means a maliciously crafted tar archive can specify an absolute linkpath (e.g. /etc/passwd or an arbitrary file inside the extraction consumer’s project) and node-tar will create a link pointing outside the intended extraction directory — even when the caller has set preservePaths: false expecting containment. The included PoC builds such a malicious archive, extracts it, and confirms it can overwrite an arbitrary file’s contents through the created link.
Vulnerability Details
Root Cause
path.resolve(this.cwd, entry.linkpath) in node-tar’s unpack logic ignores the extraction root whenever linkpath is an absolute path, so hardlink/symlink entries are not confined to the intended output directory regardless of the preservePaths setting.
Attack Vector
- Attacker crafts a tar archive containing a
Link(hardlink) entry whoselinkpathis an absolute path to a target file, plus aSymbolicLinkentry pointing to a sensitive system path. - Victim application extracts the archive using a vulnerable
node-tarversion withpreservePaths: false(the “safe” default). - node-tar resolves the absolute
linkpathvalues literally instead of confining them under the extraction directory. - The attacker (or a subsequent write through the extracted link) overwrites the arbitrary target file’s contents.
Impact
Arbitrary file overwrite outside the intended extraction directory, which can lead to configuration tampering, dependency/code poisoning, or further compromise depending on which file is overwritten.
Environment / Lab Setup
Target: node-tar (tar npm package) < 7.5.2
Attacker: Node.js runtime, `npm install tar@7.5.2`
Proof of Concept
PoC Script
See
poc.jsin this folder.
| |
The script builds a malicious tar archive containing an absolute-path hardlink and symlink entry, extracts it with preservePaths: false, and then writes through the extracted hardlink to confirm that a file outside the extraction directory (secret.txt) gets overwritten — printing VULN CONFIRMED on success.
Detection & Indicators of Compromise
Signs of compromise:
- Files modified or replaced shortly after a tar archive extraction step, especially outside the expected output directory.
- Tar archives containing
Link/SymbolicLinkentries with absolutelinkpathvalues. - Unexpected symlinks/hardlinks appearing in extraction output directories pointing to system or application-sensitive paths.
Remediation
| Action | Detail |
|---|---|
| Primary fix | Upgrade to node-tar 7.5.3 or later, which adds stripAbsolutePath() to sanitize link targets before resolution |
| Interim mitigation | Avoid extracting untrusted tar archives; if unavoidable, extract in an isolated/sandboxed filesystem and validate archive entries before extraction |
References
Notes
Mirrored from https://github.com/Jvr2022/CVE-2026-23745 on 2026-07-05.
| |