/

CVE-2026-59196

Severity:

HIGH RISK

(7.1)

Path Traversal (CWE-22) in pnpm Lockfile Alias Handling

CVE-2026-59196

Analyzed

Vulnerability type

Category:

Path Traversal and Insecure Filesystem Layout

CWE:

CWE-22, CWE-73

Impact:

Filesystem Layout Corruption 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

pnpm lockfile alias handling previously allowed crafted path traversal entries to be joined directly under the hoisted node_modules directory, letting aliases escape the intended package layout.

Under certain conditions, reserved aliases such as .bin or .pnpm could be overwritten, enabling an attacker who can modify lockfiles or dependency metadata to corrupt pnpm-owned directories and potentially influence executed binaries.

Affected context

This vulnerability appears in pnpm-based JavaScript/Node.js projects that rely on lockfile-driven dependency resolution and hoisting into a shared node_modules directory.

It becomes relevant when pnpm processes aliases from the lockfile or dependency metadata and treats those alias paths as trusted.

Environments that ingest lockfiles from external sources (such as CI pipelines, shared monorepos, or automated tooling) are more exposed, particularly when pnpm-owned directories (.bin, .pnpm) are part of the hoisted layout.

Exploit preconditions

  • Attack surface: pnpm CLI execution, typically during install or dependency resolution.
  • Required access: Ability to introduce or modify a crafted lockfile (e.g., committing to a repository, publishing a malicious package, or tampering with build artifacts).
  • Trigger point: Running pnpm commands that read the lockfile and compute hoisted node_modules aliases.
  • Why exploitation is possible: Lockfile alias paths were not sufficiently constrained or normalized, allowing traversal sequences and reserved directory names to be joined into the filesystem layout without robust validation.

Why this happens

The underlying flaw stems from insufficient validation of file and directory paths derived from lockfile aliases when constructing the hoisted node_modules tree.

pnpm treated alias strings as trusted input and joined them into the installation directory without enforcing strict constraints on traversal components (such as ../) or on reserved internal directories (.bin, .pnpm).

This behavior aligns with CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), and CWE-73: External Control of File Name or Path, where attacker-influenced paths can alter filesystem locations outside their intended boundary.

Potential impact

  • Malicious modification of pnpm-owned directories (e.g., .bin and .pnpm) within the project structure.
  • Overwriting or replacing helper scripts or binaries that are later executed by developers, CI jobs, or application processes.
  • Corruption of node_modules layout, causing dependencies to resolve to attacker-controlled content.
  • Potential execution of attacker-supplied code if corrupted binaries or scripts are invoked in build or runtime workflows.
  • Undermining supply-chain integrity by silently altering dependency behavior across shared repositories or monorepos.

General mitigation guidance

Mitigation typically focuses on constraining how paths from external metadata are interpreted and reducing trust in lockfile content.

Pattern-based strategies include:

  • Enforcing strict path normalization and validation before joining alias strings into filesystem locations, rejecting traversal sequences and disallowed directory names.
  • Treating lockfiles and dependency metadata as untrusted input and applying schema and policy checks prior to installation.
  • Preserving clear separation between tool-owned directories (.bin, .pnpm) and user-controlled layout, ensuring these locations cannot be overridden via aliases.
  • Running package management operations with least privilege and in isolated, disposable environments (e.g., ephemeral CI workers) to limit the impact of layout corruption.
  • Establishing supply-chain controls that prevent arbitrary third parties from modifying lockfiles without review.

How teams detect issues like this

Organizations can identify similar issues by combining static and process-level checks:

  • Reviewing package manager source code or configuration for direct concatenation of user-controlled path components without normalization or directory boundary enforcement.
  • Adding static analysis or linter rules that flag use of path-joining APIs with unvalidated input from lockfiles, manifests, or external configuration.
  • Implementing CI policies that verify lockfile integrity, disallow unexpected alias patterns (such as traversal segments or reserved directory names), and require code review for lockfile changes.
  • Using automated supply-chain security tools that inspect dependency graphs and lockfiles for anomalous aliases or layout overrides.
  • Monitoring build and installation logs for suspicious filesystem changes under .bin, .pnpm, or other tool-owned directories.

Sources

SourceLink
github.comgithub.com/pnpm/pnpm/security/advisories/GHSA-fr4h-3cph-29xv

Frequently asked

questions

Exploitability depends on who can influence lockfiles or dependency metadata.

In environments where lockfiles are tightly controlled and reviewed, risk is reduced.

In large monorepos, shared CI pipelines, or ecosystems consuming third-party lockfiles or packages, an attacker with commit or publish rights can more readily craft malicious aliases.

An attacker typically needs the ability to modify the pnpm lockfile or supply a dependency whose metadata affects alias resolution, such as publishing a malicious package or tampering with repository contents.

Direct shell access to the installation environment is not strictly required, as exploitation occurs when pnpm processes the crafted data.

The most robust fix pattern is to strictly validate and normalize all alias paths before using them, rejecting traversal components and preventing writes to reserved directories.

Additionally, maintain a clear boundary between tool-owned filesystem areas and user-controlled layout so that internal structures cannot be overwritten via configuration or metadata.

Teams can enforce security-focused design for filesystem operations: treat all external path inputs as untrusted, enforce directory boundaries, and adopt defense-in-depth around package management.

Combine code review policies, automated checks on lockfile changes, and supply-chain scanning tools to detect abnormal alias usage and layout overrides early in the development lifecycle.

Find out what's already
exploitable in your codebase.