Dev.to Security 🔐 Cybersecurity 👁 0 📖 3 min read

CVE-2026-140234: CVE-2026-140234: Null Byte Truncation Bypass in node-tar Leading to Denial of Service and Path Differential

CVE-2026-140234: Null Byte Truncation Bypass in node-tar Leading to Denial of Service and Path Differential Vulnerability ID: CVE-2026-140234 CVSS Score: 7.1 Published: 2026-12-02 CVE-2026-140234 (GHSA-wpwg-r92p-fjj

CVE-2026-140234: Null Byte Truncation Bypass in node-tar Leading to Denial of Service and Path Differential

Vulnerability ID: CVE-2026-140234
CVSS Score: 7.1
Published: 2026-12-02

CVE-2026-140234 (GHSA-wpwg-r92p-fjjh) is an improper null byte neutralization vulnerability (CWE-158) in node-tar versions prior to 8.0.0. The regular expression used to truncate null-terminated header strings omits the dotAll (s) flag, causing truncation to halt prematurely when a null byte is followed by a line terminator. This defect allows embedded null bytes and trailing characters to persist in parsed file and link paths, resulting in asynchronous Node.js process crashes via native filesystem validation errors and path differentials against compliant TAR implementations.

TL;DR

In node-tar prior to version 8.0.0, the regular expression /\0.*/ fails to strip characters after a line break in null-terminated TAR header strings. Processing an archive with a null byte followed by a newline causes embedded null bytes to reach Node.js fs bindings, triggering an unhandled ERR_INVALID_ARG_VALUE exception and crashing the runtime process, or causing path resolution differentials.

⚠️ Exploit Status: POC

Technical Details

  • CVE / GHSA ID: CVE-2026-140234 / GHSA-wpwg-r92p-fjjh
  • Weakness Class: CWE-158: Improper Neutralization of Null Byte or NUL Character
  • CVSS v4.0 Score: 7.1 High (CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:N/VI:L/VA:H/SC:N/SI:N/SA:N)
  • Affected Package: tar (node-tar) < 8.0.0
  • Patched Version: tar >= 8.0.0
  • Primary Impact: Denial of Service (Unhandled ERR_INVALID_ARG_VALUE Crash) & Path Differential
  • Exploit Status: Proof-of-Concept Available
  • CISA KEV Status: Not Listed

Affected Systems

  • node-tar (npm package: tar) < 8.0.0
  • tar (node-tar): < 8.0.0 (<= 7.5.24) (Fixed in: 8.0.0)

Code Analysis

Commit: f351e5b

parse: read archives in the same way as other tar programs

diff --git a/src/header.ts b/src/header.ts
index 858a9838..6bdcdac5 100644
--- a/src/header.ts
+++ b/src/header.ts
@@ -351,7 +351,7 @@ const decString = (buf: Buffer, off: number, size: number) =>
   buf
     .subarray(off, off + size)
     .toString('utf8')
-    .replace(/\0.*/, '')
+    .replace(/\0.*/s, '')

 const decDate = (buf: Buffer, off: number, size: number) =>
   numToDate(decNumber(buf, off, size))
diff --git a/src/parse.ts b/src/parse.ts
index bc775a4f..bca52392 100644
--- a/src/parse.ts
+++ b/src/parse.ts
@@ -387,14 +393,14 @@ export class Parser extends EE implements Warner {
       case 'OldGnuLongPath': {
         const ex: Pax = this[EX] ?? Object.create(null)
         this[EX] = ex
-        ex.path = this[META].replace(/\0.*/, '')
+        ex.path ??= this[META].replace(/\0.*/s, '')
         break
       }

       case 'NextFileHasLongLinkpath': {
         const ex: Pax = this[EX] || Object.create(null)
         this[EX] = ex
-        ex.linkpath = this[META].replace(/\0.*/, '')
+        ex.linkpath ??= this[META].replace(/\0.*/s, '')
         break
       }
diff --git a/src/pax.ts b/src/pax.ts
index d528ae77..e8dd0920 100644
--- a/src/pax.ts
+++ b/src/pax.ts
@@ -176,7 +187,7 @@ const parseKVLine = (

   const k = r.replace(/^SCHILY\.(dev|ino|nlink)/, '$1')

-  const v = kv.join('=').replace(/\0.*/, '')
+  const v = kv.join('=').replace(/\0.*/s, '')
   switch (k) {
     case 'path':
     case 'linkpath':

Mitigation Strategies

  • Upgrade the npm 'tar' dependency to version 8.0.0 or higher, which truncates header strings at the first raw 0x00 byte prior to UTF-8 decoding.
  • Implement strict entry filtering using the 'filter' and 'onReadEntry' options in node-tar to block paths or link targets containing null bytes or line terminators (\0, \n, \r, \u2028, \u2029).
  • Attach comprehensive error handlers to all asynchronous extraction streams and Promise chains to prevent unhandled exceptions from terminating the Node.js event loop.

Remediation Steps:

  1. Audit project dependency trees using 'npm ls tar' to identify direct and transitive dependencies on node-tar versions below 8.0.0.
  2. Update package.json to require 'tar': '^8.0.0' (ensuring the host runtime meets the Node.js >= 22 requirement for v8.0.0) and regenerate lockfiles.
  3. If locked to node-tar 7.x or earlier due to Node.js runtime constraints, deploy an extraction wrapper that validates 'entry.path' and 'entry.linkpath' against /[\0\r\n\u2028\u2029]/ prior to filesystem writes.
  4. Verify the remediation using unit tests containing ustar, GNU long path, and PAX headers with 'a\0b\nc\0d' filename sequences.

References

Read the full report for CVE-2026-140234 on our website for more details including interactive diagrams and full exploit analysis.

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.