Listen to this Post
In pnpm v10+, a security feature was introduced to disable lifecycle scripts (like postinstall) for dependencies by default. This is enforced via the `onlyBuiltDependencies = []` setting, which blocks script execution during the BUILD phase. However, this protection is inconsistently applied. Git-hosted dependencies (e.g., from GitHub, GitLab) are processed in a separate FETCH phase. During this phase, the `preparePackage()` function is called, which checks for the `ignoreScripts` flag but does not consult the `onlyBuiltDependencies` allowlist. Since `ignoreScripts` defaults to false, the lifecycle scripts prepare, prepublish, and `prepack` within a git dependency’s `package.json` will execute automatically during a pnpm install. This creates a bypass, allowing a malicious git dependency to run arbitrary code on a victim’s system without warning, even when the user believes all dependency scripts are disabled.
Platform: pnpm
Version: v10+
Vulnerability: Git script bypass
Severity: High
date: 2026-01-08
Prediction: Patch date unspecified
What Undercode Say:
Analytics:
`cd poc`
`chmod +x run-poc.sh`
`./run-poc.sh`
`cat /tmp/pnpm-vuln-poc-marker.txt`
{
"scripts": {
"prepare": "node -e \"require('fs').writeFileSync('/tmp/pwned.txt', 'RCE!')\""
}
}
`pnpm install`
How Exploit:
git+https://github.com/attacker/malicious.git`github:attacker/malicious
<h2 style="color: blue;"></h2>gitlab:attacker/malicious
<h2 style="color: blue;"></h2>bitbucket:attacker/malicious
<h2 style="color: blue;"></h2>git+ssh://[email protected]/…
<h2 style="color: blue;"></h2>git+file:///path/to/repo
<h2 style="color: blue;"></h2>–ignore-scripts`.
<h2 style="color: blue;">Create malicious package.</h2>
<h2 style="color: blue;">Add prepare script.</h2>
<h2 style="color: blue;">Host on git.</h2>
<h2 style="color: blue;">Victim installs dependency.</h2>
<h2 style="color: blue;">Protection from this CVE</h2>
<h2 style="color: blue;">Set `onlyBuiltDependencies` explicitly.</h2>
<h2 style="color: blue;">Audit all git dependencies.</h2>
<h2 style="color: blue;">Avoid untrusted git sources.</h2>
<h2 style="color: blue;">Pin dependencies to trusted commits.</h2>
<h2 style="color: blue;">Use `pnpm audit` and
Impact
Remote Code Execution.
Supply chain compromise.
Credential and secret exfiltration.
Backdoor implantation.
CI/CD pipeline attack.
🎯Let’s Practice Exploiting & Learn Patching For Free:
Sources:
Reported By: github.com
Extra Source Hub:
Undercode

