Executive brief
pnpm is a package manager used by developers to install and manage JavaScript dependencies. A flaw in pnpm's package resolution allows an attacker to craft a malicious tarball with a specially crafted package name that can write or overwrite arbitrary files outside the project directory (e.g., shell configuration files, Git hooks, or other packages' code) when a developer runs `pnpm install`, even with safety flags enabled. This could lead to code execution and compromise of the developer's machine or build pipeline.
Technical details
The vulnerability is a path traversal / directory escape (CWE-22) in pnpm's dependency resolution logic. The isolated-linker import target is constructed using `path.join(modules, <resolved name>)` in three locations (`resolvePeers.ts:706`, `index.ts:614`, `lockfileToDepGraph.ts:233`) without the `safeJoinModulesDir` guard that protects other path-construction sites. A malicious tarball's `package.json` can declare a scoped name containing path traversal sequences (e.g., `@x/../../…/<abs path>`), bypassing the validate-name check that only rejects unscoped names with `/`. When pnpm installs this dependency, the traversal escapes the `node_modules/.pnpm/<id>/node_modules/` directory boundary and reaches an attacker-specified absolute path, enabling overwrite of arbitrary files. The attack succeeds during `pnpm install --ignore-scripts`, defeating that mitigation. An attacker controls destination, filenames, and file contents, enabling code execution via shell initialization files, Git hooks, or other packages' code. Patches apply `safeJoinModulesDir` to the affected join calls and enforce `validate-npm-package-name` on resolved manifest names to reject traversal attempts before any write.
Affected products
- pnpm pnpm < 10.34.5, >= 11.0.0 < 11.11.0
Timeline
- 2026-08-02: disclosed: GitHub Security Advisory published
- 2026-07-09: patched: Patch commits 51300fd and 78e29fe merged
- 2026-09-02: advisory: GHSA-vq4v-j7r6-jq4m formally published