CVE-2026-140239: CVE-2026-140239: Global Extended Header linkpath Injection in node-tar
CVE-2026-140239: Global Extended Header linkpath Injection in node-tar Vulnerability ID: CVE-2026-140239 CVSS Score: 7.2 Published: 2026-12-02 CVE-2026-140239 (GHSA-ffhw-4r4q-5cwv) is an improper input validation vu
CVE-2026-140239: Global Extended Header linkpath Injection in node-tar
Vulnerability ID: CVE-2026-140239
CVSS Score: 7.2
Published: 2026-12-02
CVE-2026-140239 (GHSA-ffhw-4r4q-5cwv) is an improper input validation vulnerability in the node-tar npm package prior to version 8.0.0. An inconsistency between the Header and ReadEntry parsing classes allows an attacker to inject an arbitrary linkpath attribute into all subsequent archive entries via a PAX Global Extended Header (type 'g'). Because the Header class ignores the global linkpath while ReadEntry applies it, the parser's strict-mode integrity validation is bypassed, enabling downstream applications that inspect entry.linkpath to be manipulated into arbitrary file read or write operations outside the extraction directory.
TL;DR
A parsing differential between Header and ReadEntry in node-tar (< 8.0.0) allows PAX Global Extended Headers to inject an unvalidated linkpath attribute into every subsequent archive entry, bypassing strict-mode checks and enabling path traversal or arbitrary file overwrite in downstream consumers of tar.Parser and tar.list().
⚠️ Exploit Status: POC
Technical Details
- Vulnerability ID: CVE-2026-140239 / GHSA-ffhw-4r4q-5cwv
- Affected Component: node-tar (tar on npm) < 8.0.0
- Weakness Class: CWE-20 (Improper Input Validation) / CWE-345 (Insufficient Verification of Data Authenticity)
- CVSS v4.0 Score: 7.2 High (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 (Crafted TAR archive with PAX Global Extended Header type 'g')
- Impact: Strict-mode validation bypass and arbitrary linkpath injection on ReadEntry objects, leading to arbitrary file read/write in downstream consumers
- Exploit Status: Proof-of-Concept available (regression test in test/parse-differential.test.ts)
- CISA KEV Status: Not Listed
Affected Systems
- node-tar (tar npm package)
-
tar (node-tar): < 8.0.0 (Fixed in:
8.0.0)
Code Analysis
Commit: f351e5b
parse: read archives in the same way as other tar programs
--- a/src/read-entry.ts
+++ b/src/read-entry.ts
@@ -96,11 +96,15 @@ export class ReadEntry extends Minipass<Buffer, Buffer> {
this.uname = header.uname
this.gname = header.gname
- if (ex) {
- this.#slurp(ex)
- }
- if (gex) {
- this.#slurp(gex, true)
+ // Pending extended headers describe the next file entry, not a
+ // meta entry. Apply global first, so that local values win.
+ if (!this.meta) {
+ if (gex) {
+ this.#slurp(gex, true)
+ }
+ if (ex) {
+ this.#slurp(ex)
+ }
}
}
@@ -136,7 +140,15 @@ export class ReadEntry extends Minipass<Buffer, Buffer> {
// we slurp in everything except for the path attribute in
// a global extended header, because that's weird. Also, any
// null/undefined values are ignored.
- return !(v === null || v === undefined || (k === 'path' && gex))
+ // The Header already resolved size. It sets the body length.
+ return !(
+ v === null ||
+ v === undefined ||
+ k === 'size' ||
+ k === 'global' ||
+ (k === 'path' && gex) ||
+ (k === 'linkpath' && gex)
+ )
}),
),
)
Mitigation Strategies
- Upgrade the npm 'tar' dependency to version 8.0.0 or later to ensure PAX Global Extended Headers cannot inject or override linkpath attributes.
- Enforce strict entry type validation in downstream tar.Parser and tar.list() consumers so that entry.linkpath is only read when entry.type is explicitly 'SymbolicLink' or 'Link'.
- Sanitize and resolve all entry.linkpath values against the extraction root directory to prevent relative path traversal sequences ('..') from escaping the target directory.
- Reject or strip PAX GlobalExtendedHeader (type 'g') entries during stream parsing if global PAX metadata is not required by the application.
Remediation Steps:
- Audit package.json and package-lock.json across all Node.js projects to identify direct or transitive dependencies on 'tar' versions prior to 8.0.0.
- Verify that the target deployment environment runs a compatible Node.js runtime (Node.js >= 22 is required for tar 8.0.0).
- Run 'npm install tar@^8.0.0' and update any legacy stream or callback imports to match the v8.0.0 Web Streams API and 'tar/node' subpath exports.
- If remaining on tar 6.x or 7.x temporarily, add an entry sanitizer in the 'onReadEntry' or 'entry' event handler that sets 'entry.linkpath = undefined' whenever 'entry.type !== "SymbolicLink" && entry.type !== "Link"', and rejects archives containing 'GlobalExtendedHeader' entries.
References
- NVD - CVE-2026-140239 Detail
- CVE.org Record - CVE-2026-140239
- GitHub Security Advisory GHSA-ffhw-4r4q-5cwv
- Fix Commit f351e5b4a8916bc8c8f821d0ad926a17d26ea237 in isaacs/node-tar
- node-tar v8.0.0 Release
- CVEListV5 JSON Record for CVE-2026-140239
Read the full report for CVE-2026-140239 on our website for more details including interactive diagrams and full exploit analysis.
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.