GHSA-xpqm-wm3m-f34h

Suggest an improvement
Source
https://github.com/advisories/GHSA-xpqm-wm3m-f34h
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/01/GHSA-xpqm-wm3m-f34h/GHSA-xpqm-wm3m-f34h.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-xpqm-wm3m-f34h
Aliases
Downstream
Published
2026-01-26T21:02:39Z
Modified
2026-02-03T03:06:15.209571Z
Severity
  • 6.5 (Medium) CVSS_V3 - CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N CVSS Calculator
Summary
pnpm scoped bin name Path Traversal allows arbitrary file creation outside node_modules/.bin
Details

Summary

A path traversal vulnerability in pnpm's bin linking allows malicious npm packages to create executable shims or symlinks outside of node_modules/.bin. Bin names starting with @ bypass validation, and after scope normalization, path traversal sequences like ../../ remain intact.

Details

The vulnerability exists in the bin name validation and normalization logic:

1. Validation Bypass (pkg-manager/package-bins/src/index.ts)

The filter allows any bin name starting with @ to pass through without validation:

.filter((commandName) =>
  encodeURIComponent(commandName) === commandName ||
  commandName === '' ||
  commandName[0] === '@'  // <-- Bypasses validation
)

2. Incomplete Normalization (pkg-manager/package-bins/src/index.ts)

function normalizeBinName (name: string): string {
  return name[0] === '@' ? name.slice(name.indexOf('/') + 1) : name
}
// Input:  @scope/../../evil
// Output: ../../evil  <-- Path traversal preserved!

3. Exploitation (pkg-manager/link-bins/src/index.ts:288)

The normalized name is used directly in path.join() without validation.

PoC

  1. Create a malicious package:

    {
      "name": "malicious-pkg",
      "version": "1.0.0",
      "bin": {
        "@scope/../../.npmrc": "./malicious.js"
      }
    }
    
  2. Install the package:

    pnpm add /path/to/malicious-pkg
    
  3. Observe .npmrc created in project root (outside node_modules/.bin).

Impact

  • All pnpm users who install npm packages
  • CI/CD pipelines using pnpm
  • Can overwrite config files, scripts, or other sensitive files

Verified on pnpm main @ commit 5a0ed1d45.

Database specific
{
    "github_reviewed_at": "2026-01-26T21:02:39Z",
    "nvd_published_at": "2026-01-26T22:15:56Z",
    "cwe_ids": [
        "CWE-23"
    ],
    "severity": "MODERATE",
    "github_reviewed": true
}
References

Affected packages

npm / pnpm

Package

Affected ranges

Type
SEMVER
Events
Introduced
0Unknown introduced version / All previous versions are affected
Fixed
10.28.1

Database specific

source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/01/GHSA-xpqm-wm3m-f34h/GHSA-xpqm-wm3m-f34h.json"