Repository navigation
fix(security): contain lockfile & manifest package names/slots against path traversal (pnpm + pacquet) - #12872
Conversation
…th traversal The isolated (virtual-store) linker and the Plug'n'Play resolver map both reconstruct a package name from a lockfile `packages` depPath key via `dp.parse`, which does no validation, and join it onto the virtual store to form the package's install directory / PnP `packageLocation`. A crafted `pnpm-lock.yaml` with a traversal name (e.g. `../../../tmp/[email protected]`) could therefore make `pnpm install` import package content to an arbitrary path outside the store. This is the same class of issue as GHSA-fr4h-3cph-29xv, whose fix added the `safeJoinModulesDir` containment helper to the hoisted linker and to `symlinkDependency` but not to the virtual-store linker (the default) or the PnP path. Apply the same guard at both remaining sinks (`lockfileToDepGraph` and `lockfileToPackageRegistry`), so a name that isn't a valid npm package name is rejected before any fetch or filesystem work. Reported as GHSA-c59q-g84q-2gj5. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe PR adds traversal containment checks for lockfile-derived names and virtual-store paths across graph building, PnP mapping, Rust lockfile verification, and install-time package materialization. It also updates related tests, workspace wiring, diagnostics, and release notes. ChangesLockfile path containment
Estimated code review effort: 4 (Complex) | ~60 minutes Possibly related PRs
Suggested labels: Suggested reviewers: ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
PR Summary by Qodofix(security): prevent lockfile path traversal in virtual-store linker and PnP map
AI Description
Diagram
High-Level Assessment
Files changed (11)
|
Code Review by Qodo
Context used✅ Compliance rules (platform):
51 rules 1.
|
PR Code Suggestions ✨Latest suggestions up to 21e5aca Warning
Previous suggestionsSuggestions up to commit e317ca5
Suggestions up to commit 59603c6
Suggestions
|
||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pnpm11/deps/graph-builder/test/lockfileToDepGraph.test.ts`:
- Around line 78-85: The regression test is checking the wrong path, so it does
not verify the actual containment behavior. Update lockfileToDepGraph does not
create a directory outside the virtual store for a traversal name to assert the
computed package directory stays within the virtual store boundary, using the
path derived by lockfileToDepGraph/graphOpts rather than the synthetic escaped
path. If you keep the filesystem assertion, point it at the real escape target
that the code would derive, and keep the ERR_PNPM_INVALID_DEPENDENCY_NAME
expectation in place.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 46309efa-a641-48ba-b0e5-956c41f19d43
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml,!pnpm-lock.yaml
📒 Files selected for processing (10)
.changeset/contain-virtual-store-package-name.mdpnpm11/deps/graph-builder/package.jsonpnpm11/deps/graph-builder/src/lockfileToDepGraph.tspnpm11/deps/graph-builder/test/lockfileToDepGraph.test.tspnpm11/deps/graph-builder/test/tsconfig.jsonpnpm11/deps/graph-builder/tsconfig.jsonpnpm11/lockfile/to-pnp/package.jsonpnpm11/lockfile/to-pnp/src/index.tspnpm11/lockfile/to-pnp/test/index.tspnpm11/lockfile/to-pnp/tsconfig.json
…rsal test The containment regression test computed a synthetic escaped path that did not match what the linker actually derives: `depPathToFilename` folds the depPath key into a single contained store subdir, while the separately-parsed package name is what escapes when joined onto that subdir's node_modules. Reconstruct that exact directory (and assert it genuinely falls outside the virtual store) so the filesystem check verifies the boundary the guard enforces. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Code review by qodo was updated up to the latest commit 1c14ca8 |
PR Code Suggestions ✨Warning
|
|||||||||
…x9-3g3h-c2jv) A crafted pnpm-lock.yaml could carry a dependency alias, snapshot package name, or virtual-store slot with path-traversal segments (e.g. `../../escaped-link`). During `pacquet install` — notably `--frozen-lockfile --trust-lockfile` — those lockfile-controlled strings were joined into filesystem paths and could create symlinks, directories, or bins outside the project / node_modules boundary (CWE-22 / CWE-59). The lockfile verifier already validated dependency aliases, but the check only ran inside the resolution-policy fan-out, which `trustLockfile` disables — and it never covered snapshot package names or packages-less (`link:`-only) lockfiles. - Add `verify_lockfile_dependency_names`, an offline structural check over importer aliases, snapshot package names, and snapshot dependency aliases, and run it in `verify_lockfile_resolutions` before the `packages`-absent short-circuit and the cache lookup. - Call it unconditionally from `InstallFrozenLockfile::run` — before any materialization and the warm-install skip filter — so `trustLockfile` cannot bypass it. - Add `validate_virtual_store_slot_containment` to reject a global-virtual-store slot whose version-derived segment escapes the store root, the one escape name validation alone cannot catch. Rejections surface `ERR_PNPM_INVALID_DEPENDENCY_NAME`. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The isolated-linker name guard (safeJoinModulesDir on the inner package name) does not cover the global-virtual-store slot directory, which is built from the lockfile-controlled package name and version via `formatGlobalVirtualStorePath` — inserting both as raw `/`-separated path segments. A snapshot with a valid name but a traversal `version` (e.g. `version: "../../x"`) escapes the store root before the inner name join runs, so the name guard passes and the package materializes outside the store. Contain the computed slot directory against its store root in `iteratePkgsForVirtualStore`, throwing ERR_PNPM_INVALID_DEPENDENCY_NAME when it escapes. Applied to the legacy slot too (already single-segment via depPathToFilename) as a uniform final guarantee. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Code review by qodo was updated up to the latest commit b44dc7e |
PR Code Suggestions ✨Warning
No code suggestions found for the PR.
|
Micro-Benchmark ResultsLinux |
A tarball, git, or file dependency whose own package.json `name` was a scoped path traversal (e.g. `@x/../../../<path>`) was used verbatim as the directory name for the package inside the virtual store. The isolated linker built its import target with a raw `path.join(modules, name)`, without the `safeJoinModulesDir` containment guard already applied on the hoisted/symlink paths, and the resolve-time name gate only rejected unscoped names. As a result the package's files were extracted outside node_modules to an attacker-chosen absolute path, and could overwrite existing files there, during `pnpm install` — even with `--ignore-scripts`. This is GHSA-vq4v-j7r6-jq4m. Route the resolved package name through `safeJoinModulesDir` at every isolated-linker sink (resolvePeers, the GVS graph builder in deps-resolver, and graph-builder's lockfileToDepGraph), and at the env-installer config-subdep sinks, so a traversal name is rejected with `ERR_PNPM_INVALID_DEPENDENCY_NAME` before any write and legitimate scoped names are unaffected. The Rust pacquet port shared the vulnerability: the unpack target in install_package_from_registry, the snapshot import target in create_virtual_dir_by_snapshot, and the hoist symlink source now go through pacquet's existing `safe_join_modules_dir`. Its env-installer path was already covered by `verify_env_lockfile`. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Code review by qodo was updated up to the latest commit 5ba0e45 |
PR Code Suggestions ✨Warning
No code suggestions found for the PR.
|
Integrated-Benchmark Report (Linux)Commit: Each scenario reports direct installs and pnpr installs. Bencher consumes pacquet@HEAD and pnpr@HEAD. Scenario: Isolated linker: fresh restore, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.121403453,
"stddev": 0.1725690288843961,
"median": 4.0390349578,
"user": 4.35762884,
"system": 2.2970904000000005,
"min": 3.9435398768,
"max": 4.4629389728,
"times": [
4.3290072148,
4.4629389728,
4.2317016218,
4.0280402878,
4.0252888798,
3.9918241918,
4.0500296278,
4.1770258738,
3.9435398768,
3.9746379828
]
},
{
"command": "pacquet@main",
"mean": 4.0175266898999995,
"stddev": 0.11360169848515259,
"median": 3.9955802983,
"user": 4.372096340000001,
"system": 2.3186188000000003,
"min": 3.8780315898000004,
"max": 4.2270221828,
"times": [
3.8780315898000004,
3.8839160258,
4.1287959508,
3.9676891608000004,
4.0348922618,
4.023471435799999,
3.9410834598,
3.9665240328,
4.1238407988,
4.2270221828
]
},
{
"command": "pnpr@HEAD",
"mean": 1.9378362380999998,
"stddev": 0.12528376986556708,
"median": 1.9258303713,
"user": 2.97714254,
"system": 1.9725393,
"min": 1.7448716517999998,
"max": 2.1581971868000003,
"times": [
1.9811688578,
1.8875915468,
1.8360543507999998,
1.9480536188,
1.9036071237999999,
1.7448716517999998,
1.8301786998,
1.9935037598,
2.1581971868000003,
2.0951355848
]
},
{
"command": "pnpr@main",
"mean": 1.9390326137999998,
"stddev": 0.13617612568771517,
"median": 1.9005132757999998,
"user": 3.00690604,
"system": 1.9714416999999997,
"min": 1.7840774888,
"max": 2.1811368238,
"times": [
2.1811368238,
2.0743305468,
1.8417889658,
2.1020024028,
1.8211400058,
1.7840774888,
1.9491454758,
1.8666143947999998,
1.9344121568,
1.8356778768
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.5119168754000001,
"stddev": 0.006577492384443104,
"median": 0.5130737490999999,
"user": 0.40292034,
"system": 0.82499048,
"min": 0.5020408791000001,
"max": 0.5203708451,
"times": [
0.5075253341,
0.5184607391,
0.5108153591,
0.5203708451,
0.5153321391,
0.5159786331,
0.5042571791,
0.5181123691,
0.5062752771,
0.5020408791000001
]
},
{
"command": "pacquet@main",
"mean": 0.4979749481000001,
"stddev": 0.007614156684202578,
"median": 0.4960513521,
"user": 0.39959353999999997,
"system": 0.81392968,
"min": 0.4895423131,
"max": 0.5117892581,
"times": [
0.5024468831,
0.49088735910000003,
0.5092070551,
0.49136954110000003,
0.4895423131,
0.4954970771,
0.4945423761,
0.4966056271,
0.4978619911,
0.5117892581
]
},
{
"command": "pnpr@HEAD",
"mean": 0.5980122017,
"stddev": 0.10081840159856847,
"median": 0.5546206516000001,
"user": 0.4105380399999999,
"system": 0.85703788,
"min": 0.5224387071000001,
"max": 0.7880812261000001,
"times": [
0.5481953551000001,
0.5340775921,
0.5532968141,
0.5224387071000001,
0.7865716671,
0.7880812261000001,
0.5711273801,
0.5559444891,
0.5511055531,
0.5692832331000001
]
},
{
"command": "pnpr@main",
"mean": 0.5566588962000001,
"stddev": 0.010634556517302177,
"median": 0.5564296981000001,
"user": 0.4168607399999999,
"system": 0.8566713800000001,
"min": 0.5411131311,
"max": 0.5698592471,
"times": [
0.5505901681,
0.5535348581,
0.5656098781000001,
0.5441634181,
0.5411131311,
0.5698592471,
0.5478613221,
0.5593245381,
0.5650815771000001,
0.5694508241
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.26163732888,
"stddev": 0.034667308479452055,
"median": 4.257242723680001,
"user": 4.30585756,
"system": 2.25240916,
"min": 4.20816756468,
"max": 4.33049987868,
"times": [
4.33049987868,
4.259058967680001,
4.22551433868,
4.29203804668,
4.277047591680001,
4.20816756468,
4.2421325026800005,
4.27585269468,
4.2554264796800005,
4.250635223680001
]
},
{
"command": "pacquet@main",
"mean": 4.266955831980001,
"stddev": 0.04194053015409888,
"median": 4.253132000680001,
"user": 4.268454459999999,
"system": 2.25858506,
"min": 4.19098230068,
"max": 4.33488361968,
"times": [
4.244629557680001,
4.2511307266800005,
4.30043242368,
4.305859932680001,
4.25097388168,
4.23891067968,
4.25513327468,
4.33488361968,
4.296621922680001,
4.19098230068
]
},
{
"command": "pnpr@HEAD",
"mean": 2.0432067593799994,
"stddev": 0.17050266733507385,
"median": 1.99761015668,
"user": 2.7922448600000003,
"system": 1.8971653599999996,
"min": 1.86780594768,
"max": 2.27019403768,
"times": [
2.27019403768,
2.11894858568,
1.8756648086799999,
1.9084547996799999,
1.86780594768,
1.8749834566799999,
2.2604073796799997,
1.98050093268,
2.01471938068,
2.26038826468
]
},
{
"command": "pnpr@main",
"mean": 2.02940153518,
"stddev": 0.1062689006032878,
"median": 2.00008614918,
"user": 2.7868064599999993,
"system": 1.90803696,
"min": 1.86533871968,
"max": 2.25838339268,
"times": [
1.99469901368,
1.86533871968,
2.06177817968,
1.98288681368,
2.00547328468,
2.11707848968,
2.25838339268,
1.9878628166799999,
2.07006537468,
1.95044926668
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.2886906798200002,
"stddev": 0.01885679787975631,
"median": 1.28951589442,
"user": 1.4548180599999998,
"system": 1.08640942,
"min": 1.25654846242,
"max": 1.32363349342,
"times": [
1.2825432624200002,
1.27589100442,
1.3055845804200001,
1.28994934442,
1.29297916642,
1.29977974942,
1.27091529042,
1.32363349342,
1.28908244442,
1.25654846242
]
},
{
"command": "pacquet@main",
"mean": 1.3133058011199998,
"stddev": 0.04995643196761544,
"median": 1.30110624292,
"user": 1.46939096,
"system": 1.0930548199999996,
"min": 1.28101773142,
"max": 1.45397014342,
"times": [
1.30592850342,
1.29722853742,
1.29268857942,
1.29364415542,
1.30381279742,
1.30250669342,
1.45397014342,
1.30255507742,
1.2997057924200002,
1.28101773142
]
},
{
"command": "pnpr@HEAD",
"mean": 0.53707631542,
"stddev": 0.02248175827388987,
"median": 0.53139639792,
"user": 0.3599643599999999,
"system": 0.79816442,
"min": 0.52223458942,
"max": 0.60010140542,
"times": [
0.53484897142,
0.53151101842,
0.52913752742,
0.52223458942,
0.5261914894199999,
0.53230418542,
0.52824937242,
0.53490281742,
0.60010140542,
0.5312817774199999
]
},
{
"command": "pnpr@main",
"mean": 0.52521812572,
"stddev": 0.0047183103242666195,
"median": 0.52624205392,
"user": 0.35425576000000003,
"system": 0.79669492,
"min": 0.51706965242,
"max": 0.53025934742,
"times": [
0.52930729142,
0.53025934742,
0.52968713342,
0.52477533742,
0.52728090242,
0.51706965242,
0.52259002442,
0.52520320542,
0.52803885542,
0.51796950742
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 3.09732791624,
"stddev": 0.049267354387338994,
"median": 3.08214961874,
"user": 2.0289960799999998,
"system": 1.32726914,
"min": 3.02006498274,
"max": 3.18785209074,
"times": [
3.10745483774,
3.07986861074,
3.07314115374,
3.02006498274,
3.08443062674,
3.07157938674,
3.06484648674,
3.16214086174,
3.18785209074,
3.1219001247400002
]
},
{
"command": "pacquet@main",
"mean": 3.0609837877400006,
"stddev": 0.024970660333319634,
"median": 3.06508907174,
"user": 1.9945824799999996,
"system": 1.30450524,
"min": 3.00575048874,
"max": 3.09450417074,
"times": [
3.07995666774,
3.03989243574,
3.09450417074,
3.00575048874,
3.06353473474,
3.04683651574,
3.07130107874,
3.06543927874,
3.07788364174,
3.0647388647400002
]
},
{
"command": "pnpr@HEAD",
"mean": 0.54069005964,
"stddev": 0.0071848260649293675,
"median": 0.5398425207400002,
"user": 0.37534108,
"system": 0.8105960399999999,
"min": 0.5292491917400001,
"max": 0.55583865974,
"times": [
0.5403058327400001,
0.54065997174,
0.5482483127400001,
0.53752749574,
0.5361009987400001,
0.5423020567400001,
0.5292491917400001,
0.55583865974,
0.5372888677400001,
0.5393792087400001
]
},
{
"command": "pnpr@main",
"mean": 0.5440282005399999,
"stddev": 0.011268449838782819,
"median": 0.54325760974,
"user": 0.36271857999999996,
"system": 0.8076234399999999,
"min": 0.53273728874,
"max": 0.5691519787400001,
"times": [
0.53537457974,
0.53327087474,
0.54326054574,
0.53273728874,
0.5691519787400001,
0.54325467374,
0.5352331897400001,
0.5512727847400001,
0.5518916367400001,
0.5448344527400001
]
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.7205192172000001,
"stddev": 0.012763158687024276,
"median": 0.7172548032,
"user": 0.70850254,
"system": 0.10897766,
"min": 0.6982927932,
"max": 0.7400878092000001,
"times": [
0.7087776402,
0.7290609252,
0.7164917392,
0.6982927932,
0.7139288922,
0.7163934022,
0.7400878092000001,
0.7358465372,
0.7180178672,
0.7282945662
]
},
{
"command": "pacquet@main",
"mean": 0.7222791092,
"stddev": 0.004973429513426707,
"median": 0.7238778502000001,
"user": 0.70418144,
"system": 0.11456446000000002,
"min": 0.7107868552000001,
"max": 0.7268161862,
"times": [
0.7235169942,
0.7178158002,
0.7268161862,
0.7236880932,
0.7258692572000001,
0.7192209142,
0.7258721852,
0.7240676072,
0.7107868552000001,
0.7251371992
]
},
{
"command": "pnpr@HEAD",
"mean": 0.10460991281538462,
"stddev": 0.001024861088782478,
"median": 0.10458994370000001,
"user": 0.02839114,
"system": 0.013240706153846152,
"min": 0.1030341422,
"max": 0.1086426162,
"times": [
0.1047412372,
0.1040364792,
0.1053998322,
0.10493135020000001,
0.1042048612,
0.1044759452,
0.10440395620000001,
0.1048116292,
0.1030341422,
0.1041387042,
0.1037043772,
0.10527674620000001,
0.10405352720000001,
0.10470394220000001,
0.1033724542,
0.10482391020000001,
0.1042963442,
0.1047863842,
0.1036609492,
0.1054330962,
0.1047909312,
0.1048149772,
0.1086426162,
0.1037967712,
0.1051502502,
0.10437231920000001
]
},
{
"command": "pnpr@main",
"mean": 0.104578108162963,
"stddev": 0.0005459073477616083,
"median": 0.1046866802,
"user": 0.028319436296296293,
"system": 0.013804452592592588,
"min": 0.1028983262,
"max": 0.1057773882,
"times": [
0.1028983262,
0.1047585862,
0.1047215202,
0.1047570792,
0.1044898612,
0.1041589512,
0.1047513152,
0.1049130942,
0.1049039922,
0.1042575772,
0.10454126820000001,
0.1046934962,
0.1057773882,
0.1054285102,
0.10490693820000001,
0.1039422962,
0.10453204320000001,
0.1040558002,
0.1046184482,
0.1051096982,
0.1043404592,
0.10432024320000001,
0.1048028882,
0.1046866802,
0.10374082720000001,
0.1045128312,
0.10498880120000001
]
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 6.89895112378,
"stddev": 0.09604422550059201,
"median": 6.89011649428,
"user": 4.59114814,
"system": 2.5305112800000003,
"min": 6.79923952078,
"max": 7.11804591978,
"times": [
6.88855714178,
6.79923952078,
6.845638774779999,
6.91002897978,
6.89167584678,
6.84722812378,
6.99583304278,
6.89360878778,
6.79965509978,
7.11804591978
]
},
{
"command": "pacquet@main",
"mean": 6.9181110207800005,
"stddev": 0.09120861932777319,
"median": 6.90626751728,
"user": 4.66111264,
"system": 2.54031298,
"min": 6.74762528978,
"max": 7.08295503678,
"times": [
6.84761602578,
6.89272831278,
6.91450437478,
7.08295503678,
6.74762528978,
6.89803065978,
6.882240600779999,
6.96748276678,
6.93763967878,
7.01028746178
]
},
{
"command": "pnpr@HEAD",
"mean": 4.94274949678,
"stddev": 0.12626017225403485,
"median": 4.92136553028,
"user": 3.16554424,
"system": 2.2136630800000003,
"min": 4.82572906378,
"max": 5.25056965478,
"times": [
4.91346976178,
4.92926129878,
4.93375218778,
5.01759308078,
4.85833500478,
4.82830694578,
4.99836655778,
5.25056965478,
4.82572906378,
4.87211141178
]
},
{
"command": "pnpr@main",
"mean": 4.8979047933799995,
"stddev": 0.07724356715949693,
"median": 4.886623356279999,
"user": 3.14732244,
"system": 2.21467588,
"min": 4.75401876078,
"max": 5.04490981878,
"times": [
4.75401876078,
4.90761012978,
4.8756547777799994,
4.87354421578,
4.83988364978,
4.95613842078,
4.89105514878,
4.88219156378,
4.95404144778,
5.04490981878
]
}
]
} |
|
| Branch | pr/12872 |
| Testbed | pnpr |
⚠️ WARNING: No Threshold found!Without a Threshold, no Alerts will ever be generated.
Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the--ci-only-thresholdsflag.
Click to view all benchmark results
| Benchmark | Latency | milliseconds (ms) |
|---|---|---|
| isolated-linker.fresh-install.cold-cache.cold-store | 📈 view plot | 2,043.21 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 540.69 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 537.08 ms |
| isolated-linker.fresh-resolve.hot-cache.offline | 📈 view plot | 104.61 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 1,937.84 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr | 📈 view plot | 4,942.75 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 598.01 ms |
…v10 (#12890) Backports the TypeScript portion of 51300fd (#12872) to release/10. Two advisories: - GHSA-c59q-g84q-2gj5: lockfile depPath name -> isolated linker + PnP. - GHSA-vq4v-j7r6-jq4m: dependency manifest `name` from the fetched tarball (e.g. @x/../../../path) -> resolver/linker. Apply safeJoinModulesDir at lockfileToDepGraph (deps/graph-builder) and the PnP packageLocation (lockfile-to-pnp); validate manifest names in resolve-dependencies (extendGraph + resolvePeers); contain the global-virtual-store slot dir by rejecting a traversal version segment in iterateHashedGraphNodes (calc-dep-state), the single point every GVS slot path funnels through. The pacquet and env-installer changes from the original commit do not apply to v10 (no pacquet stack; installConfigDeps has no GVS subdep installation and config-dependency names are already validated by assertValidConfigDepName from #12504). All rejections surface ERR_PNPM_INVALID_DEPENDENCY_NAME. Co-authored-by: Claude Fable 5 <[email protected]>
…rtual-store slot (#13383) Installing a `file:` directory dependency with the global virtual store enabled crashed the headless install: TypeError: Cannot read properties of undefined (reading 'split') at assertNoPathTraversal at formatGlobalVirtualStorePath at calcGraphNodeHash pnpm omits `version` from a directory snapshot, so `nameVerFromPkgSnapshot` hands the hasher `undefined` and the traversal guard added in #12872 dereferences it. Directory snapshots now use a fixed `directory` segment in place of the version. That also settles a disagreement between the two install paths: the resolver reads the version off the manifest and the headless install off the lockfile, where there is none, so the same package landed on two different slots. The crash hid a worse defect. A directory resolution is the one resolution with no integrity — it is a path relative to the lockfile — so `file:dep` hashed identically in every project that depended on a directory of that name, and all of them linked to whichever project installed first. Since the source directory is mutable, pnpm re-imports it on every install, so the projects went on overwriting each other's copy. The lockfile directory now joins the hash payload for directory resolutions, giving each project its own slot; every other resolution hashes exactly as before. `iterateHashedGraphNodes` takes an options object now — it was up to five positional parameters before this change added a sixth. Closes #13335
…rtual-store slot (pnpm#13383) Installing a `file:` directory dependency with the global virtual store enabled crashed the headless install: TypeError: Cannot read properties of undefined (reading 'split') at assertNoPathTraversal at formatGlobalVirtualStorePath at calcGraphNodeHash pnpm omits `version` from a directory snapshot, so `nameVerFromPkgSnapshot` hands the hasher `undefined` and the traversal guard added in pnpm#12872 dereferences it. Directory snapshots now use a fixed `directory` segment in place of the version. That also settles a disagreement between the two install paths: the resolver reads the version off the manifest and the headless install off the lockfile, where there is none, so the same package landed on two different slots. The crash hid a worse defect. A directory resolution is the one resolution with no integrity — it is a path relative to the lockfile — so `file:dep` hashed identically in every project that depended on a directory of that name, and all of them linked to whichever project installed first. Since the source directory is mutable, pnpm re-imports it on every install, so the projects went on overwriting each other's copy. The lockfile directory now joins the hash payload for directory resolutions, giving each project its own slot; every other resolution hashes exactly as before. `iterateHashedGraphNodes` takes an options object now — it was up to five positional parameters before this change added a sixth. Closes pnpm#13335
Summary
Fixes three related path-traversal advisories where a crafted
pnpm-lock.yamlor a malicious dependency's own manifest could makepnpm install/pacquet installwrite package content, symlinks, or bins outsidenode_modules/ the virtual store — in some cases even with--ignore-scriptsor--frozen-lockfile --trust-lockfile. All are the same class: a lockfile- or manifest-controlled package name/version is joined into a filesystem path without validation. Rejections surfaceERR_PNPM_INVALID_DEPENDENCY_NAME.name(from the fetched tarball, e.g.@x/../../../path) → resolver/linkerThis consolidates what were three separate PRs into one, per the two-stacks-one-PR parity rule.
What's included
TypeScript
safeJoinModulesDir(modules, pkgName)at the isolated linker (deps/graph-builder/lockfileToDepGraph.ts) and the PnPpackageLocation(lockfile/to-pnp), matching the guard GHSA-fr4h-3cph-29xv already added to the hoisted linker. (c59q-g84q-2gj5)installing/deps-resolver(+resolvePeers) andinstalling/env-installer(config deps). (vq4v-j7r6-jq4m)node_modules/<name>join but not the GVS slot dir itself, whichformatGlobalVirtualStorePathbuilds from raw name and version.iteratePkgsForVirtualStorenow contains each computed slot dir against its store root, so a valid name with a traversalversion(e.g. a snapshotversion: "../../x") is rejected too.pacquet
verify_lockfile_dependency_names— an offline structural check over importer aliases, snapshot package names, and snapshot dependency aliases — run unconditionally inInstallFrozenLockfile::runbefore any materialization and before the warm-install skip filter, sotrustLockfile(which disables the resolution-policy fan-out) can't bypass it. Plusvalidate_virtual_store_slot_containmentfor the GVS version-segment escape. (2rx9-3g3h-c2jv)safe_join_modules_dirguards on the manifest-name / fresh-install paths:create_symlink_layout,create_virtual_dir_by_snapshot,hoist,install_package_from_registry, and the resolver (resolve_dependency_tree). (vq4v-j7r6-jq4m)The two pacquet strategies are complementary: the verifier rejects a poisoned lockfile up front (and covers the
trustLockfile/ snapshot-key / GVS-version cases), while the sink guards also catch manifest names and the fresh-resolve path that never touch the lockfile.Reproduced end-to-end for the pacquet lockfile case: before,
pacquet install --frozen-lockfile --trust-lockfileon a../../escaped-linkdependency created a symlink outside the project; after, it aborts withERR_PNPM_INVALID_DEPENDENCY_NAMEand writes nothing outside the project.Squash Commit Body
Checklist
pacquet/port.@pnpm/deps.graph-builder,@pnpm/lockfile.to-pnp,@pnpm/installing.deps-resolver,@pnpm/installing.env-installer,pnpm). pacquet is Rust and not changeset-versioned.deps/graph-builder(7, incl. the GVS version-escape case),installing/deps-resolver(126),installing/env-installer(34), and thedeps-installerfromTarballmanifest-traversal e2e (4). pacquet:pacquet-package-manager(656) +pacquet-resolving-deps-resolver(167) +pacquet-lockfile-verification(47);cargo clippy --deny warnings+cargo fmtclean.Written by an agent (Claude Code, claude-opus-4-8).
Summary by CodeRabbit