Skip to content

Update dependency tar to v8 [SECURITY] - #1419

Open
renovate[bot] wants to merge 1 commit into
mainfrom
renovate/npm-tar-vulnerability
Open

renovate[bot] wants to merge 1 commit into
mainfrom
renovate/npm-tar-vulnerability

Conversation

@renovate

@renovate renovate Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

This PR contains the following updates:

Package Change Age Confidence
tar ^7.5.22 → ^8.0.0 age confidence

Test plan: CI should pass with updated dependencies. No review required: this is an automated dependency update PR.


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

CVE-2026-140252 / GHSA-25mm-r35j-6hgm

More information

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.

Severity

  • CVSS Score: 7.1 / 10 (High)
  • Vector String: 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

References

This data is provided by the GitHub Advisory Database (CC-BY 4.0).


node-tar async extraction deadlocks permanently when an entry's linkpath is a hierarchical relative of its own path

CVE-2026-140251 / GHSA-98v3-7xjr-fg83

More information

Details

Summary

An unauthenticated remote-input denial of service allows a crafted tar archive of about 1.5 KB to permanently and silently hang node-tar's default asynchronous extraction. When a Link or SymbolicLink entry has a linkpath that is an ancestor (or descendant) directory of the entry's own path, the internal path-reservation queue enters an unsatisfiable state. The promise returned by tar.x() / tar.extract() never resolves or rejects, the stream never emits end / finish / close, and no warning is raised. Every entry after the poison entry is silently skipped.

Details

Async Unpack serialises filesystem work through PathReservations (src/path-reservations.ts). reserve([entry.path, entry.linkpath], fn) registers each reserved path as a plain function at that path's queue key, and every ancestor directory of each path as a Set<Handler> at that directory's queue key.

check(fn) (src/path-reservations.ts:114-120) only schedules fn when it is the head function of every path queue AND the head of every directory queue is a Set that contains fn:

check(fn) {
  const { paths, dirs } = this.#getQueues(fn)
  return (
    paths.every(q => q && q[0] === fn) &&
    dirs.every(q => q && q[0] instanceof Set && q[0].has(fn))
  )
}

When one of the two reserved strings is an ancestor directory of the other, the same queue key is written twice: once as a function head (the path reservation, src/path-reservations.ts:65-72) and once as a directory Set (the dir reservation, src/path-reservations.ts:73-85). For a hardlink a/b whose linkpath is a, key a first receives [fn] (function head), then the dir loop appends a Set behind it, giving [fn, Set([fn])]. check() then requires q[0] instanceof Set at key a, but q[0] is the function fn, so check() is permanently false. #run(fn) never fires, [CHECKFS2] never executes, the [PENDING] counter never drains, and [MAYBECLOSE] never completes the stream.

The collision can be introduced by three independent, attacker-controlled routes, all validated:

  1. A literal Link / SymbolicLink header whose linkpath is a hierarchical relative of its path.
  2. A PAX extended-header linkpath record attached to a plain File entry (the "linkpath forbidden" check runs on the raw header before PAX fields are applied, so a File can carry a linkpath). See advisory 03.
  3. A GNU long-linkname (K / NextFileHasLongLinkpath) entry assigning a hierarchical linkpath to the following link entry.

Synchronous extraction bypasses reservations and is unaffected. Windows is unaffected because reservations are globally serialised there under a single key ('win32 parallelization disabled', src/path-reservations.ts:53-55).

PoC

Validated on president-xd/node-tar main @​ 2a22bfc (version 7.5.22) and against the published npm package tar@7.5.22, on Linux, 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/resv-hang'; fs.rmSync(dir, {recursive:true, force:true}); fs.mkdirSync(dir, {recursive:true})
const b = Buffer.alloc(512)
new Header({ path: 'a/b', type: 'Link', linkpath: 'a', size: 0, mode: 0o644 }).encode(b, 0) // linkpath 'a' is ancestor of 'a/b'
fs.writeFileSync(dir + '/poison.tar', Buffer.concat([b, Buffer.alloc(1024)]))
let settled = 'NEVER'
x({ cwd: dir, file: dir + '/poison.tar' }).then(() => settled='RESOLVED').catch(() => settled='REJECTED')
const keepalive = setInterval(() => {}, 100) // hold the loop open so an unsettled promise is a true hang
setTimeout(() => { clearInterval(keepalive); console.log('result:', settled); process.exit(0) }, 4000)

Observed output:

result: NEVER      // no warning, no resolution, no rejection

Control archive with linkpath: 'c' (a sibling, not a hierarchical relative) resolves in the same harness with a single TAR_ENTRY_ERROR warning. The PAX-linkpath route (14 linkpath=a\n before a File at a/b) and the GNU K route both hang identically; their sibling controls both resolve.

Impact

Availability-only denial of service (no confidentiality or integrity effect, no extraction outside the target directory). Any pipeline that uses node-tar's default asynchronous extraction on POSIX and awaits completion can be wedged forever by a small crafted archive: npm and CI package installation, artifact processing, bundlers, and any service that extracts third-party tarballs. Impact is a permanent silent hang, with all subsequent entries in the archive never extracted. Unauthenticated, remote, no user interaction.

Severity

  • CVSS Score: 7.1 / 10 (High)
  • Vector String: 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

References

This data is provided by the GitHub Advisory Database (CC-BY 4.0).


node-tar: Nested symlink target can escape node-tar extraction root

CVE-2026-140248 / GHSA-6wwr-g865-f46r

More information

Details

Summary

With default preservePaths: false, tar 7.5.22 can extract a symbolic link whose effective target is outside the extraction directory. A crafted archive first creates one in-root symlink and then a second symlink whose target contains that symlink followed by ... The containment check simplifies the target lexically before checking filesystem symlinks, but the stored target is resolved by the OS through the first symlink. A later consumer following the extracted link can access a file outside the intended root.

This was reproduced locally on commit 2a22bfc5d3a432a606d9da0e2d87ba634aa3b1cb (package version 7.5.22). Earlier versions were not assessed. The PoC only reads a marker that it creates in its own temporary directory. No preexisting file is touched.

Root cause

STRIPABSOLUTEPATH accepts a symlink linkpath containing .. if path.posix.normalize(path.posix.join(entryDir, linkpath)) appears to stay inside the extraction root (src/unpack.ts:263-302). Later, SYMLINK derives parts using path.resolve(dirname(entry.absolute), entry.linkpath) (src/unpack.ts:640-659), which also removes b/.. before ENSURE_NO_SYMLINK inspects each component (src/unpack.ts:679-698). LINK then writes the original unsimplified entry.linkpath with fs.symlink (src/unpack.ts:866-880).

For a/b -> ../x and a/c -> b/../.., the lexical check reduces the second target to the extraction root and never checks a/b. Actual filesystem traversal follows a/b to x first and then processes two parent components, ending in the extraction root's parent.

Safe local PoC

Run from a built checkout of 7.5.22:

import { mkdtempSync, mkdirSync, writeFileSync, readFileSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { Header, extract } from 'tar'

const parent = mkdtempSync(join(tmpdir(), 'node-tar-link-poc-'))
const out = join(parent, 'out')
mkdirSync(out)
writeFileSync(join(parent, 'outside-marker.txt'), 'OUTSIDE MARKER\n')
const block = h => {
  const b = Buffer.alloc(512)
  new Header(h).encode(b)
  return b
}
const input = join(parent, 'input.tar')
writeFileSync(input, Buffer.concat([
  block({ path: 'x/', type: 'Directory', size: 0 }),
  block({ path: 'a/', type: 'Directory', size: 0 }),
  block({ path: 'a/b', type: 'SymbolicLink', linkpath: '../x', size: 0 }),
  block({ path: 'a/c', type: 'SymbolicLink', linkpath: 'b/../..', size: 0 }),
  Buffer.alloc(1024),
]))

const warnings = []
await extract({ file: input, cwd: out, onwarn: (code, message) => warnings.push({ code, message }) })
console.log(readFileSync(join(out, 'a/c/outside-marker.txt'), 'utf8').trim())
console.log(warnings)
// OUTSIDE MARKER
// []

The marker is outside out; the access passes through a symlink extracted under out. This demonstrates the target containment bypass. It does not claim that node-tar itself writes outside out while extracting a subsequent member; its existing path checks may stop such an entry.

Impact and suggested fix

An attacker needs to supply a tar archive to an application that extracts links and later follows or serves files from the extracted tree. The resulting link crosses the documented default target confinement. The downstream read/write impact depends on that consumer.

Validate link targets using filesystem semantics before accepting them, or conservatively reject a target that traverses .. after a symlink component. In particular, inspect the unsimplified components before path.resolve() removes them. Add a regression case with a symlink component followed by .., and assert that the second link is rejected under default options.

Credit goes to GitHub user @mikkel32 as finder/reporter in the published advisory.

Severity

  • CVSS Score: 7.2 / 10 (High)
  • Vector String: CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:L/VI:H/VA:L/SC:N/SI:N/SA:N

References

This data is provided by the GitHub Advisory Database (CC-BY 4.0).


node-tar crashes the process with an uncaught exception on a 4-byte zstd magic header when the Node runtime lacks native zstd

CVE-2026-140241 / GHSA-72fp-85cc-g945

More information

Details

Summary

An unauthenticated remote-input denial of service allows a four-byte file to crash any process that lists or extracts it with node-tar's asynchronous file API, on any Node runtime without native zlib zstd support (Node 18.x, 20.x, 21.x, 22.0-22.14, 23.0-23.7, all of which satisfy the package's declared engines: node >= 18). node-tar's default-enabled compression sniffing detects the zstd magic (28 b5 2f fd) and constructs new ZstdDecompress({}) with no error handling. On a runtime without the zstd binding, minizlib's constructor throws a TypeError synchronously inside the file-read stream's data callback, so the async tar.t() / tar.x() promise never settles and the exception is uncaught, killing the process.

Details

Parser.write() sniffs the first bytes of every input and, on the zstd magic, constructs the decompressor unguarded:

// src/parse.ts:547-550
this[UNZIP] =
  this[UNZIP] === undefined ? new Unzip({})
  : isZstd ? new ZstdDecompress({})   // throws TypeError on a runtime without native zstd
  : new BrotliDecompress({})

minizlib's ZlibBase constructor throws TypeError: Compression method not supported: ZstdDecompress when node:zlib lacks the binding. Because this construction runs inside the file-read stream's data handler (ReadStream.emit -> Unpack.write -> new ZstdDecompress), the throw is not routed through the stream's error event or Parser.abort(). For the async file form (tar.x({file}) / tar.t({file})), the throw escapes as an uncaught exception: the process dies, and a consumer's try/catch or .catch() cannot reach it because the returned promise never settles. zlib.ZstdDecompress was added in Node v23.8.0 and backported to v22.15.0; on those and later runtimes the class exists and the same 4-byte input is handled through the normal catchable error path instead.

PoC

Validated on the published npm package tar@7.5.22 (and source main @​ 2a22bfc). Vulnerable runtime: Node v20.20.2 (node -e "console.log(typeof require('zlib').ZstdDecompress)" prints undefined). Non-vulnerable control: Node v24.19.0.

// npm i tar@7.5.22 ; node poc.cjs   (run on Node 20)
const { x } = require('tar'); const fs = require('fs')
fs.writeFileSync('/tmp/z4.tar', Buffer.from([0x28,0xb5,0x2f,0xfd,0x01,0x02,0x03,0x04]))
fs.rmSync('/tmp/z-out',{recursive:true,force:true}); fs.mkdirSync('/tmp/z-out')
let uncaught = null, settled = 'NEVER'
process.on('uncaughtException', e => uncaught = e.constructor.name + ': ' + e.message)
x({ cwd:'/tmp/z-out', file:'/tmp/z4.tar' }).then(()=>settled='RESOLVED').catch(()=>settled='REJECTED')
const ka = setInterval(()=>{},100)
setTimeout(()=>{ clearInterval(ka); console.log('uncaught:', uncaught); console.log('settled:', settled); process.exit(0) }, 3000)

Observed on Node v20.20.2 (zstd undefined):

uncaught: TypeError: Compression method not supported: ZstdDecompress
settled:  NEVER

Without the uncaughtException handler the process dies with the raw stack (frame: at new ZstdDecompress ... at Unpack.write ... at FSReqCallback.wrapper [as oncomplete] (node:fs)). On Node v24.19.0 the same file produces a clean catchable rejection (TAR_ABORT / zlib: Dictionary mismatch) and no crash. Synchronous mode and direct stream writes throw catchably from the caller's stack on all runtimes; only the async file API turns the throw into process death.

Impact

Availability-only denial of service via process crash. Four attacker-controlled bytes, with no tar structure, kill any pipeline on an affected Node runtime that lists or extracts an attacker-supplied archive through node-tar's async file API, including npm-style package installation and CI artifact processing. The impact is conditional on the Node version: it is present on Node 18.x, 20.x, 21.x, 22.0-22.14, and 23.0-23.7 (Node 20 is an Active LTS line in wide production use) and inert on Node 22.15+ / 23.8+ / 24+. Unauthenticated, remote, no user interaction.

Severity

  • CVSS Score: 7.1 / 10 (High)
  • Vector String: 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

References

This data is provided by the GitHub Advisory Database (CC-BY 4.0).


Release Notes

isaacs/node-tar (tar)

v8.0.0

Compare Source

A new API. See "Migration from version 7" in the README.

Breaking changes
  • Drop support for node <22
  • Remove callbacks and Node.js streams. Each command returns a promise. create() with no file returns a web ReadableStream. list() and extract() read the input option, or a file.
  • Remove the sync option. Use createSync, extractSync, listSync, replaceSync, and updateSync.
  • Rename onReadEntry to onEntry, which is awaited. onReadEntry and onentry are aliases of it.
  • The option aliases (C, f, z, P, U, k, m, p, L, h, strip-components, keep-newer, keep-existing, no-mtime, their camelCase forms, and noChmod) work in the commands only. entries(), Pack, Unpack, and Parser take only the names of the options.
  • Remove the options noResume, ondone, dirCache, linkCache, readdirCache, and statCache.
  • ReadEntry and WriteEntry are not streams. A ReadEntry has the shape of a Response: body, bytes(), arrayBuffer(), text(), and blob(). A WriteEntry is metadata and a body.
  • Parser, Pack, and Unpack are not streams. Parser is a state machine with push() and next(). Pack is an async iterator of chunks. Unpack has an extract(input) method.
  • Remove WriteEntrySync and WriteEntryTar.
  • Use Uint8Array, not Buffer. Header#block and the result of Pax#encode() are a Uint8Array.
  • transform returns a TransformStream, or an object with a readable and a writable web stream. In extractSync(), it returns a function that changes a chunk. For a Node.js Transform stream, return codecStream(stream).
  • In strict mode, extraction stops at the first error.
  • The first null block is the end of the archive, as it is for bsdtar. Data after it is dropped with no warning, also when no second null block comes after it. Version 7 read the entries after a single null block, so it read archives that were joined end to end. Split such a file into its archives before you read it.
  • update() adds a file only if it is newer than the entry of the same path. It does not add a file that has the same time as the entry, or a time that differs only by a part of a second.
  • A jobs or maxReadSize option that is not 0, a positive integer, or Infinity is a TypeError. 0 gives the default.
  • A uid or gid option of extract() that is not an unsigned 32-bit integer is a TypeError. Before, it was ignored, and the owner in the archive was used.
  • create() gives a TAR_ENTRY_UNSUPPORTED warning for a path that is not a file, a directory, or a symbolic link, such as a socket, a FIFO, or a device. Before, it skipped the path with no warning. With strict, it is an error.
  • extract() with strip skips an entry that has no part of its path left, as GNU tar and bsdtar do. Before, a directory entry such as package/ with strip: 1 set its mode, owner, and times on the extraction directory.
  • In create(), replace(), and update(), a path that does not exist is a TAR_ENTRY_ERROR warning, as it is for bsdtar. The other paths are added. Before, it was an error that stopped the command. Set strict to get the error.
  • extract() and list() give a TAR_ENTRY_ERROR warning for each path in files that no entry of the archive matches. With strict, it is an error after the archive is read.
  • The readers detect the compression format. The brotli and zstd options are only for create().
  • Remove the subpath exports (tar/create, tar/extract, tar/parse, and the others). The exports are tar, tar/core, tar/raw, and tar/core/raw.
  • Remove all runtime dependencies: minipass, minizlib, @isaacs/fs-minipass, chownr, and yallist.
New features
  • delete() and deleteSync() remove entries from an archive file: the paths in a list, the entries that a filter accepts, or both. The archive keeps its compression.
  • Add the tar/core entry point, the runtime-neutral core. It runs in a browser, a worker, or another runtime with web streams. It uses no node: module, and it needs the fs and cwd options for work on files. It has no sync commands.
  • tar is the entry point for server-side runtimes: Node.js, and each other runtime that has the node: modules. It has all of the core, the sync commands, and the defaults (node:fs, node:zlib, the working directory, the platform, and the user of the process).
  • tar/raw and tar/core/raw are the same two entry points as separate modules that are not minified.
  • Add the fs option. All file system work goes through it, so a caller can give another file system.
  • Add the input option, and entries() and entriesSync(), which read a Uint8Array, an ArrayBuffer, a Blob, a ReadableStream, or an iterable of chunks.
  • Add entries from memory to an archive: the file list of create(), replace(), and update() takes WriteEntry objects, ReadEntry objects, and iterables of entries.
  • Add the Codec type and the codecs option, to add a compression format. tar has gzip, brotli, and zstd from node:zlib. tar/core has gzip.
  • create() writes the names of a directory in sorted order, so the archive is the same on each runtime and file system.
  • list() and extract() with a file do not read the body of an entry that nothing reads. A listing of an archive of large files reads only the headers.
  • Add the compress option of create(). It takes a Codec, or [codec, options], and writes the archive with that codec.
  • The options platform, processUid, processGid, processUname, and processUmask give the facts of the process to tar/core.
  • In tar/core, the cwd of create() and of extract() must be an absolute path. A path that is not absolute is a TypeError. The tar entry point makes a relative cwd absolute first.
  • Nothing is read before the consumer asks for it: the readers read input, and create() reads files, only on demand.
  • The async extraction writes up to 16 entries at one time (the jobs option).
  • replace() and update() read PAX and GNU long name headers when they find the place to append, and refuse an archive in any known compressed format.
  • Export CwdError and SymlinkError.
  • create() reads the dev and ino of a file with more than one link as bigint values when the numbers are not safe integers. On Windows, two files can have the same ino number. Before, the second file was then written as a hard link to the first, and its content was lost. With follow, a directory gets the same exact values for the check that it is not in itself.
  • The error of create() for a file that has fewer or more bytes than its lstat size names the path and the size in its message.
  • extract() works with a cwd that is a root of the file system, such as / or c:\.
Security fixes
Bug fixes
  • On Windows, extract() with preservePaths sets the owner of each directory that it makes, not only of the last one.
  • update() checks the paths in a directory also when the time of the directory did not change. A directory is always added again.
  • A path in the files of list() and extract() matches an entry at each depth in that directory, not only 100 levels.
  • create() does not write a file that has more than one link as a hard link to itself when its path is added two times.
  • extract() keeps an existing directory for a GNUDumpDir entry, as it does for a Directory entry.
  • With two GNU long name headers before one entry, the readers use the last one, as GNU tar does.

v7.5.24

Compare Source

v7.5.23

Compare Source


Configuration

📅 Schedule: (in timezone America/Los_Angeles)

  • Branch creation
    • At any time (no schedule defined)
  • Automerge
    • At any time (no schedule defined)

🚦 Automerge: Enabled.

♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@renovate
renovate Bot enabled auto-merge (squash) December 1, 2026 22:47
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown

@renovate
renovate Bot force-pushed the renovate/npm-tar-vulnerability branch from 65b073c to 418dbf7 Compare December 2, 2026 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants