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

CVE-2026-140242: CVE-2026-140242: Improper Input Validation in node-tar PAX Header Parser Causes Entry Loss and Denial of…

CVE-2026-140242: Improper Input Validation in node-tar PAX Header Parser Causes Entry Loss and Denial of Service Vulnerability ID: CVE-2026-140242 CVSS Score: 7.1 Published: 2026-12-02 CVE-2026-140242 (also tracked

CVE-2026-140242: Improper Input Validation in node-tar PAX Header Parser Causes Entry Loss and Denial of Service

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

CVE-2026-140242 (also tracked as GHSA-ph3c-p786-j4rp) is an input validation vulnerability (CWE-1284) in the node-tar package for Node.js, affecting versions >= 7.0.0 and < 7.5.24. The parser for POSIX.1-2001 Extended (PAX) header records fails to verify that the parsed value of the size attribute is a finite, safe integer. Supplying a PAX header record with a size value such as Infinity bypasses simple non-negative numerical checks via JavaScript unary coercion. This results in stream boundary corruption and entry loss during archive extraction, or an uncaught runtime exception and process termination when re-packing the archive.

TL;DR

An improper input validation flaw in node-tar versions 7.0.0 through 7.5.23 allows attackers to set an entry size to Infinity via crafted PAX extended headers. This causes archive extraction pipelines to drop subsequent file entries and triggers an uncaught exception that crashes the Node.js process during re-packing operations. Upgrade to version 7.5.24 to remediate the issue.

⚠️ Exploit Status: POC

Technical Details

  • CVE / GHSA ID: CVE-2026-140242 / GHSA-ph3c-p786-j4rp
  • Weakness Class: CWE-1284 (Improper Validation of Specified Quantity in Input)
  • 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) >= 7.0.0, < 7.5.24
  • Patched Version: 7.5.24
  • Primary Impact: Archive Entry Loss (Integrity) & Process Termination via Uncaught Exception (Availability)
  • Exploit Status: Proof-of-Concept (PoC in upstream test suite)
  • CISA KEV Status: Not Listed

Affected Systems

  • node-tar (npm package: tar) >= 7.0.0, < 7.5.24
  • tar (node-tar): >= 7.0.0, < 7.5.24 (Fixed in: 7.5.24)

Code Analysis

Commit: 6b815b7

reject PAX sizes that are not valid numbers

diff --git a/src/pax.ts b/src/pax.ts
index 8f2292a8..90700979 100644
--- a/src/pax.ts
+++ b/src/pax.ts
@@ -2,6 +2,8 @@ import { basename } from 'node:path'
 import type { HeaderData } from './header.js'
 import { Header } from './header.js'

+const SIMPLE_NUMBER = /^(?:0|[1-9]\d*)$/
+
 export class Pax implements HeaderData {
   atime?: Date
   mtime?: Date
@@ -193,8 +195,12 @@ const parseKVLine = (
       set[k] = new Date(Number(v) * 1000)
       break
     case 'size':
+      // value must be a string of digits with no negative sign
+      if (!SIMPLE_NUMBER.test(v.trim())) break
       const s = +v
-      if (s >= 0) set[k] = s
+      // must be a finite, non-negative integer, like the binary header path
+      if (!Number.isSafeInteger(s)) break
+      set[k] = s
       break
     case 'gid':
     case 'uid':

Exploit Details

  • GitHub: Official fix commit containing the unit test reproduction demonstrating PAX size=Infinity, size=1e400, and unsafe integer inputs.

Mitigation Strategies

  • Upgrade node-tar (tar) to version 7.5.24 or later across all direct and transitive dependencies.
  • Use package manager overrides (npm overrides, yarn resolutions) to force transitive dependencies on tar v7.x to resolve to >= 7.5.24.
  • Implement stream entry validation callbacks (filter or onReadEntry) to verify that entry.size passes Number.isSafeInteger() and adheres to application-specific size quotas before processing.
  • Isolate untrusted archive processing within dedicated worker threads or child processes to contain potential uncaught exceptions.

Remediation Steps:

  1. Run npm ls tar to identify all direct and transitive installations of the tar package within the project.
  2. Execute npm install tar@^7.5.24 or npm audit fix to update vulnerable versions (>= 7.0.0, < 7.5.24).
  3. If transitive dependencies lock tar to an older 7.x release, add "overrides": { "tar": "^7.5.24" } to package.json and regenerate package-lock.json.
  4. Verify the fix by re-running npm ls tar and confirming all resolved versions are 7.5.24 or higher (or remain on unaffected v6.x branches).

References

Read the full report for CVE-2026-140242 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.