Commit f6135c9
fix(security): validate package-spec @-tail, close direct-reference bypass
Codex re-review of #672 found validatePackageSpec only validated the
parsed NAME, not the version/@-tail. A PEP 508 / npm direct reference
("pkg@./local", "pkg@/abs/path", "pkg@git+https://…") therefore passed
— the name "pkg" is a valid registry name — while the full untrusted
spec still reached `pip download` / `uv pip download` / `npm pack` and
executed setup.py. The P0 was not actually closed.
Validate the WHOLE spec:
- New bareVersionRe: the "name@<tail>" / "name==<tail>" tail must be a
bare version / range / npm dist-tag — must start alphanumeric and
contain no '/' or ':' — so a path/URL/VCS tail is rejected.
- Python: any '@' is a PEP 508 direct reference (pins use '=='), so it
is refused outright.
- Bare version pins / dist-tags (pkg@1.2.3, pkg@latest, @scope/pkg@2.0.0)
stay valid — no regression.
TDD: TestValidatePackageSpec gains npm+python "pkg@<path/url/vcs>" reject
cases and bare-version positive cases; TestResolveFromPackageFetch_
RejectsNonRegistrySpec gains uvx/npx direct-reference cases asserting the
setup.py execution marker stays absent.
Related MCP-2442
Co-Authored-By: Paperclip <noreply@paperclip.ing>1 parent c842e18 commit f6135c9
3 files changed
Lines changed: 47 additions & 2 deletions
File tree
- docs/features
- internal/security/scanner
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
259 | 259 | | |
260 | 260 | | |
261 | 261 | | |
262 | | - | |
| 262 | + | |
263 | 263 | | |
264 | 264 | | |
265 | 265 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
117 | 124 | | |
118 | 125 | | |
119 | 126 | | |
| |||
145 | 152 | | |
146 | 153 | | |
147 | 154 | | |
148 | | - | |
| 155 | + | |
149 | 156 | | |
150 | 157 | | |
151 | 158 | | |
152 | 159 | | |
153 | 160 | | |
154 | 161 | | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
155 | 168 | | |
156 | 169 | | |
157 | 170 | | |
158 | 171 | | |
159 | 172 | | |
160 | 173 | | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
161 | 182 | | |
162 | 183 | | |
163 | 184 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
510 | 510 | | |
511 | 511 | | |
512 | 512 | | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
513 | 534 | | |
514 | 535 | | |
515 | 536 | | |
| |||
541 | 562 | | |
542 | 563 | | |
543 | 564 | | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
544 | 568 | | |
545 | 569 | | |
546 | 570 | | |
| |||
0 commit comments