Summary
pnpm's handling of config dependency names in env lockfile sections can be abused to perform path traversal when creating symlinks under node_modules/.pnpm-config.
If a malicious repository provides a crafted pnpm-lock.yaml with traversal-shaped names, pnpm may create symlinks pointing outside the intended directory, potentially exposing or overwriting files.
Affected context
This vulnerability arises during pnpm install in projects that consume lockfiles from potentially untrusted or shared repositories.
It affects environments where the env-lockfile document in pnpm-lock.yaml can be modified by an attacker, and where pnpm resolves config dependency names directly into filesystem paths for symlink creation under node_modules/.pnpm-config.
The risk is more pronounced in CI pipelines, multi-user development setups, or when building third-party projects without reviewing their lockfiles.
Exploit preconditions
- Attack surface:
pnpm installexecution that processespnpm-lock.yamlwithenv-lockfileconfiguration. - Required access: Ability to commit or otherwise provide a crafted
pnpm-lock.yamlto the target environment (e.g., via a malicious git repository or artifact). - Trigger point: Running pnpm commands that read the env lockfile configDependencies and create symlinks under
node_modules/.pnpm-config. - Why exploitation is possible: pnpm uses config dependency names directly when constructing symlink paths, without enforcing strict normalization or rejection of traversal sequences, allowing paths to escape the intended directory.
Why this happens
The underlying bug is an improper validation of filesystem paths derived from user-controlled data, corresponding to CWE-22: Path Traversal.
pnpm treats config dependency names in the env lockfile as trusted identifiers and uses them directly to build symlink locations, failing to sanitize or constrain sequences such as ../ that can move outside the target directory.
This pattern reflects a broader class of issues where application-level path construction does not enforce a safe root, allowing attackers to influence where files or symlinks are created relative to the project filesystem.
Potential impact
- Symlink creation that points outside
node_modules/.pnpm-configinto sensitive directories. - Potential overwriting or tampering with files that pnpm or other tools later consume.
- Leakage of filesystem structure or data if symlinks expose unintended paths.
- Interference with build or deployment pipelines by redirecting configuration loads.
General mitigation guidance
Mitigation centers on enforcing strict path handling and distrust of lockfile-sourced identifiers.
Secure patterns include:
- Normalizing and validating all paths derived from configuration names before symlink creation, rejecting traversal segments and absolute paths.
- Constraining symlink targets to a predefined base directory and enforcing checks to ensure constructed paths remain within that boundary.
- Treating lockfiles as untrusted input when they originate from external repositories, applying validation layers or policies before installation.
- Running build and install processes with least filesystem privileges so that even misdirected symlinks cannot affect high-value locations.
How teams detect issues like this
Detection typically involves examination of both code and runtime artifacts:
- Static analysis rules that flag concatenation of configuration-derived strings into filesystem paths without normalization or boundary checks.
- Code review checklists that specifically ask whether any path components come from lockfiles, environment configuration, or other user-controlled sources, and whether those are validated.
- CI policies that scan
pnpm-lock.yamland similar artifacts for suspicious traversal patterns in configuration names before running installs. - File system monitoring in sensitive environments to detect unexpected symlink creation in or near build directories, optionally aided by automated security tooling.

