CVE-2026-140252: Tar Node-tar UnpackSync Never Completes Sync-stream Vulnerability

HIGH
Advisory Identifier: GHSA-25mm-r35j-6hgm
CWE-667 CWE-696 CWE-911
Published
Advisory Summary

CVE-2026-140252 is a HIGH node-tar unpacksync never completes sync-stream vulnerability (CWE-667: Improper Locking) affecting Tar libraries in the npm ecosystem. The issue involves node-tar unpacksync never completes sync-stream extraction after any failing entry (pend/unpend imbalance). Remediation is available by upgrading affected packages to version 8.0.0.

CVE-2026-140252 at a Glance

CVE Identifier CVE-2026-140252
GHSA Identifier GHSA-25mm-r35j-6hgm
Severity HIGH
CVSS v3.1 Base Score N/A
CWE Classification CWE-667: Improper Locking
Affected Product Tar
Package Ecosystem npm
Published Date
Last Updated

How to Fix CVE-2026-140252

To remediate this vulnerability, upgrade all affected Tar dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

tar fixed: 8.0.0
npm install tar@8.0.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls tar

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2026-140252, inspect your project dependencies using npm:

npm ls tar

Analyze the terminal output to locate any version of Tar in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 8.0.0), your application is affected.

Note: The npm ls tar command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-667: Improper Locking, where the product does not properly acquire or release a lock on a resource, leading to unexpected resource state changes and behaviors. In Tar, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary When node-tar's synchronous stream extraction (`tar.x({ sync: true })` without the `file` option, or a directly-constructed `UnpackSync` stream) processes any archive entry that fails, the stream never emits `end`, `finish`, or `close`. A single failing entry, for example a hardlink whose target does not exist (one 512-byte entry), emits a `TAR_ENTRY_ERROR` warning and then hangs the stream. Consumers that await stream completion hang indefinitely on hostile or merely damaged input, with no error to catch because the warning is non-fatal by design. ### Details `Unpack` (async) brackets each entry's filesystem work with `[PEND]()` / `[UNPEND]()` to hold the stream open until every entry settles; `[MAYBECLOSE]` emits completion only when `PENDING === 0`: ```ts // src/unpack.ts:244-246 [MAYBECLOSE]() { if (this[ENDED] && this[PENDING] === 0) { /* emit prefinish/finish/end */ } } // src/unpack.ts:436-447 (inherited by UnpackSync) [ONERROR](er, entry) { if (er.name === 'CwdError') this.emit('error', er) else { this.warn('TAR_ENTRY_ERROR', er, { entry }); this[UNPEND](); entry.resume() } // PENDING-- } // src/unpack.ts:728-729 async CHECKFS pends... [CHECKFS](entry) { this[PEND](); ... } ``` `UnpackSync[CHECKFS]` (src/unpack.ts:901) performs the same work but never calls `[PEND]()`, yet `UnpackSync` does not override `[ONERROR]`, so it inherits the async handler that unconditionally calls `[UNPEND]()` on any non-`CwdError` entry failure. A single failing entry therefore drives `PENDING` to `-1`. Because `[MAYBECLOSE]` requires exactly `0`, the negative counter permanently suppresses `end` / `finish` / `close`. (A separate fall-through in the same method, a missing `return` after the `rmdir` branch at src/unpack.ts:953-954, double-invokes `MAKEFS` on a directory-replacement entry, producing two warnings and `PENDING = -2`.) ### PoC Validated on source main @ 2a22bfc and against the published npm package `tar@7.5.22`, Node v24.19.0. ```js // npm i tar@7.5.22 ; node poc.cjs const { Header, x } = require('tar'); const fs = require('fs') const dir = '/tmp/sync-hang'; fs.rmSync(dir,{recursive:true,force:true}); fs.mkdirSync(dir,{recursive:true}) const b = Buffer.alloc(512) new Header({ path:'ln', type:'Link', linkpath:'nonexistent', size:0, mode:0o644 }).encode(b,0) const u = x({ sync: true, cwd: dir }) // the UnpackSync stream let ended = false; const warns = [] u.on('end', ()=>ended=true); u.on('finish', ()=>ended=true); u.on('warn', c=>warns.push(c)) u.end(Buffer.concat([b, Buffer.alloc(1024)])) setTimeout(()=>{ console.log(ended ? 'ENDED' : '*** HANG: end/finish never emitted', 'warnings=', warns); process.exit(0) }, 1500) ``` Observed: ``` *** HANG: end/finish never emitted warnings= [ 'TAR_ENTRY_ERROR' ] ``` Controls in the same harness: the identical archive through the async file API (`x({ cwd, file })`) resolves with a single `TAR_ENTRY_ERROR`; an all-success archive through the sync-stream API ends normally and extracts its file. Disk state is fail-closed (the failing entry is simply not created). ### Impact Availability denial of service (permanent stream hang after a warning). No confidentiality or integrity effect and no incorrect data is written. The affected surface is narrow: only consumers that pipe into `new UnpackSync()` or the stream returned by `x({ sync: true })` (without `file`) and await `end` / `finish` / `close`. The default asynchronous API and the common file-based synchronous API (`x({ sync: true, file })`, which returns void) are unaffected. A single 512-byte crafted or damaged entry is enough to wedge an affected consumer.

CVE-2026-140252 Affected Tar Versions

1 component(s)
Fixed Versions:
8.0.0
Product / Package Ecosystem Affected Versions Fixed Version
tar
npm
≥ 7.5.22
< 8.0.0
8.0.0

References

Frequently Asked Questions

What is CVE-2026-140252?
CVE-2026-140252 is a security vulnerability in Tar involving node-tar UnpackSync never completes sync-stream extraction after any failing entry (PEND/UNPEND imbalance) under CWE-667: Improper Locking.
Which Tar versions are affected?
Affected versions include releases prior to 8.0.0 across affected packages: tar.
What version fixes CVE-2026-140252?
Upgrading to 8.0.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is tar affected?
Yes, tar is affected in releases prior to 8.0.0. Upgrade your dependency to 8.0.0 or later.
What CWE is associated with CVE-2026-140252?
CVE-2026-140252 is classified under CWE-667: Improper Locking (The product does not properly acquire or release a lock on a resource, leading to unexpected resource state changes and behaviors.).
How can I check npm dependencies for CVE-2026-140252?
Run the dependency tree command: 'npm ls tar'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-25mm-r35j-6hgm",
  "modified" : "2026-12-01T19:27:34Z",
  "published" : "2026-12-01T19:27:34Z",
  "aliases" : [ "CVE-2026-140252" ],
  "summary" : "node-tar UnpackSync never completes sync-stream extraction after any failing entry (PEND/UNPEND imbalance)",
  "details" : "### Summary\nWhen node-tar's synchronous stream extraction (`tar.x({ sync: true })` without the `file` option, or a directly-constructed `UnpackSync` stream) processes any archive entry that fails, the stream never emits `end`, `finish`, or `close`. A single failing entry, for example a hardlink whose target does not exist (one 512-byte entry), emits a `TAR_ENTRY_ERROR` warning and then hangs the stream. Consumers that await stream completion hang indefinitely on hostile or merely damaged input, with no error to catch because the warning is non-fatal by design.\n\n### Details\n`Unpack` (async) brackets each entry's filesystem work with `[PEND]()` / `[UNPEND]()` to hold the stream open until every entry settles; `[MAYBECLOSE]` emits completion only when `PENDING === 0`:\n\n```ts\n// src/unpack.ts:244-246\n[MAYBECLOSE]() { if (this[ENDED] && this[PENDING] === 0) { /* emit prefinish/finish/end */ } }\n// src/unpack.ts:436-447  (inherited by UnpackSync)\n[ONERROR](er, entry) {\n  if (er.name === 'CwdError') this.emit('error', er)\n  else { this.warn('TAR_ENTRY_ERROR', er, { entry }); this[UNPEND](); entry.resume() }   // PENDING--\n}\n// src/unpack.ts:728-729  async CHECKFS pends...\n[CHECKFS](entry) { this[PEND](); ... }\n```\n\n`UnpackSync[CHECKFS]` (src/unpack.ts:901) performs the same work but never calls `[PEND]()`, yet `UnpackSync` does not override `[ONERROR]`, so it inherits the async handler that unconditionally calls `[UNPEND]()` on any non-`CwdError` entry failure. A single failing entry therefore drives `PENDING` to `-1`. Because `[MAYBECLOSE]` requires exactly `0`, the negative counter permanently suppresses `end` / `finish` / `close`. (A separate fall-through in the same method, a missing `return` after the `rmdir` branch at src/unpack.ts:953-954, double-invokes `MAKEFS` on a directory-replacement entry, producing two warnings and `PENDING = -2`.)\n\n### PoC\nValidated on source main @ 2a22bfc and against the published npm package `tar@7.5.22`, Node v24.19.0.\n\n```js\n// npm i tar@7.5.22 ; node poc.cjs\nconst { Header, x } = require('tar'); const fs = require('fs')\nconst dir = '/tmp/sync-hang'; fs.rmSync(dir,{recursive:true,force:true}); fs.mkdirSync(dir,{recursive:true})\nconst b = Buffer.alloc(512)\nnew Header({ path:'ln', type:'Link', linkpath:'nonexistent', size:0, mode:0o644 }).encode(b,0)\nconst u = x({ sync: true, cwd: dir })          // the UnpackSync stream\nlet ended = false; const warns = []\nu.on('end', ()=>ended=true); u.on('finish', ()=>ended=true); u.on('warn', c=>warns.push(c))\nu.end(Buffer.concat([b, Buffer.alloc(1024)]))\nsetTimeout(()=>{ console.log(ended ? 'ENDED' : '*** HANG: end/finish never emitted', 'warnings=', warns); process.exit(0) }, 1500)\n```\n\nObserved:\n```\n*** HANG: end/finish never emitted   warnings= [ 'TAR_ENTRY_ERROR' ]\n```\nControls in the same harness: the identical archive through the async file API (`x({ cwd, file })`) resolves with a single `TAR_ENTRY_ERROR`; an all-success archive through the sync-stream API ends normally and extracts its file. Disk state is fail-closed (the failing entry is simply not created).\n\n### Impact\nAvailability denial of service (permanent stream hang after a warning). No confidentiality or integrity effect and no incorrect data is written. The affected surface is narrow: only consumers that pipe into `new UnpackSync()` or the stream returned by `x({ sync: true })` (without `file`) and await `end` / `finish` / `close`. The default asynchronous API and the common file-based synchronous API (`x({ sync: true, file })`, which returns void) are unaffected. A single 512-byte crafted or damaged entry is enough to wedge an affected consumer.",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "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"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "tar"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "7.5.22"
      }, {
        "fixed" : "8.0.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/isaacs/node-tar/security/advisories/GHSA-25mm-r35j-6hgm"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/isaacs/node-tar/commit/73b352e0010d6c99794ea7374800816a46d3bdb2"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/isaacs/node-tar"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/isaacs/node-tar/releases/tag/v8.0.0"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-667", "CWE-696", "CWE-911" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-12-01T19:27:34Z",
    "nvd_published_at" : null
  }
}