CVE-2026-140252: node-tar UnpackSync never completes sync-stream extraction after any failing entry (PEND/UNPEND imbalance)

Published Dec 1, 2026
·
Updated

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 TARENTRYERROR 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 { if (er.name === 'CwdError') this.emit('error', er) else { this.warn('TARENTRYERROR', er, { entry }); thisUNPEND; entry.resume() } // PENDING-- } // src/unpack.ts:728-729 async CHECKFS pends... CHECKFS { thisPEND; ... }

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= [ 'TARENTRYERROR' ] Controls in the same harness: the identical archive through the async file API (x({ cwd, file })) resolves with a single TARENTRYERROR; 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.

Other sources

node-tar is a tar archive manipulation library for Node.js. From 7.5.22 until 8.0.0, during synchronous stream extraction, UnpackSync performs entry work without calling PEND, but inherited nonfatal error handling calls UNPEND after an entry fails. The pending counter becomes negative, so the exactly-zero completion condition is never reached and the stream does not emit end, finish, or close. The default asynchronous API and file-based synchronous API are not affected. This issue is fixed in version 8.0.0.

— MITRE

Affected Software

2 affected componentsFixes available
npm/node-tar>=7.5.22<8.0.0
npm/tar>=7.5.22<8.0.0
8.0.0

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade npm/tar to a version that resolves this vulnerability.

    Fixed in 8.0.0

Event History

Dec 1, 2026
CVE Published
via MITRE·06:31 PM
Data Sourced
via MITRE·06:31 PM
DescriptionWeakness
Data Sourced
via OSV·06:31 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·07:17 PM
DescriptionSeverityWeakness
Advisory Published
via GitHub·07:27 PM
Data Sourced
via GitHub·07:27 PM
DescriptionWeaknessAffected Software
Data Sourced
via OSV·07:27 PM
Affected Software

Frequently Asked Questions

1

Which applications are exposed to this issue?

Applications using node-tar synchronous stream extraction are affected in versions from 7.5.22 up to, but not including, 8.0.0. The default asynchronous API and file-based synchronous extraction are not affected.

2

What must occur for exploitation or impact?

A failing archive entry must be encountered during synchronous stream extraction. The failure follows the nonfatal error-handling path, which decrements the pending counter without a corresponding increment.

3

How can I tell whether an application is affected at runtime?

After a failing entry in synchronous stream extraction, the extraction stream never emits end, finish, or close. This can leave application logic waiting indefinitely for stream completion.

4

What should be done if the application uses the affected API?

Update node-tar to version 8.0.0. If updating is not immediately possible, avoid synchronous stream extraction and use the asynchronous API or file-based synchronous API instead.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203