GHSA-25MM-R35J-6HGM

Vulnerability from github – Published: 2026-12-01 19:27 – Updated: 2026-12-01 19:27
VLAI
Summary
node-tar UnpackSync never completes sync-stream extraction after any failing entry (PEND/UNPEND imbalance)
Details

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:

// 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.

// 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.

Show details on source website

{
  "affected": [
    {
      "package": {
        "ecosystem": "npm",
        "name": "tar"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "7.5.22"
            },
            {
              "fixed": "8.0.0"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2026-140252"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-667",
      "CWE-696",
      "CWE-911"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2026-12-01T19:27:34Z",
    "nvd_published_at": null,
    "severity": "HIGH"
  },
  "details": "### Summary\nWhen node-tar\u0027s 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\u0027s 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] \u0026\u0026 this[PENDING] === 0) { /* emit prefinish/finish/end */ } }\n// src/unpack.ts:436-447  (inherited by UnpackSync)\n[ONERROR](er, entry) {\n  if (er.name === \u0027CwdError\u0027) this.emit(\u0027error\u0027, er)\n  else { this.warn(\u0027TAR_ENTRY_ERROR\u0027, 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(\u0027tar\u0027); const fs = require(\u0027fs\u0027)\nconst dir = \u0027/tmp/sync-hang\u0027; fs.rmSync(dir,{recursive:true,force:true}); fs.mkdirSync(dir,{recursive:true})\nconst b = Buffer.alloc(512)\nnew Header({ path:\u0027ln\u0027, type:\u0027Link\u0027, linkpath:\u0027nonexistent\u0027, size:0, mode:0o644 }).encode(b,0)\nconst u = x({ sync: true, cwd: dir })          // the UnpackSync stream\nlet ended = false; const warns = []\nu.on(\u0027end\u0027, ()=\u003eended=true); u.on(\u0027finish\u0027, ()=\u003eended=true); u.on(\u0027warn\u0027, c=\u003ewarns.push(c))\nu.end(Buffer.concat([b, Buffer.alloc(1024)]))\nsetTimeout(()=\u003e{ console.log(ended ? \u0027ENDED\u0027 : \u0027*** HANG: end/finish never emitted\u0027, \u0027warnings=\u0027, warns); process.exit(0) }, 1500)\n```\n\nObserved:\n```\n*** HANG: end/finish never emitted   warnings= [ \u0027TAR_ENTRY_ERROR\u0027 ]\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.",
  "id": "GHSA-25mm-r35j-6hgm",
  "modified": "2026-12-01T19:27:34Z",
  "published": "2026-12-01T19:27:34Z",
  "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"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "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",
      "type": "CVSS_V4"
    }
  ],
  "summary": "node-tar UnpackSync never completes sync-stream extraction after any failing entry (PEND/UNPEND imbalance)"
}



Log in or create an account to share your comment.




Tags
Taxonomy of the tags.


Loading…

Loading…

Loading…

Drag nodes to arrange them. Double-click a related vulnerability to open it, or a source to visit its link. The Physics button on the left tunes the layout and the simulation; the legend at the bottom left hides or shows nodes by kind and by sighting type.

Forecast uses a logistic model when the trend is rising, or an exponential decay model when the trend is falling. Fitted via linearized least squares.

Sightings

Author Source Type Date Other

Nomenclature

  • Seen: The vulnerability was mentioned, discussed, or observed by the user.
  • Confirmed: The vulnerability has been validated from an analyst's perspective.
  • Published Proof of Concept: A public proof of concept is available for this vulnerability.
  • Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
  • Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
  • Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
  • Not confirmed: The user expressed doubt about the validity of the vulnerability.
  • Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.
Vulnerability timeline

Sightings and recorded dates, grouped by day · UTC

JSON
How durations are calculated

Following the VTEM framework (Black Hat USA 2015), time to patch starts when the vendor or a coordinator was informed, total time to patch at discovery, and disclosure to patch at public disclosure; vendor response time runs from the report to its acknowledgement. Time to exploit and time unpatched start at the earliest discovery or report, falling back to public disclosure. Unpatched time ends at the first recorded patch, or the calculation time when no patch is recorded. Exploitation to patch shows the interval between those two events; a published proof of concept is a public exploit, not exploitation. The method is described in a publication.

Each result shows its source dates. A negative interval means the end event came first; when date-only inputs leave the order open, the result says so. Date-only inputs are approximate. The earliest evidence wins: KEV report dates and sightings are labelled as such. Records describing another vulnerability are listed but never calculated from, and a PoC alone does not establish exploitation. Missing patch evidence does not prove that no patch exists. Filters below change the event list only.

Events included in the timeline

Loading timeline…


    Loading…

    Loading…

    Loading…

    Related by attack behaviour

    Vulnerabilities whose description is nearest to this one in the vector space of the CIRCL/vulnerability-attack-technique-biencoder model. This is a similarity search over the bi-encoder space (plain cosine), not a classification, and it has no measured accuracy.