Dec 1, 2026·11 min read·0 visits
An improper reference count decrement (CWE-911) in node-tar (versions >= 7.5.22, < 8.0.0) allows remote attackers to trigger an indefinite stream hang and application denial of service by supplying a crafted tar archive containing a broken link or skippable entry to an application performing synchronous stream extraction.
A high-severity denial-of-service vulnerability exists in node-tar versions 7.5.22 prior to 8.0.0 within the synchronous stream extraction implementation (UnpackSync). Due to an asymmetrical reference-counting design between the asynchronous base class Unpack and its synchronous subclass UnpackSync, handling any non-fatal entry error or skipped entry causes the internal pending operation counter to decrement below zero. Because the stream termination logic strictly checks for a counter value equal to zero, the extraction stream enters an unrecoverable state where lifecycle completion events (prefinish, finish, end) are never emitted, permanently blocking downstream stream consumers.
node-tar (tar on the npm registry) is the standard archive extraction and creation library for the Node.js ecosystem. It is widely deployed across package managers, build pipelines, container utilities, and server-side applications that process user-uploaded or network-delivered .tar and .tgz archives. The library provides both asynchronous and synchronous interfaces for reading, parsing, and writing tar archives.
In versions 7.5.22 through 7.5.24, node-tar exposes an availability flaw tracked as CVE-2026-140252 (and GHSA-25mm-r35j-6hgm) within its synchronous stream extraction component, UnpackSync. This class is instantiated directly via new tar.UnpackSync() or invoked through the high-level API tar.x({ sync: true }) when operating in stream mode (i.e., when no input file parameter is provided). The vulnerability is classified under CWE-911 (Improper Update of Reference Count), with secondary classifications under CWE-696 (Incorrect Behavior Order) and CWE-667 (Improper Locking).
When UnpackSync processes an archive containing any entry that triggers a recoverable, non-fatal warning or skip condition—such as a hard link referencing a non-existent target path (ENOENT) or an entry bypassed via extraction flags like keep: true—the internal pending operation counter ([PENDING]) is decremented without a corresponding prior increment. This drives the reference counter into a negative integer state (-1 or lower).
Because the stream completion state machine requires the [PENDING] counter to evaluate strictly to 0 (this[PENDING] === 0) after reaching end-of-file before emitting termination events (prefinish, finish, and end), the stream becomes permanently wedged. Any calling process, Promise wrapper, or stream pipeline waiting for the extraction stream to settle will hang indefinitely, resulting in a complete denial of service for the affected execution context.
To understand the root cause of CVE-2026-140252, it is necessary to examine the class hierarchy and stream lifecycle accounting model used in node-tar v7.x. The archive extraction logic is divided between the asynchronous base class Unpack (which extends Parser) and the synchronous subclass UnpackSync (which extends Unpack).
In the asynchronous Unpack class, filesystem mutations (such as creating directories, writing file streams, and establishing symbolic or hard links) occur asynchronously via node:fs callbacks. Because the underlying tar Parser may finish reading the archive buffer from memory or disk before all asynchronous filesystem operations have settled, Unpack implements a reference-counting mechanism using private Symbol properties: [PENDING], [PEND], [UNPEND], and [MAYBECLOSE]. When an archive entry is dispatched for filesystem checks in Unpack[CHECKFS](), the instance calls this[PEND](), which increments this[PENDING]++. When the asynchronous write or filesystem operation finishes, it calls this[UNPEND](), which decrements this[PENDING]-- and invokes this[MAYBECLOSE](). The [MAYBECLOSE]() method checks if (this[ENDED] && this[PENDING] === 0) before emitting the final stream lifecycle events (prefinish, finish, end).
The architectural flaw emerges in how UnpackSync overrides these lifecycle methods. Because UnpackSync executes all filesystem operations synchronously inside [CHECKFS]() (using fs.openSync, fs.writeSync, fs.linkSync, etc.), every filesystem operation completes before the function returns. Consequently, UnpackSync[CHECKFS]() never calls this[PEND](), leaving this[PENDING] initialized at 0 throughout normal execution.
However, UnpackSync fails to override either [ONERROR]() or [UNPEND](), inheriting both directly from the asynchronous Unpack base class. In Unpack, the [ONERROR](er, entry) handler is designed to catch non-fatal entry errors during asynchronous execution, emit a TAR_ENTRY_ERROR warning, and call this[UNPEND]() to account for the this[PEND]() call that occurred before the operation began. Similarly, certain early-exit paths where an entry is skipped invoke this[UNPEND](). When these code paths execute inside an UnpackSync instance, this[UNPEND]() decrements this[PENDING] from 0 to -1. Because UnpackSync never calls this[PEND](), the counter can never be incremented back to 0. Once the parser reaches the end of the archive and sets this[ENDED] = true, [MAYBECLOSE]() evaluates this[PENDING] === 0, which permanently evaluates to false.
In node-tar prior to the patch, the asynchronous base class Unpack defines the reference counting and error handling logic in src/unpack.ts. The relevant methods in the base Unpack class interact with this[PENDING] as follows:
// Simplified representation of base Unpack lifecycle management in src/unpack.ts
export class Unpack extends Parser {
[PENDING]: number = 0;
[ENDED]: boolean = false;
[PEND]() {
this[PENDING]++;
}
[UNPEND]() {
this[PENDING]--;
this[MAYBECLOSE]();
}
[MAYBECLOSE]() {
if (this[ENDED] && this[PENDING] === 0) {
this.emit('prefinish');
this.emit('finish');
this.emit('end');
}
}
[ONERROR](er: Error, entry: ReadEntry) {
if (er.name === 'CwdError') {
this.emit('error', er);
} else {
this.warn('TAR_ENTRY_ERROR', er, { entry });
// Base class assumes [PEND]() was called prior to the failing FS operation
this[UNPEND]();
entry.resume();
}
}
}When UnpackSync was implemented as a subclass of Unpack, it overrode [MAKEFS]() and [CHECKFS]() to run synchronously without calling this[PEND](), but left [UNPEND]() intact. Commit 73b352e0010d6c99794ea7374800816a46d3bdb2 resolves the vulnerability directly in src/unpack.ts by overriding [UNPEND]() on UnpackSync as a no-op method:
File: src/unpack.ts
@@ -903,6 +934,10 @@ const callSync = <T>(
export class UnpackSync extends Unpack {
sync: true = true;
+ // All work is done when the parser ends, so nothing is pending.
+ // This class never calls PEND, so UNPEND must not count.
+ [UNPEND]() {}
+
[MAKEFS](er: null | Error | undefined, entry: ReadEntry) {
return super[MAKEFS](er, entry, () => {})
}Along with the patch in src/unpack.ts, commit 73b352e0010d6c99794ea7374800816a46d3bdb2 adds two regression test cases in test/resource-limits.test.ts that verify stream termination under both failure and skip conditions:
test('the stream ends after an entry that fails', async () => {
const { cwd, warnings } = await unpack(
[
ent({ path: 'l', type: 'Link', linkpath: 'missing' }),
ent({ path: 'after.txt', type: 'File' }, 'ok'),
],
sync,
)
assert.equal(warnings.length, 1)
assert.equal(warnings[0]?.[0], 'TAR_ENTRY_ERROR')
assert.match(warnings[0]?.[1], /^ENOENT/)
assert.equal(
fs.readFileSync(resolve(cwd, 'after.txt'), 'utf8'),
'ok',
)
})
test('the stream ends after an entry that is skipped', async () => {
const cwd = testdir({ f: 'old' })
const { warnings } = await unpack(
[ent({ path: 'f', type: 'File' }, 'new')],
sync,
{ cwd, keep: true },
)
assert.deepEqual(warnings, [])
assert.equal(fs.readFileSync(resolve(cwd, 'f'), 'utf8'), 'old')
})The fix in commit 73b352e0010d6c99794ea7374800816a46d3bdb2 is complete for the UnpackSync class. Because UnpackSync performs all filesystem work synchronously inline before parser chunks return, there is never any asynchronous backlog after the parser finishes. Turning [UNPEND]() into a no-op guarantees that this[PENDING] remains invariant at 0, allowing [MAYBECLOSE]() to fire deterministically when the parser reaches EOF. Furthermore, in node-tar version 8.0.0, the maintainer introduced a comprehensive architectural rewrite (src/next/) that replaces the legacy Minipass and PEND/UNPEND reference-counting model with standard Web Streams (ReadableStream, TransformStream) and dedicated synchronous extraction APIs (extractSync in tar/node).
Exploiting CVE-2026-140252 requires no authentication or elevated privileges, only that the target application processes an untrusted tar archive using node-tar's synchronous stream extraction interface (new tar.UnpackSync() or tar.x({ sync: true }) without specifying the file option). An attacker can construct a minimal compliant tar archive containing a single entry that is guaranteed to trigger a non-fatal filesystem error or skip path during extraction.
Two distinct entry types reliably trigger the [UNPEND]() underflow:
type: 'Link'): Including a hard link entry whose linkpath points to a file that does not exist in the extraction target directory. When UnpackSync attempts to execute fs.linkSync(), the operating system returns ENOENT. By default (strict: false), node-tar treats ENOENT on an entry as a non-fatal warning, passing the error to [ONERROR](), which invokes this[UNPEND](). Note that the parser continues extracting subsequent entries in the archive, meaning file system writes still occur before the stream hangs at EOF.keep: true: If the target application configures UnpackSync with { keep: true } (do not overwrite existing files) and the archive includes a file path that already exists on disk, the skip handler decrements [PENDING] via [UNPEND]() without emit of a warning.The following standalone Proof of Concept (PoC) demonstrates how a tar stream containing a broken hard link followed by a regular file permanently hangs the UnpackSync stream consumer:
import fs from 'node:fs';
import tar from 'tar';
const cwd = './test-repro';
fs.mkdirSync(cwd, { recursive: true });
// Instantiate UnpackSync (equivalent to tar.x({ sync: true, cwd }))
const unpacker = new tar.UnpackSync({ cwd });
let completed = false;
unpacker.on('end', () => {
completed = true;
console.log('[+] Stream completed successfully.');
});
// Construct a malicious tar archive stream in memory
const pack = new tar.Pack();
// Entry 1: Broken hard link pointing to non-existent target triggers ONERROR -> UNPEND()
pack.add({ path: 'broken-link', type: 'Link', linkpath: 'does-not-exist' });
// Entry 2: Normal file (still written to disk before stream locks at EOF)
pack.add({ path: 'valid-file.txt', type: 'File', size: 4 }, 'data');
pack.end();
pack.on('data', (chunk) => {
unpacker.write(chunk);
});
pack.on('end', () => {
unpacker.end();
setTimeout(() => {
if (!completed) {
console.error('[-] DoS Confirmed: UnpackSync failed to emit "end" event.');
process.exit(1);
}
}, 1000);
});> [!NOTE]
> In automated pipelines where stream.pipeline(), stream/promises, or an explicit event listener (new Promise(resolve => unpackStream.on('end', resolve))) awaits stream completion before releasing worker threads, closing HTTP connections, or cleaning up temporary directories, this state machine deadlock indefinitely leaks the enclosing async context and stalls the worker.
The primary security impact of CVE-2026-140252 is High impact to system availability (VA:H in CVSS v4.0), with no direct impact to confidentiality (VC:N) or integrity (VI:N). The vulnerability is scored at 7.1 (High) under CVSS v4.0 (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).
The scope of the vulnerability depends strictly on how node-tar is invoked within the consuming application. Only synchronous stream extraction is affected:
| Extraction Pattern | Affected? | Technical Reasoning |
|---|---|---|
tar.x({ sync: true }) (no file option) | Yes | Returns an UnpackSync stream instance expecting piped data and stream settlement events (end, finish). |
new tar.UnpackSync({ ... }) | Yes | Directly instantiates the vulnerable class. |
tar.x({ file: 'archive.tar', sync: true }) | No | Operates via synchronous file descriptor reads (fsm.ReadStreamSync) where completion returns immediately upon exhausting the file size rather than awaiting stream lifecycle events. |
tar.x({ ... }) / new tar.Unpack({ ... }) (Async) | No | Asynchronous Unpack calls this[PEND]() symmetrically for every entry before filesystem dispatch, keeping [PENDING] balanced when [UNPEND]() executes. |
In affected deployment architectures—such as build servers, serverless functions, CI/CD runners, or microservice endpoints that pipe incoming archive streams into tar.x({ sync: true, cwd }) and await stream completion—an attacker can exhaust available request handlers, worker pools, or memory budgets by submitting concurrent requests containing small crafted tar archives.
The vulnerability is patched in node-tar version 8.0.0. Users and package maintainers should update their dependencies to tar@^8.0.0:
npm install tar@^8.0.0> [!IMPORTANT]
> Version 8.0.0 is a major release that introduces breaking architectural changes:
> - Node.js Runtime Requirement: Requires Node.js >= 22.
> - Web Streams Migration: Replaces custom Minipass streams (Unpack, Pack) with native Web Streams (ReadableStream, TransformStream).
> - Dedicated Synchronous API: Removes the sync: true flag and UnpackSync class from the main export in favor of explicit synchronous helpers exported via tar/node (such as import { extractSync } from 'tar/node').
v7.x EnvironmentsFor applications constrained to older Node.js runtimes (< 22) that cannot immediately upgrade to tar@8.0.0, two workarounds completely eliminate exposure on v7.5.22 – v7.5.24:
Switch to Asynchronous Stream Extraction or File-Based Extraction: Replace synchronous stream piping with either standard asynchronous extraction or synchronous file-based extraction:
// VULNERABLE PATTERN:
// sourceStream.pipe(tar.x({ sync: true, cwd: targetDir }));
// SAFE WORKAROUND A: Asynchronous stream extraction
import { pipeline } from 'node:stream/promises';
await pipeline(sourceStream, tar.x({ cwd: targetDir }));
// SAFE WORKAROUND B: Synchronous file-based extraction
tar.x({ sync: true, file: '/path/to/archive.tar', cwd: targetDir });Runtime Prototype Monkey-Patching:
If UnpackSync cannot be refactored out of an existing v7.5.x codebase, locate the private Symbol(unpend) on tar.Unpack.prototype at application startup and override it on tar.UnpackSync.prototype with a no-op function, mirroring commit 73b352e0010d6c99794ea7374800816a46d3bdb2:
import tar from 'tar';
const unpendSymbol = Object.getOwnPropertySymbols(tar.Unpack.prototype)
.find((sym) => sym.description === 'unpend');
if (unpendSymbol && tar.UnpackSync) {
tar.UnpackSync.prototype[unpendSymbol] = function () {};
}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| Product | Affected Versions | Fixed Version |
|---|---|---|
node-tar (tar) isaacs | >= 7.5.22, < 8.0.0 | 8.0.0 |
| Attribute | Detail |
|---|---|
| CVE / Advisory ID | CVE-2026-140252 / GHSA-25mm-r35j-6hgm |
| Weakness Class | CWE-911 (Improper Update of Reference Count) |
| 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) |
| Affected Component | node-tar UnpackSync (versions >= 7.5.22, < 8.0.0) |
| Patched Version | 8.0.0 (Commit 73b352e0010d6c99794ea7374800816a46d3bdb2) |
| Impact | Indefinite Stream Hang / Application Denial of Service |
| Exploit Status | Proof-of-Concept (Regression Test Suite) |
| CISA KEV Status | Not Listed |
The software uses a reference count to manage a resource, but it does not properly update the count when a reference is added or removed, causing the count to drop below zero or fail to reach the expected termination value.
CVE-2026-140014 (also tracked as GHSA-8wcq-xq25-7fhm and RUSTSEC-2026-0594) is a cryptographic weakness in the Rust cookie library (cookie-rs). Affected versions use userspace thread-local pseudo-random number generators (rand::thread_rng() or rand::rng()) to generate 96-bit nonces for AES-256-GCM encrypted cookies in PrivateJar. Because these generators buffer entropy in userspace memory, invoking a Unix fork() system call without exec() clones the internal RNG buffer into child processes. When sibling or parent-child processes subsequently seal private cookies on the same thread using a shared key, they emit identical nonces. This nonce reuse under AES-GCM compromises ciphertext confidentiality via keystream XOR recovery and enables arbitrary cookie forgery via polynomial GHASH authentication key recovery.
An algorithmic complexity vulnerability (CWE-407) in the JavaScript glob-matching package minimatch affects versions 11.0.0 through 11.0.6. The flaw originates in the mergeRows() optimization method in src/index.ts, which repeatedly clones and joins entire pattern arrays across every wildcard segment position. This creates quadratic O(N^2) compilation overhead for patterns containing repeated slash-separated wildcards, blocking the single-threaded Node.js event loop and resulting in an unauthenticated Denial of Service.
A denial-of-service vulnerability exists in the Go library github.com/blakesmith/ar across all released versions. The archive header parser fails to validate that the 10-byte decimal size field of an archive member is non-negative. When an application processes a crafted Unix ar archive (such as a .deb package or .rlib archive) containing a negative member size, a subsequent read operation attempts to reslice an internal byte buffer using the negative integer as the upper bound. This triggers an unhandled Go runtime slice bounds out-of-range panic, terminating the calling process.
Vite+ (vp) versions 0.2.9 through 1.5.0 contain an integrity verification flaw (CWE-494) in the internal package manager bootstrap mechanism. When initializing in an environment where the pinned pnpm distribution is not cached, the runtime queries the registry specified in the local workspace's .npmrc file and validates the downloaded tarball exclusively against the self-reported integrity digest provided by that same registry. An attacker who supplies a repository with a malicious .npmrc pointing to an attacker-controlled registry can achieve arbitrary code execution when a developer or CI runner invokes basic vp commands.
A local OS command injection and dynamic code evaluation vulnerability (CWE-78 / CWE-95) exists in the Vite+ global command-line interface (vp) across versions 0.3.3 through 1.5.0. When resolving package manager dist-tags such as 'latest' with the '--no-install' flag enabled, Vite+ queries the npm registry defined in the local workspace's '.npmrc' file and returns the raw version string without semantic version validation. Because this unvalidated string is interpolated directly into shell environment export statements evaluated by the user's shell wrapper, an attacker controlling the registry can inject shell metacharacters to achieve arbitrary command execution in the developer's local terminal context.
CVE-2026-137196 (also tracked as GHSA-qxr8-q827-836c) is an asymmetric resource consumption and denial-of-service vulnerability affecting the npm package glob (node-glob) in versions 13.0.5 through 14.0.5. When processing primary search patterns, node-glob relies on the minimatch engine with a default safeguard parameter (braceExpandMax: 10_000) to prevent combinatorial explosions during shell brace and directory traversal expansion. However, the Ignore class in src/ignore.ts instantiated its internal minimatch options with optimizationLevel: 2 while omitting the braceExpandMax configuration property. Consequently, applications that pass untrusted input into the ignore option allow attackers to trigger unbounded pattern expansion and quadratic O(n^2) preprocessing loops inside secondPhasePreProcess(), leading to single-threaded Node.js event-loop starvation.