fix(tools): run no repository or package code in Node and .NET lockfile tools
Stacked on #345 (fix/tools-sandbox).
Rule: code a repository or one of its packages chose never runs on the Count's machine. The threat model now says so with no exception and lists the guard for each tool. When a lock can't be regenerated without running such code, the update is skipped with a standing reason, and maintenance is held the same way.
Refusal path
patchula_lockfiles::Failure::Refused(reason) is a refusal that the lockfile layer returns. Plan::lockfiles_failed turns it into Hold::Blocked(reason), the same skipped-with-reason path the dashboard and CLI report already show. Nothing is written. The type is deliberately small and generic. The sibling PR fix/no-exec-python-ruby may build the same thing, and whichever lands second reconciles.
Per tool
npm (native engine: npmEngine = "npm" or format v1 locks)
- How it works: before npm starts,
node/sources.rschecks against an allowlist everypackage.jsonin the tree (dependencies,devDependencies,optionalDependencies,peerDependencies,overrides) and the lock (resolved/versiongit sources, plus nested dependency specs at any depth, v1 and v3). Anything outside the allowlist is refused: git URLs,github:/gitlab:/bitbucket:/gist:,owner/repo, forge URLs and archives. The allowlist: registry ranges and tags,npm:aliases,jsr:,workspace:,catalog:, local paths, and.tgz/.tar.gzfiles on a host that is not a forge. A regenerated lock that records a git source is thrown away (Refused). The run getsGIT_ALLOW_PROTOCOL=none, plusNODE_OPTIONS=--require=<guard>. The guard exits any Node process that has_PACOTE_NO_PREPARE_set, which is how pacote starts git-dependency preparation. - Flags verified: the pinned node 26.13.0 ships npm 11.20.0 with pacote 21.5.1, below 22, read on the VM. In pacote's
lib/git.js,#prepareDirspawnsnpm install --forcewith_PACOTE_NO_PREPARE_in its environment and never checksignoreScripts. A hosted dependency with a full SHA goes through#clonewithtarballOkand arrives as a codeload tarball throughRemoteFetcher, soGIT_ALLOW_PROTOCOLdoesn't stop it. That is why the guard exists. Inlib/dir.js,#prepareDirdoes honourignoreScripts.--ignore-scriptsandNPM_CONFIG_IGNORE_SCRIPTS=trueare kept. - Canaries: the direct dependency is Skipped with the reason, npm never starts, and no marker appears. The transitive case (
canary-mid-gitplus→git+http://…/evil.git) runs npm, fails on the Git transport, and leaves no marker.real_npm_prepare_guard_stops_git_dependency_preparationshows the real node exits 97 under the guard with_PACOTE_NO_PREPARE_set and nothing runs; an ordinary process runs normally. - Refused: git, forge and other non-allowlisted sources in any manifest, override or the lock.
Yarn Berry
- How it works: the same refusal, applied to manifests (with
resolutions),yarn.lock(descriptors,resolution, dependencies;::binding params andpatch:inner sources decoded), and every.yarnrc.ymlfrom the project up to the tree root (catalog,catalogs,packageExtensions).exec:is refused. The run getsGIT_ALLOW_PROTOCOL=noneandYARN_ENABLE_SCRIPTS=0. The run's user.yarnrc.ymlis now always written and closesgithub.comandcodeload.github.com(networkSettings.<host>.enableNetwork: false). The sanitized project rc copies dropnetworkSettings, so a project can't reopen those hosts. - Flags verified, from the 4.18.1 bundle on the VM: the
GitFetcher(cloneFromRemote) and theGithubFetcher(fetchFromNetwork,https://github.com/<u>/<r>/archive/<treeish>.tar.gz) both callscriptUtils.prepareExternalProject.networkSettingsis matched per hostname andenableNetwork === falsethrows ("has been blocked because of your configuration settings"). Experiment: withenableScripts: 0, agit://dependency still ran itspostinstallandprepackmarkers, and withGIT_ALLOW_PROTOCOL=noneit failed with "transport 'git' not allowed". Transitiveexec:from a registry package is rejected by Yarn itself ("only workspaces can depend on exec: packages"), soexec:is only a direct-dependency concern, and that is refused. - Canaries: in the canary repo's
.yarnrc.yml,approvedGitRepositories: ["**"]turns off Yarn's own guard, as a hostile repository would. The direct dependency is Skipped and Yarn never starts. Transitivecanary-mid-dotgit(http.git) fails with "not allowed" and leaves no marker. Transitivecanary-mid-github(github:…#<sha>) fails with "blocked because of your configuration settings" and leaves no marker. Control: the same transitive dependency with Git reachable does writeevil-*markers (the canary works), and its lock is thrown away as "the regenerated yarn.lock …". - Refused: as for npm, plus
exec:, catalogs andpackageExtensions.
aube (aube-lock.yaml, pnpm-lock.yaml), Bun
- How it works:
--ignore-scripts, as before. They are not refused. - Canaries, with Git reachable (
GIT_ALLOW_PROTOCOL=httpin the test) andblockExoticSubdeps: falseinpnpm-workspace.yaml: the directgit+httpdependency and the transitive one throughcanary-mid-gitplusboth reach Planned. The lock recordscanary-eviland no marker appears, for aube-lock, pnpm-lock and bun.lock. Note: by default aube 2.9.0 itself refuses exotic transitive specs (blockExoticSubdeps).
dotnet
- How it works:
packages.lock.jsonis refused outright (dotnet::refused), and no dotnet process runs. Removed along with it: the restore code, the NuGet tool credentials (nuget_env/nuget_sources),Bin::Dotnetcache wiring, thedotnetpin (defaults.toml,test:tools,mise.lock),roxmltreefrom patchula-tools, the image'sDOTNET_SYSTEM_GLOBALIZATION_INVARIANT, and the image smoke restore. - Test:
packages_lock_json_is_refused_without_running_dotnet, for both maintenance and update. Status is Skipped with the MSBuild reason and no dotnet call.
uv, Poetry, Bundler: the guards land in the sibling PR (fix/no-exec-python-ruby). The threat model and the lockfiles guide in this PR already describe them as the brief specifies: uv --no-build/UV_NO_BUILD; Poetry under a launcher with its build entry points disabled, refused otherwise; Bundler on a Count-rendered Gemfile in a scratch directory, refusing gemspec, path:, git:/forge keys, git_source, plugin, eval_gemfile, install_if, unread lines and GIT/PATH/PLUGIN SOURCE lock sections.
Docs
internals/threat-model.md: the rule now covers dependency package code. There is no exception section. A new "How each tool keeps to it" section lists every tool. This fixes the contradiction withguide/lockfiles.md.guide/lockfiles.md: the danger box is replaced by a note saying no tool runs repository or package code. A new "What is refused" section is added. The partitions paragraph is rewritten (the "every installation is trusted" and "lockfile tools run repository code anyway" wording is gone). The private-registry text, the Yarn rc sanitizing, and the .NET rows and mentions are updated.renovate/compatibility.mdlockfile table and a newrenovate/departures.mdentry, "Lockfiles that need repository or package code are refused".guide/managers.md,guide/server.mdxandreference/environment.mdlose dotnet restore.
Tests run (boat VM)
cargo test -p patchula-tools -p patchula-engine -p patchula-update -p patchula-lockfiles (real tool tests included) and clippy -D warnings on those crates: green. The extract, files, config, config-files, catalog and catalog-controls state versions are bumped for the plan.rs, lockfiles/src and engine edits.
Follow-ups
- The npm/Yarn refusal scans every
package.jsonin the tree, not only the run's reach (workspaces and local paths). Narrowing it would refuse less in monorepos with unrelated Node projects. - dotnet: an allowlist approach (e.g. projects with no targets, props or package build assets) to regenerate some
packages.lock.jsonsafely. - The npm commit-pinned GitHub path, which arrives over HTTPS from codeload, is proven by the guard canary and by reading the pacote source, not end to end. An end-to-end canary would need a TLS CONNECT proxy for codeload.github.com.
- Reconcile
Failure::Refusedwith the sibling PR's skip path.