6.7medium
pnpm has Path Traversal via arbitrary file permission modification
- Severity
- 6.7medium CVSS:4.0 by GitHub_M
- Exploit likelihood
- 0.27% (higher than 21% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-v253-rj99-jwpq
Description
pnpm is a package manager. Prior to version 10.28.2, when pnpm processes a package's `directories.bin` field, it uses `path.join()` without validating the result stays within the package root. A malicious npm package can specify `"directories": {"bin": "../../../../tmp"}` to escape the package directory, causing pnpm to chmod 755 files at arbitrary locations. This issue only affects Unix/Linux/macOS. Windows is not affected (`fixBin` gated by `EXECUTABLE_SHEBANG_SUPPORTED`). Version 10.28.2 contains a patch.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| pnpm pnpm | < 10.28.2, before 10.28.2 | CVE List, NVD |
| pnpm (npm) | before 10.28.2 | GitHub Advisory Database |
All scores
| GitHub_M | 6.7medium CVSS:4.0 | CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:A/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N |
| GitHub | medium CVSS:4.0 | CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:A/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N |
| NVD | 5.5medium CVSS:3.1 | CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N |
Classification
What each source says
CVE List
pnpm is a package manager. Prior to version 10.28.2, when pnpm processes a package's `directories.bin` field, it uses `path.join()` without validating the result stays within the package root. A malicious npm package can specify `"directories": {"bin": "../../../../tmp"}` to escape the package directory, causing pnpm to chmod 755 files at arbitrary locations. This issue only affects Unix/Linux/macOS. Windows is not affected (`fixBin` gated by `EXECUTABLE_SHEBANG_SUPPORTED`). Version 10.28.2 contains a patch.
GitHub Advisory Database
Summary
When pnpm processes a package's directories.bin field, it uses path.join() without validating the result stays within the package root. A malicious npm package can specify "directories": {"bin": "../../../../tmp"} to escape the package directory, causing pnpm to chmod 755 files at arbitrary locations.
Note: Only affects Unix/Linux/macOS. Windows is not affected (fixBin gated by EXECUTABLE_SHEBANG_SUPPORTED).
Details
Vulnerable code in pkg-manager/package-bins/src/index.ts:15-21:
if (manifest.directories?.bin) {
const binDir = path.join(pkgPath, manifest.directories.bin) // NO VALIDATION
const files = await findFiles(binDir)
// ... files outside package returned, then chmod 755'd
}
The bin field IS protected with isSubdir() at line 53, but directories.bin lacks this check.
PoC
# Create malicious package
mkdir /tmp/malicious-pkg
echo '{"name":"malicious","version":"1.0.0","directories":{"bin":"../../../../tmp/target"}}' > /tmp/malicious-pkg/package.json
# Create sensitive file
mkdir -p /tmp/target
echo "secret" > /tmp/target/secret.sh
chmod 600 /tmp/target/secret.sh # Private
# Install
pnpm add file:/tmp/malicious-pkg
# Check permissions
ls -la /tmp/target/secret.sh # Now 755 (world-readable)
Impact
- Supply-chain attack via npm packages
- File permissions changed from 600 to 755 (world-readable)
- Affects non-dotfiles in predictable paths (dotfiles excluded by tinyglobby default)
Suggested Fix
Add isSubdir validation for directories.bin paths in pkg-manager/package-bins/src/index.ts, matching the existing validation in commandsFromBin():
if (manifest.directories?.bin) {
const binDir = path.join(pkgPath, manifest.directories.bin)
if (!isSubdir(pkgPath, binDir)) {
return [] // Reject paths outside package
}
// ...
}
NVD (es)
pnpm es un gestor de paquetes. Antes de la versión 10.28.2, cuando pnpm procesa el campo 'directories.bin' de un paquete, utiliza 'path.join()' sin validar que el resultado permanezca dentro de la raíz del paquete. Un paquete npm malicioso puede especificar "directories": {"bin": "../../../../tmp"} para escapar del directorio del paquete, haciendo que pnpm aplique chmod 755 a archivos en ubicaciones arbitrarias. Este problema solo afecta a Unix/Linux/macOS. Windows no se ve afectado ('fixBin' está restringido por 'EXECUTABLE_SHEBANG_SUPPORTED'). La versión 10.28.2 contiene un parche.
References
| https://github.com/pnpm/pnpm/security/advisories/GHSA-v253-rj99-jwpq | exploit, vendor-advisory, web | |
| https://github.com/pnpm/pnpm/commit/17432ad5bbed5c2e77255ca6d56a1449bbcfd943 | patch, web | |
| https://github.com/pnpm/pnpm/releases/tag/v10.28.2 | release-notes, web | |
| https://github.com/pnpm/pnpm | package | |
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2026-24131 changed 2026-01-27 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-v253-rj99-jwpq changed 2026-02-03 | CC-BY-4.0 |
| NVD | CVE-2026-24131 changed 2026-06-17 | Public domain |