High

pnpm Vulnerable to Arbitrary File Write/Delete via Malicious Patch File (Path Traversal)

  • Disclosed: 26.06.2026
  • Updated: 11.10.2026 10:22

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 node_modules/.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):

js
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):

js
case 'file deletion': {
  const eff = effect
  // TODO: integrity checks
  if (!opts.dryRun) {
    fs.unlinkSync(eff.path)
  }
  break
}

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

Proof of Concept

bash
# Write variant:
bash autofyn_audit/exploits/vuln6_patch_traversal_write/exploit.sh
# Result: PASS -- /tmp/vuln6_pwned created with attacker-controlled content

# Delete variant:
bash autofyn_audit/exploits/vuln7_patch_traversal_delete/exploit.sh
# Result: PASS -- /tmp/vuln7_target deleted by malicious patch

# Combined chain (delete + replace SSH authorized_keys):
bash autofyn_audit/exploits/chain2_patch_ssh_backdoor/exploit.sh
# Result: PASS -- authorized_keys 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 authorized_keys, 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: audit_report.md Exploit script: exploit.sh

Affected software

Click a technology to see all vulnerabilities affecting it.

PlatformPackageVulnerable versionsFixed in
npm package pnpm < 10.34.0, >= 11.0.0, < 11.4.0 10.34.0, 11.4.0

References

CVSS score 7.3/10
CVSS vector
CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:N/I:H/A:H
Weakness (CWE)
CWE-22
Platform
npm
Package
pnpm
Disclosed
26.06.2026
Updated
11.10.2026 10:22

Sources and licenses

OSV / GitHub Advisory Database - GHSA-rxhj-4m44-96r4 - CC BY 4.0

Vulnerability history: pnpm

All published vulnerabilities of this package (npm package), newest first. Shows whether this is a one-off slip or a package that needs watching.

All (32) in the archive
Total entries
32
First → latest
03.2022 09.2026
Without a fix
0
Exploited in attacks
0

Severity breakdown

  • High 18
  • Medium 14

Disclosures per year

  1. 2022: 1
  2. 2023: 1
  3. 2024: 1
  4. 2025: 1
  5. 2026: 28
Severity:
  1. High · 7.1 CVE-2026-82392 < 10.34.5, >= 11.0.0, < 11.11.0 10.34.5, 11.11.0
  2. High · 7.5 CVE-2026-82393 < 10.34.5, >= 11.0.0, < 11.11.0 10.34.5, 11.11.0
  3. High · 7.4 CVE-2026-101043 >= 11.0.0, < 11.11.0, >= 10.7.0, < 10.34.5 11.11.0, 10.34.5
  4. High · 7.1 ghsa-2rx9-3g3h-c2jv >= 12.0.0-alpha.0, < 12.0.0-alpha.5 12.0.0-alpha.5
  5. High · 8.2 CVE-2026-59195 < 10.34.4, >= 11.0.0, < 11.8.0 10.34.4, 11.8.0
  6. High · 7.1 CVE-2026-59194 < 10.34.4, >= 11.0.0, < 11.7.0 10.34.4, 11.7.0
  7. High · 7.1 CVE-2026-59196 < 10.34.4, >= 11.0.0, < 11.7.0 10.34.4, 11.7.0
  8. High · 8.8 CVE-2026-55698 < 10.34.2, >= 11.0.0, < 11.5.3 10.34.2, 11.5.3
  9. High · 7.5 CVE-2026-55697 < 10.34.2, >= 11.0.0, < 11.5.3 10.34.2, 11.5.3
  10. High · 7.5 CVE-2026-55487 < 10.34.2, >= 11.0.0, < 11.5.3 10.34.2, 11.5.3
  11. pnpm Vulnerable to Arbitrary File Write/Delete via Malicious Patch File (Path Traversal) this entry
    High · 7.3 CVE-2026-50015 < 10.34.0, >= 11.0.0, < 11.4.0 10.34.0, 11.4.0
  12. High · 8.8 CVE-2026-50016 < 10.34.0, >= 11.0.0, < 11.4.0 10.34.0, 11.4.0
  13. High · 8.8 CVE-2025-69264 >= 10.0.0, < 10.26.0 10.26.0
  14. High · 7.5 CVE-2025-69262 >= 6.25.0, < 10.27.0 10.27.0
  15. High · 7.5 CVE-2023-37478 < 7.33.4, >= 8.0.0, < 8.6.8 7.33.4, 8.6.8
  16. High · 8.8 CVE-2022-26183 < 6.15.1 6.15.1

Know which vulnerabilities affect your application

With the DockRay integration and software inventory enabled, DockRay checks reported component versions against known vulnerabilities and notifies you about confirmed matches. Coverage depends on the supported technology and available advisory data.

Connect your application
DockRay newsletter

Application security in your inbox

Important vulnerabilities, actionable guidance and practical advice for your applications. Choose your technologies and follow what matters to your project.

  • A daily digest of new vulnerabilities, critical ones included.
  • Notifications about important updates.
  • Practical advice on application security and monitoring.

Leave empty to receive updates for every technology.

Free to subscribe. Unsubscribe with one click in any email.