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

CVE-2026-140241: CVE-2026-140241: Uncaught Exception Denial of Service in node-tar via Zstandard Magic Header

CVE-2026-140241: Uncaught Exception Denial of Service in node-tar via Zstandard Magic Header Vulnerability ID: CVE-2026-140241 CVSS Score: 7.1 Published: 2026-12-02 CVE-2026-140241 is a Denial of Service (DoS) vulne

CVE-2026-140241: Uncaught Exception Denial of Service in node-tar via Zstandard Magic Header

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

CVE-2026-140241 is a Denial of Service (DoS) vulnerability in the node-tar archive manipulation library (npm package: tar) affecting versions 7.5.22 through 7.5.24. The defect stems from an uncaught synchronous exception thrown during the initialization of Zstandard (zstd) decompression on Node.js runtimes that lack native zstd bindings. An unauthenticated attacker can supply a 4-byte payload containing the zstd magic header (0x28 0xb5 0x2f 0xfd) to asynchronous listing or extraction APIs, causing the error to escape stream event handlers and terminate the Node.js process.

TL;DR

An uncaught synchronous TypeError during Zstandard decompressor instantiation in node-tar (versions 7.5.22 to 7.5.24) allows unauthenticated attackers to crash the Node.js process using a 4-byte file containing the zstd magic header on runtimes without native zstd support.

⚠️ Exploit Status: POC

Technical Details

  • CVE / Advisory ID: CVE-2026-140241 / GHSA-72fp-85cc-g945
  • Primary CWE: CWE-248 (Uncaught Exception) / CWE-755
  • CVSS v4.0 Score: 7.1 High (CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N)
  • Attack Vector: Network (4-byte Zstandard magic header 0x28 0xb5 0x2f 0xfd)
  • Affected Versions: tar >= 7.5.22, < 8.0.0 (7.5.22, 7.5.23, 7.5.24)
  • Patched Version: tar 8.0.0
  • Impact: Immediate Node.js process crash (Denial of Service)
  • CISA KEV Status: Not Listed

Affected Systems

  • node-tar (npm package: tar) >= 7.5.22, < 8.0.0
  • tar (node-tar): >= 7.5.22, < 8.0.0 (Fixed in: 8.0.0)

Code Analysis

Commit: 73b352e

Wrap decompressor instantiation in src/parse.ts within a try...catch block and call this.abort(er) to prevent uncaught synchronous exceptions on runtimes without native zstd support.

--- a/src/parse.ts
+++ b/src/parse.ts
@@ -544,10 +544,17 @@ export class Parser extends EE implements Warner {
       ) {
         const ended = this[ENDED]
         this[ENDED] = false
-        this[UNZIP] =
-          this[UNZIP] === undefined ? new Unzip({})
-          : isZstd ? new ZstdDecompress({})
-          : new BrotliDecompress({})
+        try {
+          this[UNZIP] =
+            this[UNZIP] === undefined ? new Unzip({})
+            : isZstd ? new ZstdDecompress({})
+            : new BrotliDecompress({})
+        } catch (er) {
+          // For example, zstd on a Node.js version that does not have it.
+          this.abort(er as Error)
+          cb?.()
+          return false
+        }
         this[UNZIP].on('data', chunk => {
           if (this[CHECKDECOMPRESSIONRATIO](chunk)) {
             this[CONSUMECHUNK](chunk)

Mitigation Strategies

  • Upgrade the node-tar (npm: tar) dependency to version 8.0.0 or higher.
  • Ensure the host Node.js runtime version includes native Zstandard (zstd) bindings in the built-in zlib module so minizlib does not throw an unsupported compression method TypeError.
  • Pre-validate incoming files and byte streams at the application boundary to reject inputs starting with the 4-byte Zstandard magic header (0x28 0xb5 0x2f 0xfd) prior to passing them to node-tar.

Remediation Steps:

  1. Audit project dependencies using 'npm ls tar' to identify any direct or transitive installations of tar versions 7.5.22, 7.5.23, or 7.5.24.
  2. Update package.json to require 'tar': '^8.0.0' and run 'npm install tar@^8.0.0' (requires Node.js >= 22).
  3. If migrating to v8.0.0, update any synchronous Node.js-specific API imports to use the 'tar/node' entrypoint.
  4. If constrained to tar 7.x on an older Node.js runtime, implement a pre-processing check to inspect the first 4 bytes of untrusted files and reject files matching 0x28 0xb5 0x2f 0xfd.

References

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