/

CVE-2026-82392

Severity:

HIGH RISK

(7.1)

Path Traversal (CWE-22) in pnpm Package Installation

CVE-2026-82392

Deferred

Vulnerability type

Category:

Path Traversal

CWE:

CWE-22

Impact:

Arbitrary File Write and Potential Code Execution

Severity:

HIGH RISK

(7.1)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A path traversal vulnerability in pnpm allows an attacker-controlled package name from a malicious lockfile to influence where package contents are written during installation. If a user installs from the crafted lockfile, files may be written outside the intended node_modules directory, and permitted lifecycle scripts could execute with the user's privileges.

Affected context

The issue occurs in pnpm installations that process attacker-controlled pnpm-lock.yaml package keys and use the parsed package name in filesystem paths. Risk is higher when a project permits lifecycle scripts through broad build-script policies or matching build allowlists, because an escaped package may both write files outside the dependency directory and run code during installation.

Exploit preconditions

  • Attack surface: Dependency installation through pnpm
  • Required access: Ability to provide or influence a project's lockfile or dependency input
  • Trigger point: Lockfile-to-dependency-graph processing and package installation
  • Why exploitation is possible: The parsed package name is used in path construction and package import operations without sufficient path validation, allowing filesystem locations to escape the intended dependency directory
  • Additional condition for code execution: Lifecycle scripts must be permitted by the project's build-script policy

Why this happens

The vulnerability results from treating a package name extracted from an untrusted lockfile as a trusted filesystem path component. Without canonicalization, containment checks, and validation against an expected package-name format, path construction can resolve outside the intended node_modules location. This maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory, commonly known as path traversal. If installation lifecycle scripts are also enabled, the unintended file placement may create an additional code-execution path.

Potential impact

  • Malicious package contents may be written outside the intended dependency directory
  • Project files or other user-accessible files could be overwritten
  • Installation-time code may execute with the installing user's privileges
  • Build environments, developer workstations, or CI runners could be compromised
  • Attackers may modify project behavior or persistence-related files

General mitigation guidance

Mitigation generally focuses on treating lockfiles and package metadata as untrusted input and enforcing filesystem containment.

Common defensive patterns include:

  • Validate package names against the package-manager's expected syntax before using them in paths
  • Resolve target paths canonically and verify they remain within the intended dependency directory
  • Reject absolute paths, traversal segments, and unexpected separators
  • Keep package installation and lifecycle scripts separated by default
  • Require narrowly scoped, explicit approval for trusted build scripts
  • Run dependency installation with least-privilege accounts and isolated workspaces
  • Use read-only or disposable environments for untrusted dependency installation where practical
  • Treat lockfiles from external sources as reviewed supply-chain artifacts

How teams detect issues like this

Organizations can detect related risks through:

  • Static analysis rules that flag unvalidated metadata flowing into path construction APIs such as path.join
  • Code review checks for package names or archive entries used as filesystem paths
  • Tests that verify canonicalized installation paths remain inside the intended directory
  • Dependency-installation policies that flag broad lifecycle-script permissions
  • File-integrity monitoring for unexpected writes outside dependency directories
  • CI checks that reject malformed or untrusted lockfile changes

Automated security review tools may help identify tainted-data flows from lockfiles into filesystem and process-execution operations.

Sources

SourceLink
github.comgithub.com/pnpm/pnpm/commit/51300fd41c5e4c8f47635108e373cc3d1f324fa7
github.comgithub.com/pnpm/pnpm/commit/78e29fe5583a1e5d69ea05e414eff310f78d5ed9
github.comgithub.com/pnpm/pnpm/pull/12872
github.comgithub.com/pnpm/pnpm/pull/12890
github.comgithub.com/pnpm/pnpm/releases/tag/v10.34.5
github.comgithub.com/pnpm/pnpm/releases/tag/v11.11.0
github.comgithub.com/pnpm/pnpm/security/advisories/GHSA-c59q-g84q-2gj5

Frequently asked

questions

It can be exploited through a malicious or compromised lockfile when a victim runs pnpm install, but it is not typically a network-service vulnerability by itself.

An attacker generally needs to influence the lockfile or dependency source that the victim installs. The victim must then process the crafted dependency data.

Code execution depends on lifecycle scripts being permitted by the project's build configuration. Path traversal and unintended file writes may still be relevant even when scripts are restricted.

Validate package-name input, enforce canonical path containment, reject traversal forms, and keep installation scripts disabled unless narrowly required and trusted.

Treat lockfiles as untrusted input, apply taint-aware path validation, review dependency changes, run installs with minimal privileges, and monitor installation-time filesystem activity.

Find out what's already
exploitable in your codebase.