CVE-2026-50015: pnpm: Arbitrary File Write/Delete via Malicious Patch File (Path Traversal)

Published Jun 25, 2026
·
Updated

Summary

pnpm's patch application pipeline (@pnpm/patch-package) performs no path validation on file paths extracted from .patch files. An attacker who contributes a malicious patch file via a pull request can write attacker-controlled content to or delete arbitrary files on the filesystem during pnpm install, as the user running the install. The diff --git header paths containing ../../ sequences traverse out of the package directory, and the traversal is difficult to catch in code review because patch file diff headers are opaque to most reviewers.

Vulnerability Details

During pnpm install, when a patchedDependencies entry is present in pnpm-workspace.yaml, pnpm reads the referenced .patch file and applies it via the embedded @pnpm/patch-package library. The applyPatchToDir function at patching/apply-patch/src/index.ts:12-13 calls process.chdir(opts.patchedDir), setting the working directory to the installed package location deep inside nodemodules/.pnpm/.

The patch parser at @pnpm/patch-package/dist/patch/parse.js:88 extracts file paths from diff --git a/(.?) b/(.?) headers using a regex with no path sanitization. The executeEffects function in apply.js then operates on these unsanitized paths:

File write (apply.js:35-49): javascript case 'file creation': { const eff = effect fs.ensureDirSync(dirname(eff.path)) fs.writeFileSync(eff.path, fileContents, { mode: eff.mode }) break }

File delete (apply.js:13-22): javascript case 'file deletion': { const eff = effect // TODO: integrity checks if (!opts.dryRun) { fs.unlinkSync(eff.path) } break }

A path like ../../../../../../../../../../home/user/.ssh/authorizedkeys in the patch header traverses out of the package directory to an arbitrary location.

Proof of Concept

bash Write variant: bash autofynaudit/exploits/vuln6patchtraversalwrite/exploit.sh Result: PASS -- /tmp/vuln6pwned created with attacker-controlled content

Delete variant: bash autofynaudit/exploits/vuln7patchtraversaldelete/exploit.sh Result: PASS -- /tmp/vuln7target deleted by malicious patch

Combined chain (delete + replace SSH authorizedkeys): bash autofynaudit/exploits/chain2patchsshbackdoor/exploit.sh Result: PASS -- authorizedkeys replaced with attacker's public key

Impact

Arbitrary file write and delete as the user running pnpm install, limited to paths writable by that user. An attacker who submits a PR adding a .patch file and patchedDependencies config can target SSH authorizedkeys, shell configuration, CI/CD files, or other writable files. Patch files may receive less review scrutiny than package.json changes because the ../ traversal sequences are in diff --git headers that look like patch metadata.

Suggested Remediation

Validate parsed patch file paths against the package root directory. Reject any path that resolves outside the patched package directory via path.resolve + prefix check. Alternatively, sanitize at parse time by rejecting paths containing .. components in parse.js.

---

> Discovered by AutoFyn > Full audit report: auditreport.md > Exploit script: exploit.sh

Other sources

pnpm is a package manager. Prior to 10.34.0 and 11.4.0, pnpm's patch application pipeline (@pnpm/patch-package) performs no path validation on file paths extracted from .patch files. An attacker who contributes a malicious patch file via a pull request can write attacker-controlled content to or delete arbitrary files on the filesystem during pnpm install, as the user running the install. The diff --git header paths containing ../../ sequences traverse out of the package directory, and the traversal is difficult to catch in code review because patch file diff headers are opaque to most reviewers. This vulnerability is fixed in 10.34.0 and 11.4.0.

NVD

Affected Software

5 affected componentsFixes available
pnpm>0<=10.34.0, >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 pnpm to a version that resolves this vulnerability.

    Fixed in 10.34.0
  4. Upgrade

    Upgrade pnpm to a version that resolves this vulnerability.

    Fixed in 11.4.0
  5. Configuration

    Ensure `patchedDependencies` only references patches from trusted sources; avoid accepting PRs that add `.patch` files intended to be applied during `pnpm install`.

    pnpm patchedDependencies in pnpm-workspace.yaml = remove or disable entries that reference untrusted `.patch` files
  6. Compensating control

    During pnpm install, do not allow untrusted contributors to add or modify `.patch` files referenced via the `patchedDependencies` entry in `pnpm-workspace.yaml` (a malicious patch can write/delete arbitrary files, including `~/.ssh/authorized_keys`, as the user running the install).

Event History

Jun 25, 2026
CVE Published
via MITRE·04:52 PM
Data Sourced
via MITRE·04:52 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·06:16 PM
DescriptionSeverityWeaknessAffected Software
Jun 26, 2026
Advisory Published
via GitHub·10:59 PM
Data Sourced
via GitHub·10:59 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-50015?

The severity of CVE-2026-50015 is high with a score of 7.3.

2

How do I fix CVE-2026-50015?

To fix CVE-2026-50015, update pnpm to version 10.34.0 or later, or 11.4.0 or later.

3

What type of vulnerability is CVE-2026-50015?

CVE-2026-50015 is a Path Traversal vulnerability.

4

What can an attacker do with CVE-2026-50015?

An attacker can exploit CVE-2026-50015 to write attacker-controlled content to arbitrary files via a malicious patch file.

5

Which software is affected by CVE-2026-50015?

The software affected by CVE-2026-50015 is pnpm.

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