CVE Professor
/
All CVEs
CVE-2026-140235

CVE-2026-140235 — Tar — CWE-20 · CWE-436

HIGH CVSS 7.2 ⚡ EPSS 0.8% GitHub

### Summary node-tar parses POSIX pax extended headers by splitting the header body on every newline and validating each resulting line's length prefix, instead of consuming length-delimited records as the format specifies. A record whose value contains a newline (which occurs legitimately whenever an archived filename contains a newline) is mishandled two ways: the true record is dropped (the entry falls back to its truncated 100-byte header name), and any post-newline fragment that itself forms a self-valid `<length> key=value` line is applied as a real extended-header field. This is a cross-implementation divergence and an arbitrary PAX-field injection primitive (`path`, `size`, `linkpath`, `mode`, `uid`, `gid`, `mtime`) driven by a single attacker-controlled filename or crafted archive. ### Details ```ts // src/pax.ts:151-167 const parseKV = (str) => str.replace(/\n$/, '').split('\n') // <- splits INSIDE length-valid record values .reduce(parseKVLine, Object.create(null)) const parseKVLine = (set, line) => { const n = parseInt(line, 10) // XXX Values with \n in them will fail this. // Refactor to not be a naive line-by-line parse. if (n !== Buffer.byteLength(line) + 1) return set // record dropped when its value contained '\n' line = line.slice((n + ' ').length) // ... a forged '<len> key=value' fragment is then ACCEPTED as a real record } ``` POSIX pax records are `<len> key=value\n`, where `<len>` counts the entire record including any ne

### Summary node-tar parses POSIX pax extended headers by splitting the header body on every newline and validating each resulting line's length prefix, instead of consuming length-delimited records as the format specifies. A record whose value contains a newline (which occurs legitimately whenever an archived filename contains a newline) is mishandled two ways: the true record is dropped (the entry falls back to its truncated 100-byte header name), and any post-newline fragment that itself forms a self-valid `<length> key=value` line is applied as a real extended-header field. This is a cross-implementation divergence and an arbitrary PAX-field injection primitive (`path`, `size`, `linkpath`, `mode`, `uid`, `gid`, `mtime`) driven by a single attacker-controlled filename or crafted archive. ### Details ```ts // src/pax.ts:151-167 const parseKV = (str) => str.replace(/\n$/, '').split('\n') // <- splits INSIDE length-valid record values .reduce(parseKVLine, Object.create(null)) const parseKVLine = (set, line) => { const n = parseInt(line, 10) // XXX Values with \n in them will fail this. // Refactor to not be a naive line-by-line parse. if (n !== Buffer.byteLength(line) + 1) return set // record dropped when its value contained '\n' line = line.slice((n + ' ').length) // ... a forged '<len> key=value' fragment is then ACCEPTED as a real record } ``` POSIX pax records are `<len> key=value\n`, where `<len>` counts the entire record including any ne

CVSS v4.0 Vector Metrics
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:L/VI:H/VA:L/SC:N/SI:N/SA:N
Attack Vector Network AV:N
Attack Complexity Low AC:L
Attack Reqs. None AT:N
Privileges Req. None PR:N
User Interaction Passive UI:P
Vuln. Conf. Low VC:L
Vuln. Integrity High VI:H
Vuln. Avail. Low VA:L
Subseq. Conf. None SC:N
Subseq. Integ. None SI:N
Subseq. Avail. None SA:N
EPSS — Exploit Prediction Scoring System
0.8%
30-day probability
In the 59. percentile of all CVEs — higher exploitation probability than most vulnerabilities.
AI Security Analysis & Remediation

🎯 What is this vulnerability?

Root cause
node-tar (versions 7.5.0 – 8.0.0) parses PAX records with a helper called parseKV.
PAX records are length‑delimited key/value pairs that may contain arbitrary data, including newline characters (\n).
parseKV naïvely splits the record on every newline, treating each line as a separate key/value pair.
If a newline appears inside a value, the parser:

1. Drops the original field – the key/value pair that contained the newline is lost.
2. Treats the trailing fragment (the part after the newline) as a new key/value pair.

When the forged key is one of the special tar header fields (path, size, linkpath, etc.), the library ends up creating an entry with a forged attribute that can point outside the intended extraction directory.

CWE mapping

CWEDescription
CWE‑20Improper Input Validation – the library accepts arbitrary PAX data without sanitising newlines.
CWE‑436Improper Handling of Path Traversal – forged path values can escape the extraction root when preservePaths is enabled.

Impact of the missing check

  • Integrity: The attacker can overwrite arbitrary files on disk (e.g., configuration files, web‑root files).
  • Privilege Escalation: If the Node.js process runs as a privileged user (root, system, or a user with write access to critical directories), the attacker can modify binaries or scripts.
  • Remote Code Execution (RCE): By writing a malicious script or binary into a web‑accessible directory, the attacker can later execute it.
  • Availability: Not a primary concern; the flaw does not crash the extractor, but corrupted archives could cause downstream failures.

  • ⚡ Attack Chain

    Assumptions
    * The target application uses node-tar ≥ 7.5.0 and < 8.0.0.
    * The application accepts user‑supplied tar archives (file upload, API endpoint, etc.).
    * preservePaths is enabled (the default is false).
    * The Node.js process runs with write access to the extraction root or higher.

    1. Discovery & Reconnaissance

    StepTechniqueTool / Command
    Identify vulnerable librarySearch package.json or npm ls output for node-tarnpm ls node-tar
    Determine versionInspect the resolved versionnpm ls node-tar → [email protected]
    Confirm preservePaths usageReview source code or configurationSearch for preservePaths: true in the codebase
    If the application is a black‑box web service, a simple upload of a tar file and observation of the response can reveal whether the extraction succeeded or failed.

    2. Exploitation

    2.1 Crafting the malicious tar

    The PAX record format is:

    <length> <key>=<value>\n

    parseKV splits on \n.
    To exploit, we embed a newline inside the value of a key that controls the extraction path.

    Example payload – a tar archive that writes /tmp/evil.txt into the extraction root when preservePaths is true.

    # Create a benign file that will be extracted
    echo "Hello world" > /tmp/hello.txt
    
    # Build a malicious tar with a PAX record that contains a newline in the value
    # The record will be interpreted as:
    #   path=../../../../../../../../tmp/evil.txt
    #   (the rest of the line after the newline is ignored)
    tar --format=ustar \
        --pax-option="path=../../../../../../../../tmp/evil.txt\n" \
        -cf malicious.tar /tmp/hello.txt
    The \n inside the path= value forces parseKV to split the record, dropping the original path field and turning the trailing fragment into a forged path.

    2.2 Delivering the archive

    Assume the application exposes an upload endpoint /api/upload that accepts a tar file and extracts it with:

    const tar = require('node-tar');
    tar.extract({
      file: req.file.path,
      cwd: '/var/www/app/uploads',
      preservePaths: true
    });

    PoC request (illustrative)

    curl -X POST http://target.example.com/api/upload \
      -F "[email protected]"
    If the endpoint is protected by authentication, the attacker must first obtain valid credentials or exploit an unauthenticated upload path.

    2.3 Result

    When node-tar processes malicious.tar:

  • The forged path value resolves to /tmp/evil.txt (outside /var/www/app/uploads).
  • Because preservePaths is true, the library does not sanitize the path.
  • /tmp/evil.txt is created (or overwritten) with the contents of hello.txt.
  • If the attacker writes a malicious script instead of hello.txt, they can achieve RCE.

    3. Post‑Exploitation

    GoalTechniqueOutcome
    Write arbitrary filesUse the same mechanism to write a PHP/Node.js script into the web rootThe attacker can later access the script via HTTP
    Privilege EscalationIf the Node.js process runs as root, overwrite /etc/passwd or a system binaryGain root shell or modify system configuration
    PersistenceDeploy a cron job or systemd unit via the same path traversalMaintain long‑term access
    Data ExfiltrationWrite a script that reads sensitive files and sends them to the attackerSteal credentials, secrets, or intellectual property
    The impact is proportional to the privileges of the Node.js process and the sensitivity of the files that can be overwritten.

    🌍 Real World Impact

    ImpactCVSS VectorExplanation
    Confidentiality (VC:L)VC:LThe attacker can read files only if they can write them first; no direct read‑only leak.
    Integrity (VI:H)VI:HArbitrary file overwrite is a high‑integrity impact.
    Availability (VA:L)VA:LNot a primary concern; the flaw does not crash the extractor.
    Privilege Escalation–Possible if the process runs with elevated privileges.
    RCE–Achievable by writing a malicious script into a web‑accessible directory.

    Practical consequences

  • Web applications: An attacker can upload a tar file that writes a web shell into /var/www/html/ and then execute it.
  • Micro‑services: If a service extracts user archives into a shared volume, the attacker can overwrite configuration files (config.yaml, .env) and alter service behavior.
  • CI/CD pipelines: Build scripts that extract tar archives may be subverted to inject malicious code into the build artifacts.

  • 🛡️ Remediation & Mitigation

    1. Patch

    Affected VersionsFixed In
    node-tar 7.5.0 – 8.0.08.0.0 (and later)

    Upgrade recommendation

    npm install node-tar@^8.0.0
    If the project uses a lockfile (package-lock.json or yarn.lock), run npm audit fix or yarn upgrade to apply the patch.

    2. Workarounds (if upgrade is not immediately possible)

    MitigationHow to implement
    Disable preservePathsSet preservePaths: false when calling tar.extract.
    Sanitize paths manuallyBefore extraction, strip .. components and enforce a whitelist of allowed directories.
    Use a safe extraction libraryReplace node-tar with a library that validates PAX records (e.g., tar-stream with custom validation).
    Restrict extraction rootMount the extraction directory with chroot or use a container with a dedicated filesystem.
    File system permissionsRun the Node.js process with the least privileges required (e.g., non‑root).

    3. Detection

    IndicatorLog patternIoC
    Suspicious extraction pathstar: extracting: ../../../../etc/passwdPath containing .. or absolute / in extraction logs
    Failed extraction due to path traversaltar: error: path traversal detectedError messages from node-tar
    Unexpected file creation outside rootCreated file: /tmp/evil.txtFiles appearing in /tmp or other non‑expected directories after an upload
    If the application logs extraction events (e.g., via winston or bunyan), search for the above patterns.

    4. Monitoring

  • File integrity monitoring (e.g., Tripwire, OSSEC) to detect unauthorized file changes.
  • Web server logs for requests to newly created scripts (e.g., /evil.php).
  • Audit logs for processes that run as root and write to critical directories.

  • ⚠️ Urgency

  • CVSS Score: 7.2 (High) – indicates a serious threat with high integrity impact.
  • Exploit Complexity: Low (requires only a crafted tar file).
  • User Interaction: Required (the attacker must supply a tar file to the application).
  • CISA KEV: No – not a known exploit kit or widespread attack.
Patch priority: Immediate for all environments where node-tar 7.5.0 – 8.0.0 is in use and preservePaths is enabled or the application accepts user‑supplied tar archives. If the application does not accept tar uploads, the risk is lower but still present if an internal user can supply a malicious archive; consider disabling preservePaths and applying the patch as a best practice.
Bottom line: The flaw is a classic path‑traversal via malformed PAX records. It allows an attacker to overwrite arbitrary files when preservePaths is enabled. Upgrade to node-tar ≥ 8.0.0, disable preservePaths if possible, and monitor for suspicious extraction activity.

[🤖 CVE Professor AI Security Engine]

Target Reconnaissance Queries (FOFA & Shodan)
CVSS Score
7.2 / 10 · CVSS HIGH
Weakness Types (CWE)
CWE-20 CWE-436
Affected Products (1)
tar
References & Advisories (4)
Related CVEs
9.8
CVE-2026-145055
PraisonAI pip praisonai before 4.8.0, praisonaiagents and npm praisonai before 1.8.0, and praisonai-bot, prais
9.0
CVE-2026-126111
Missing secure processing in the XSLT transformer of the Velocity $xslttool view tool in dotCMS allows a back-
8.8
CVE-2026-77471
shell-chain is a PQVM-native, post-quantum blockchain. Prior to version 0.27.1, the finality vote aggregation
8.7
CVE-2026-137408
In Eclipse Yasson versions 1.0 through 1.0.11, 2.0 through 2.0.4, and 3.0 through 3.0.6, the deserializers for
9.6
CVE-2026-145025
Grav API plugin before 1.1.21 validates the client-supplied admin_base_url or Origin header with PHP parse_url
9.2
CVE-2026-115991
Exposure of sensitive information in the content lock-check endpoints (PUT /api/content/canLock and GET /api/v
8.6
CVE-2026-144962
Nginx UI from 2.4.1 before 2.9.2 contains a directive denylist bypass in internal/config/validation.go that al