Know every vulnerabilitybefore it knows you.
DevGuard continuously monitors your dependencies and alerts you when CVEs like this one affect your stack — with real-time threat intelligence built for developers.
GHSA-xpqm-wm3m-f34h
No affected components available
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
- Create a malicious package:
{
"name": "malicious-pkg",
"version": "1.0.0",
"bin": {
"@scope/../../.npmrc": "./malicious.js"
}
}
- Install the package:
pnpm add /path/to/malicious-pkg
- Observe
.npmrccreated 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.
The vulnerability can be exploited over the network without needing physical access. It is easy for an attacker to exploit this vulnerability. An attacker does not need any special privileges or access rights. The attacker needs the user to perform some action, like clicking a link. The impact is confined to the system where the vulnerability exists. There is a high impact on the integrity of the data.
Exploitation attempts have been detected. Elevated vigilance and prompt remediation are advised.
The exploit probability is very low. The vulnerability is unlikely to be exploited in the next 30 days.
We did not find any exploit available. Neither in GitHub repositories nor in the Exploit-Database.
Browse More
Continuously monitor your dependencies and get alerted when vulnerabilities like this one affect your stack.
Checkout DevGuard