Repository navigation
Conversation
…th name GHSA-c59q-g84q-2gj5 reported that the isolated linker joined the lockfile-derived package name onto the virtual store without validation. That site, and the PnP `packageLocation`, were already contained by 51300fd; the one recommended site that commit missed is the rebuild phase, which resolves its package root the same way. `_rebuild` reads the current lockfile from `node_modules` and rebuilds `pkgRoot` as `path.join(pkgModulesDir(depPath), pkgInfo.name)`, where `pkgInfo.name` comes from `dp.parse` of the depPath key. `dp.parse` is a raw substring and validates nothing, so a `../../../[email protected]` key pointed the lifecycle-script runner and the post-build bin linking at a directory outside the virtual store. The dep graph that phase walks comes from `@pnpm/deps.graph-hasher`, which deliberately defers the name check to its sink -- and this sink had none. Route both joins through `safeJoinModulesDir`, so a crafted name fails with ERR_PNPM_INVALID_DEPENDENCY_NAME before any script runs. Reachability is narrower than the reported install path: the poisoned lockfile has to already be in `node_modules`, which means a shipped or restored `node_modules` rather than a committed `pnpm-lock.yaml`. No pacquet change: its `rebuild` drives the frozen-install pipeline, which runs `verify_lockfile_dependency_names` unconditionally over snapshot package names, and it reads the project lockfile rather than a copy in `node_modules`, so it has no equivalent unguarded sink.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
ChangesRebuild path safety
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested labels: Suggested reviewers: ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. 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 rebuild depPath traversal by validating lockfile-derived package roots
AI Description
Diagram
High-Level Assessment
Files changed (6)
|
Code Review by Qodo
Context used✅ Compliance rules (platform):
18 rules 1. Windows traversal untested
|
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 @.changeset/rebuild-depath-name-traversal.md:
- Line 6: Add a concise sentence to the changeset explaining that the pacquet
rebuild path already validates dependency names through the frozen-install
pipeline, so no pacquet change is required.
In `@pnpm11/building/commands/test/build/index.ts`:
- Around line 608-623: Update the final filesystem assertion in the rebuild test
around rebuild.handler to check the vulnerable join destination under the
project’s node_modules directory, specifically the resolved path for
node_modules/escaped, rather than path.resolve('../../../escaped') from the
project root. Preserve the existing ERR_PNPM_INVALID_DEPENDENCY_NAME rejection
assertion and verify that no outside directory is created.
🪄 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: c91b64b6-e18b-4e45-b232-fa3ae440e9ad
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml,!pnpm-lock.yaml
📒 Files selected for processing (5)
.changeset/rebuild-depath-name-traversal.mdpnpm11/building/after-install/package.jsonpnpm11/building/after-install/src/index.tspnpm11/building/after-install/tsconfig.jsonpnpm11/building/commands/test/build/index.ts
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Reviews (2): Last reviewed commit: "test(building): approve the escaped buil..." | Re-trigger Greptile |
Integrated-Benchmark Report (Linux)Commit: Regular scenarios report direct and pnpr installs. The peer-heavy resolver scenario compares current Rust, main Rust, and TypeScript pnpm. Bencher consumes pacquet@HEAD and pnpr@HEAD. The tables below show mean ± σ; Bencher thresholds on the minimum latency, which is far less perturbed by shared-runner contention (noise only adds time). Scenario: Isolated linker: fresh restore, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.4962731390000004,
"stddev": 0.16558746303884403,
"median": 2.4288841704,
"user": 1.6411454799999998,
"system": 1.3260083200000001,
"min": 2.3469593414000003,
"max": 2.7547645024,
"times": [
2.3550418534,
2.4373510654,
2.4622379514,
2.3682987004,
2.3469593414000003,
2.4204172754,
2.7547645024,
2.3833582354,
2.7348767314,
2.6994257334
]
},
{
"command": "pacquet@main",
"mean": 2.4730618972,
"stddev": 0.14617996795274274,
"median": 2.4128399894,
"user": 1.6564532799999998,
"system": 1.2848638199999995,
"min": 2.3514898914,
"max": 2.7797134194,
"times": [
2.7797134194,
2.5677816104,
2.3698715934,
2.6529330604,
2.3746286074,
2.3822421554,
2.3639712874,
2.3514898914,
2.4445495234,
2.4434378234
]
},
{
"command": "pnpr@HEAD",
"mean": 1.5240783710000003,
"stddev": 0.10778020727423958,
"median": 1.4963390234,
"user": 1.18661278,
"system": 1.1327866199999999,
"min": 1.3945823654,
"max": 1.7444269484000001,
"times": [
1.4686057224,
1.4035671624000001,
1.5118015584000002,
1.4556276414,
1.7444269484000001,
1.3945823654,
1.6086745304,
1.5895842524,
1.4808764884,
1.5830370404
]
},
{
"command": "pnpr@main",
"mean": 1.5094600406,
"stddev": 0.1657694099532189,
"median": 1.4823795784000002,
"user": 1.20392178,
"system": 1.1463687199999997,
"min": 1.3502856964,
"max": 1.7981915404,
"times": [
1.4888619464000001,
1.3580744974,
1.7981915404,
1.4758972104,
1.5319574194,
1.3751046874,
1.6076843974,
1.3518818504,
1.3502856964,
1.7566611604000002
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.25681311304000004,
"stddev": 0.005914373661810641,
"median": 0.25508277464,
"user": 0.20679558,
"system": 0.51424892,
"min": 0.25138581764,
"max": 0.26557709964,
"times": [
0.25579428764,
0.25221503164,
0.25155437164,
0.25592084664,
0.26414521664,
0.26536345364,
0.25138581764,
0.26557709964,
0.25437126164,
0.25180374364
]
},
{
"command": "pacquet@main",
"mean": 0.25544693244,
"stddev": 0.006410969905257915,
"median": 0.25633751764,
"user": 0.20499918,
"system": 0.49690281999999997,
"min": 0.24579441664000004,
"max": 0.26546441364,
"times": [
0.26546441364,
0.25795703364,
0.25722843364,
0.25544660164,
0.25131595564,
0.24931060664000002,
0.24908514864000003,
0.26158024564,
0.26128646864,
0.24579441664000004
]
},
{
"command": "pnpr@HEAD",
"mean": 0.27100116744,
"stddev": 0.004988218199392307,
"median": 0.26990636213999997,
"user": 0.21578148000000003,
"system": 0.50237342,
"min": 0.26359252664,
"max": 0.27896463764,
"times": [
0.27568180064,
0.27029694664,
0.26359252664,
0.26951577764,
0.26476303764,
0.27488766264,
0.26819619864,
0.26914872264,
0.27896463764,
0.27496436364
]
},
{
"command": "pnpr@main",
"mean": 0.26340340474,
"stddev": 0.005951261449502883,
"median": 0.26209462214,
"user": 0.22188477999999998,
"system": 0.50267452,
"min": 0.25575759864000003,
"max": 0.27817695164,
"times": [
0.26003996564,
0.26264656764,
0.26084283964,
0.25575759864000003,
0.27817695164,
0.26510932464,
0.26405567664,
0.26154267664,
0.26579091864,
0.26007152764
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.5830449282,
"stddev": 0.017284632687944394,
"median": 2.5859946919,
"user": 1.6492549999999997,
"system": 1.31153048,
"min": 2.5573388684,
"max": 2.6086911524,
"times": [
2.5937768484,
2.5719956614000004,
2.5573388684,
2.6014950714,
2.5686147954000003,
2.5936558304,
2.5810828574,
2.6086911524,
2.5909065264,
2.5628916704
]
},
{
"command": "pacquet@main",
"mean": 2.5811038228000003,
"stddev": 0.021936182511886324,
"median": 2.5766205914,
"user": 1.6043755000000002,
"system": 1.3450163799999997,
"min": 2.5587614124,
"max": 2.6384869674,
"times": [
2.5760532374,
2.5624473194,
2.5771879454,
2.5735173614,
2.5859631074,
2.5776314224,
2.5587614124,
2.5752087974,
2.5857806574000004,
2.6384869674
]
},
{
"command": "pnpr@HEAD",
"mean": 1.6380432423999998,
"stddev": 0.10382765346435335,
"median": 1.6263999694,
"user": 1.1816001999999999,
"system": 1.1491570800000002,
"min": 1.4948773914000002,
"max": 1.7809426014,
"times": [
1.4948773914000002,
1.5260540304,
1.7809426014,
1.6367748854000002,
1.7376170184000002,
1.7623638894,
1.5529852734,
1.7087359974000003,
1.6160250534,
1.5640562834000002
]
},
{
"command": "pnpr@main",
"mean": 1.535774532,
"stddev": 0.12009041898287846,
"median": 1.4785898709,
"user": 1.1356614,
"system": 1.20076168,
"min": 1.4312389204000002,
"max": 1.7418569514000002,
"times": [
1.7418569514000002,
1.4312389204000002,
1.5637890644,
1.4398391094000003,
1.6636212784000002,
1.4549424514,
1.5022372904,
1.4408659114000002,
1.6866724874,
1.4326818554000003
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.38837679222,
"stddev": 0.012683794078245318,
"median": 0.38542599501999997,
"user": 0.49159869999999994,
"system": 0.7191747399999999,
"min": 0.37407498102000003,
"max": 0.41221020702,
"times": [
0.37936060102,
0.37522400202,
0.41221020702,
0.39793986502,
0.38572003202,
0.38567237802,
0.40508671402,
0.38517961202,
0.38329953002,
0.37407498102000003
]
},
{
"command": "pacquet@main",
"mean": 0.38151890132,
"stddev": 0.016420373487077748,
"median": 0.37926717802,
"user": 0.5060107,
"system": 0.67658064,
"min": 0.36391421202,
"max": 0.41589000102,
"times": [
0.38669023302,
0.36609974902000003,
0.37389316902,
0.36391421202,
0.38464118702,
0.38632175502,
0.39854277902,
0.41589000102,
0.36788482202,
0.37131110602
]
},
{
"command": "pnpr@HEAD",
"mean": 0.29753492272,
"stddev": 0.006704847447417812,
"median": 0.29730953502,
"user": 0.1832922,
"system": 0.5095783399999999,
"min": 0.28878836102,
"max": 0.30691634002,
"times": [
0.30217615602000003,
0.28998067502,
0.29168660102,
0.29353077902,
0.30087367902,
0.30564002202,
0.30201122302,
0.30691634002,
0.29374539102,
0.28878836102
]
},
{
"command": "pnpr@main",
"mean": 0.29671159562,
"stddev": 0.00575280880929654,
"median": 0.29756640902,
"user": 0.18611329999999998,
"system": 0.50941024,
"min": 0.28510380902,
"max": 0.30507381502,
"times": [
0.30241728302,
0.29259355702,
0.29774078702,
0.29808285202,
0.30507381502,
0.30092469302,
0.29207183602000003,
0.29739203102,
0.28510380902,
0.29571529302
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.7309928954,
"stddev": 0.011339138873095338,
"median": 1.7284880729999998,
"user": 0.73907152,
"system": 0.74194368,
"min": 1.7176801035,
"max": 1.7583478165,
"times": [
1.7386296695,
1.7231691685,
1.7294425855,
1.7176801035,
1.7583478165,
1.7315991174999998,
1.7233116015,
1.7343985844999998,
1.7258167464999998,
1.7275335605
]
},
{
"command": "pacquet@main",
"mean": 1.7162982985000004,
"stddev": 0.008198193561057152,
"median": 1.7161776325,
"user": 0.69503372,
"system": 0.77117128,
"min": 1.7045738925,
"max": 1.7324812765,
"times": [
1.7045738925,
1.7173628765,
1.7141446125,
1.7184956335000001,
1.7088083454999998,
1.7246770715,
1.7149923885,
1.7189039155,
1.7085429724999999,
1.7324812765
]
},
{
"command": "pnpr@HEAD",
"mean": 0.2979706616000001,
"stddev": 0.00832805348094571,
"median": 0.2954671765,
"user": 0.17189581999999998,
"system": 0.5295217799999999,
"min": 0.2899242265,
"max": 0.31419919150000003,
"times": [
0.2974813955,
0.2917870125,
0.29058365150000004,
0.2954534905,
0.2954808625,
0.31419919150000003,
0.30380699650000004,
0.3089716745,
0.2899242265,
0.29201811450000004
]
},
{
"command": "pnpr@main",
"mean": 0.2925983032,
"stddev": 0.008423300979758986,
"median": 0.29103474800000007,
"user": 0.18696071999999997,
"system": 0.5032682799999999,
"min": 0.2828270385,
"max": 0.3048178005,
"times": [
0.30135528450000004,
0.30027467550000003,
0.2828270385,
0.28777302650000003,
0.2839150805,
0.2996064075,
0.28788512450000003,
0.3048178005,
0.2833442225,
0.29418437150000004
]
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.17676649497999997,
"stddev": 0.004604380348793756,
"median": 0.17526332358,
"user": 0.15953583333333338,
"system": 0.08301881333333333,
"min": 0.17142575658,
"max": 0.18676134058,
"times": [
0.18676134058,
0.17381755858,
0.17158132358,
0.18102011058,
0.17218997158,
0.17396310958,
0.17313615758,
0.17512387858,
0.17142575658,
0.17721149958,
0.18282695058,
0.17883394958,
0.17643256358,
0.18190993058,
0.17526332358
]
},
{
"command": "pacquet@main",
"mean": 0.179668354205,
"stddev": 0.004091350498087182,
"median": 0.17862350208,
"user": 0.1505488875,
"system": 0.091871705,
"min": 0.17349420558,
"max": 0.18903907758,
"times": [
0.17748966558,
0.17824946258,
0.17902825558,
0.18388160558,
0.17648432658,
0.17899754158,
0.17685849658,
0.17724238358,
0.17704257658,
0.18180990458,
0.18903907758,
0.18168599958,
0.17597096658,
0.18106564258,
0.17349420558,
0.18635355658
]
},
{
"command": "pnpr@HEAD",
"mean": 0.09054805364896554,
"stddev": 0.0035573133253705654,
"median": 0.09047066558000001,
"user": 0.021982044827586204,
"system": 0.011245697931034483,
"min": 0.08615175158,
"max": 0.09730822758,
"times": [
0.09468873858,
0.09730822758,
0.09349560558,
0.09054432758,
0.09623290258,
0.09173283558,
0.09326622658,
0.09356593758000001,
0.09339346358,
0.09509517158000001,
0.08952126558000001,
0.08617623158000001,
0.08987523958,
0.08701208158000001,
0.08847361258000001,
0.09047066558000001,
0.09693537358000001,
0.08999060458000001,
0.08615175158,
0.08775050158,
0.09166612558000001,
0.08615592658,
0.08617814458,
0.08668408058,
0.08733414058000001,
0.08623350058000001,
0.08702028858000001,
0.09099619358000001,
0.09194439058000001
]
},
{
"command": "pnpr@main",
"mean": 0.09015728870499999,
"stddev": 0.003710415224187257,
"median": 0.08967472908,
"user": 0.02069745,
"system": 0.0123176375,
"min": 0.08529676658,
"max": 0.09996706958000001,
"times": [
0.08863836858,
0.08717268958,
0.08712942558,
0.09600893358000001,
0.09276722858000001,
0.08904657958000001,
0.09101389958,
0.08634933758,
0.09104252358,
0.09163289658000001,
0.09226251558000001,
0.09459429058,
0.09222280458000001,
0.09157954758,
0.08981817558,
0.08649545558,
0.09188879758,
0.09996706958000001,
0.08723192258000001,
0.08969595258,
0.08914953358000001,
0.09845492358,
0.09512307158000001,
0.08625044758,
0.08664567758000001,
0.08965350558,
0.08607738058,
0.08751503558000001,
0.08529676658,
0.09085997558,
0.08710732558,
0.08634118058000001
]
}
]
}Scenario: Isolated linker: peer-heavy resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.65732106396,
"stddev": 0.16488572187713746,
"median": 0.61394736796,
"user": 0.5930242644444443,
"system": 0.14870775777777778,
"min": 0.46190354496,
"max": 1.01690907596,
"times": [
1.01690907596,
0.73244137696,
0.61394736796,
0.57381175896,
0.46190354496,
0.54357016496,
0.61842727296,
0.57682334296,
0.7780556699600001
]
},
{
"command": "pacquet@main",
"mean": 0.8843794297377777,
"stddev": 0.15299720834031358,
"median": 0.8485361049600001,
"user": 0.814988931111111,
"system": 0.22962897999999995,
"min": 0.73721882096,
"max": 1.14291032796,
"times": [
0.8485361049600001,
1.14291032796,
0.8634104769600001,
0.73721882096,
0.8684472629600001,
0.7594599829600001,
0.77477575696,
1.14042094596,
0.8242351879600001
]
},
{
"command": "pnpm@HEAD",
"mean": 2.998205594293333,
"stddev": 0.10588762777619642,
"median": 3.0237559029599996,
"user": 4.243853375555555,
"system": 0.2827980911111111,
"min": 2.82297177196,
"max": 3.12890485896,
"times": [
2.82297177196,
3.12890485896,
3.04232156996,
3.11355794296,
2.93250668996,
2.99775572896,
2.86376587896,
3.0237559029599996,
3.05831000396
]
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.53112606964,
"stddev": 0.11699183586097239,
"median": 4.4880813887399995,
"user": 1.7906354399999997,
"system": 1.4001083399999996,
"min": 4.43219581624,
"max": 4.81357239724,
"times": [
4.43219581624,
4.44433474124,
4.5576239872399995,
4.60089100824,
4.45636647424,
4.81357239724,
4.58349787524,
4.5139575792399995,
4.4622051982399995,
4.44661561924
]
},
{
"command": "pacquet@main",
"mean": 4.5882751941399995,
"stddev": 0.1692046771437198,
"median": 4.534261842239999,
"user": 1.7984938400000001,
"system": 1.37871164,
"min": 4.41878573224,
"max": 4.83047169624,
"times": [
4.63931083624,
4.45141954424,
4.8164220662399995,
4.83047169624,
4.51825867024,
4.79272536124,
4.42133766424,
4.41878573224,
4.44375535624,
4.55026501424
]
},
{
"command": "pnpr@HEAD",
"mean": 3.5347271191400003,
"stddev": 0.10975457678042821,
"median": 3.49504695574,
"user": 1.29371394,
"system": 1.26012024,
"min": 3.44173951324,
"max": 3.78152235824,
"times": [
3.4625723972399998,
3.50784089224,
3.46835072324,
3.4479572892399997,
3.48225301924,
3.54825766224,
3.78152235824,
3.53769775024,
3.44173951324,
3.66907958624
]
},
{
"command": "pnpr@main",
"mean": 3.5633492529399993,
"stddev": 0.1257010477887788,
"median": 3.5026718067399996,
"user": 1.2932298399999997,
"system": 1.2242224399999997,
"min": 3.45613521924,
"max": 3.74240614124,
"times": [
3.72489285824,
3.74240614124,
3.73957656224,
3.45613521924,
3.58888429224,
3.48469890624,
3.4617529552399997,
3.52064470724,
3.4566001802399997,
3.45790070724
]
}
]
} |
|
| Project | pnpm's project |
| Branch | pr/13596 |
| 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 | 1,494.88 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 289.92 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 288.79 ms |
| isolated-linker.fresh-resolve.hot-cache.offline | 📈 view plot | 86.15 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 1,394.58 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr | 📈 view plot | 3,441.74 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 263.59 ms |
The final assertion checked `path.resolve('../../../escaped')` -- three
levels above the project, a path the vulnerable join never touches. The
join actually resolves out of `node_modules/.pnpm/<slot>/node_modules` to
`<project>/node_modules/escaped`, so the assertion could never fail.
Asserting on the corrected directory would be almost as weak: neither
path is created by the vulnerable code, because the escaped root has to
already exist for anything to happen there.
Plant a package at the real traversal target whose postinstall writes a
marker, and allow builds so the build policy is not what stops it. On the
unfixed code the script runs and the marker appears outside the virtual
store; with `safeJoinModulesDir` the rebuild rejects first and the marker
never appears -- the test now pins the security property rather than a
directory that was never going to exist.
…s key `dangerouslyAllowAllBuilds` is not part of `RebuildCommandOpts`, so it typechecked only under jest's transpile-only path and broke the pre-push build. Use `allowBuilds` instead. The key has to carry the version: a bare `../../../escaped` has no parseable version, so `isDepPathAllowBuildKey` classifies it as a depPath rule and it is then compared against the full `../../../[email protected]` depPath, which never matches -- which is why the first version of this test saw the build silently skipped rather than escaping. `../../../[email protected]` parses into name + version, lands in the package-spec rules, and matches.
|
Code review by qodo was updated up to the latest commit ff86e3f |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
Summary
Follow-up to
51300fd41c(GHSA-c59q-g84q-2gj5, GHSA-vq4v-j7r6-jq4m, GHSA-2rx9-3g3h-c2jv).The GHSA-c59q-g84q-2gj5 report listed three sinks that join a lockfile-derived package name onto a directory.
51300fd41ccontained two of them — the isolated linker (lockfileToDepGraph) and the PnPpackageLocation— and both are covered by regression tests. The third, the rebuild phase, was missed._rebuildin@pnpm/building.after-installreads the current lockfile fromnode_modulesand builds the package root aspath.join(pkgModulesDir(depPath), pkgInfo.name), wherepkgInfo.namecomes fromdp.parse()of thepackageskey.dp.parse()is a raw substring with no validation, so a key like../../../[email protected]pointed the lifecycle-script runner (and the post-build.binlinking a few lines down) at a directory outside the virtual store. The dep graph that phase walks is built by@pnpm/deps.graph-hasher, which deliberately defers the package-name check to its sink — and this sink had none.Both joins now go through
safeJoinModulesDir, so a crafted name fails withERR_PNPM_INVALID_DEPENDENCY_NAMEbefore any script runs.Reachability is narrower than the install path the advisory described: the poisoned lockfile has to already be inside
node_modules/.pnpm/lock.yaml, which means a shipped or CI-restorednode_modules, not a committedpnpm-lock.yaml. It is a defence-in-depth gap rather than a live repeat of the original bug, but it is the exact sink the report asked to close.Squash Commit Body
Checklist
already linked to it solves it.
pnpm/port, or the description notes what still needs porting.pnpm changeset) if this PR changes any publishedpackage. Keep it short and written for pnpm users — it becomes a release note.
Written by an agent (Claude Code, claude-opus-5).
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by CodeRabbit
pnpm rebuildnow rejects lockfiles containing package names with path traversal segments.ERR_PNPM_INVALID_DEPENDENCY_NAMEerror for invalid dependency names.