fix(guards): refuse a .npmrc beside a portal manifest, like bunfig.toml

Bun reads .npmrc too, so a registry line beside a borrowed portal's
manifest fetches every dependency from a server the portal's author
picked - the same door bunfig.toml opens, which the installer and guard
check 3 already refuse. Both now reject either file. The #718 integration
test, which pointed Bun at its offline registry through a .npmrc, passes
the registry through NPM_CONFIG_REGISTRY instead; it still proves the
hook stays off, because the hooked package only exists on that server.

Follows GHSA-wq7j-x5jq-pjrw; this case is ours, not the report's. Guard
tests for the workspaces and bunfig.toml refusals, which the previous
commit added without them, come along.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Mads LorentzenandClaude Fable 5.1 authored and Mads Lorentzen committed 2026-10-27 16:14:35 +01:00
1 parent 0bcfd75e60
commit 83c788d779
9 files changed
+67 -28

No files matched your search

+7 -6
View File
@@ -520,17 +520,18 @@ per-file diff commands.
key is added to the allowlist in the same PR, with its own check. Reported privately by
@folovco and @Huge (Martin Vlach).
- **Portal CLI installation never runs a lifecycle script, and refuses `workspaces` and
`bunfig.toml`** (#718 by @rudycelekli, `tools/install_portal_clis.py`, `tools/security_guards.py`
- **Portal CLI installation never runs a lifecycle script, and refuses `workspaces`,
`bunfig.toml` and `.npmrc`** (#718 by @rudycelekli, `tools/install_portal_clis.py`, `tools/security_guards.py`
check 3, `tests/test_install_portal_hooks.py`, `tests/test_install_portal_clis.py`) - the
installer refused a manifest's own lifecycle scripts and `trustedDependencies`, then ran plain
`bun install`, which on Bun 1.3.x still runs the hooks of default-trusted dependencies (esbuild's
`postinstall` ran in the reproduction) and of workspace packages: a `workspaces` entry pulled in
sub-packages whose scripts the check never read, and a `bunfig.toml` beside the manifest
reconfigured the install itself (registry, scopes, trusted packages). Every install now passes
sub-packages whose scripts the check never read, and a `bunfig.toml` or `.npmrc` beside the
manifest reconfigured the install itself (registry, scopes, trusted packages), so every
dependency could come from a server the portal's author picked. Every install now passes
`--ignore-scripts` (verified against an offline registry serving a hooked package), the
installer skips a manifest that declares `workspaces` or has a `bunfig.toml` beside it, and the
in-tree guard forbids both. Reported privately by @folovco and @Huge (Martin Vlach).
installer skips a manifest that declares `workspaces` or has a `bunfig.toml` or `.npmrc` beside
it, and the in-tree guard forbids all three. The `.npmrc` case is ours, not the report's. Reported privately by @folovco and @Huge (Martin Vlach).
- **The ask list now covers the files the allow list runs, and the guard reads load-time commands**