Skip to content

fix(install): never hand mise "latest" for npm:/pipx: tools; mise use writes the project config only - #1139

Merged
sandstream merged 6 commits into
mainfrom
fix/mise-latest-fork-loop
Nov 27, 2026
Merged

sandstream merged 6 commits into
mainfrom
fix/mise-latest-fork-loop

Conversation

@sandstream

Copy link
Copy Markdown
Owner

Problem

kit could start an unbounded process fork loop through mise.

How it happens

  • kit writes scanner versions as "latest" (DEFAULT_SECURITY_SCANNERS). miseInstall ran mise install <tool>@latest and then mise use <tool>@latest. mise use had no --global and no --path. In that case mise writes mise.toml in the current folder, "or global config if cwd is home directory" (mise help use, mise v2026.6.11). So a run from ~ wrote "npm:snyk" = "latest" and "npm:@socketsecurity/cli" = "latest" into ~/.config/mise/config.toml.
  • To resolve latest for an npm: tool, mise v2026.6.11 runs npm view <pkg> dist-tags --json with the bare npm (src/backend/npm.rs, latest_stable_version). When npm on PATH is mise's own shim, the shim resolves the toolset again and runs npm view again. Nothing stops the recursion.
  • What we saw: 4,425 orphaned npm view snyk dist-tags --json / npm view @socketsecurity/cli dist-tags --json processes (ppid 1) within one minute, on a flaky network where nothing got cached. pkill could not keep up, and only a reboot stopped it. This happened three times, once during npm test.
  • Current mise main reads the registry over HTTP and skips its own shims, so newer mise fixes this upstream. kit cannot rely on the user's mise version.
  • pipx: has no such loop. mise reads PyPI over HTTP for it in v2026.6.11 and on main (src/backend/pipx.rs), so the detection row covers npm: only.

Fix

  1. kit never hands mise latest for npm: / pipx: / pip:.
    • The new src/mise-version.ts resolves latest to the newest stable release that has been public for the cooling period ([supply_chain] min_release_age_days, default 14).
    • It reuses triage-cooling's newestOlder, registrySource and limitFrom, and it honours air-gap mirrors.
    • installTools triages that exact version (npm:x@1.2.3) and installs it.
    • If no version can be resolved (registry unreadable, air-gap with no mirror, nothing cooled), the install fails closed with a clear detail. It never falls back to latest.
    • miseInstall also refuses latest for those backends, in case a caller passes it directly.
    • Other backends (aqua:, core runtimes) still pass latest through. kit has no cooling resolver for them, and mise resolves them from its registry or the GitHub API, not through a shim. This is a deliberate gap: latest still reaches mise for aqua: tools.
  2. mise use writes only the project config. It now runs mise use --path <project>/mise.toml (or an existing .mise.toml). kit refuses to run it in the home folder (compared by file identity), where any config would act as global.
  3. Detection and migration.
    • A new kit check security row, mise npm: tools at latest (category supply-chain), reads the project mise.toml / .mise.toml and the global config (MISE_GLOBAL_CONFIG_FILE, MISE_CONFIG_DIR, XDG, ~/.config/mise/config.toml).
    • It warns (high) when an npm: tool is at latest (string, table or list form) and mise's npm shim exists with the shims folder on PATH. It names the loop and the fix.
    • It reads files only and never runs mise or npm.
    • The row does not use "the first npm on PATH": kit usually runs under a node that mise started, and mise puts a real npm first for that child. I measured this on the affected machine.
    • kit fix pins each plain-string entry to the newest version installed under mise's data folder. Table and list forms, and tools that are not installed, are reported for a manual pin. Read-only mode refuses and writes nothing.
  4. .kit.toml may keep latest as policy. The comment on DEFAULT_SECURITY_SCANNERS and the kit install row in docs/COMMANDS.md now say what it means.
  5. Tests cannot reach the machine's global mise config.
    • scripts/test.mjs and the prepush.mjs test step set MISE_GLOBAL_CONFIG_FILE to a path where no file exists.
    • Without that, any real mise current / mise which that checkTools runs inside tests loaded the global npm: latest entries, which is the likely trigger during npm test.
    • The fix-flow helper also isolates MISE_GLOBAL_CONFIG_FILE and MISE_DATA_DIR.

Non-hermetic tests found

  • No test reaches the real mise install / mise use. Every installTools / ensureScannersInstalled / heal-recipe test injects fakes. The cmdFix / setup / check fixtures either have no scanner refs or have node = "latest", which checkTools reports already_ok.
  • These tests do reach a real mise current / mise which through checkTools: cli-fix.test.ts, cli-check.test.ts and cli-setup.test.ts (node = "latest" fixtures). With the old global config, each of those calls could start the loop. Item 5 closes that.
  • Latent risk: the repo's own .kit.toml declares trivy and trufflehog. A kit check in the repo root would auto-install them for real if those exact pins were missing. No test does that today.

What the tests prove

  • mise-version.test.ts: exact pins pass untouched with no network. npm and PyPI latest resolve to the newest cooled stable version. min_release_age_days is honoured. Unreadable registry, nothing cooled, and air-gap without a mirror all refuse, and none of them returns latest. aqua and core tools pass through.
  • install.test.ts: the resolved version is the one triaged and installed. A refusal reaches neither the gate nor mise. Against a fake exec, miseInstall passes use --path <project>/mise.toml, reuses .mise.toml, refuses in home, and refuses latest for npm/pipx.
  • check-mise-latest.test.ts: global path resolution; string, table and list detection (pipx ignored); installed version read past mise's alias links; warn and pass cases, including a real npm ahead of the shim on PATH; the pin keeps comments and the other lines; uninstalled tools are not pinned; read-only refuses.
  • fix-flow.test.ts: kit fix pins a project mise.toml end to end.
  • I also ran the row and pinMiseLatest on a copy of the affected machine's pre-fix global config. The row warns, and the pin produced exactly the versions that were pinned by hand (1.1.102, 1.1305.1).

Unverified

  • No test runs real mise. Two things rest on mise's help text and source, not on a run: that --path keeps mise use off the global config, and the recursion mechanism itself.
  • Windows: symlink-based tests skip on win32. Shim detection there checks npm.cmd / npm.exe in the shims folder and has not been run on Windows.
  • macOS: verified only by local runs on one Mac. No CI job runs macOS.

🤖 Generated with Claude Code

sandstream and others added 3 commits November 27, 2026 13:41
… to the project

mise resolves "latest" for an npm: tool by running `npm view <pkg> dist-tags --json`
with the first npm on PATH. When that npm is mise's own shim, the shim resolves the
toolset again and runs `npm view` again, without bound (4,425 orphaned processes in
under a minute on one machine). kit wrote such entries itself: `mise use <tool>@latest`
with no --path, which from the home folder writes the global mise config.

- installTools resolves "latest" for npm:/pipx:/pip: to the newest stable release public
  for the cooling period (triage-cooling's newestOlder), triages that exact version, and
  refuses when none can be resolved. miseInstall refuses "latest" for those backends too.
- mise use gets --path <project>/mise.toml (or an existing .mise.toml); refused in ~.
- kit check: "mise npm: tools at latest" supply-chain row; kit fix pins each entry to the
  installed version. File reads only, read-only aware.
- Test runs point MISE_GLOBAL_CONFIG_FILE at an empty path (test.mjs, prepush).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Kit-Hook-Tree: 225dc78
…est suites

Moves the kit fix migration for the mise fork loop into check-mise-latest.ts
(migrateMiseLatest), so src/fix.ts stays under 600 lines, and splits two describe
blocks the complexity gate measured as over 80 lines.

Test-Growth: the tests are the proof for a fix that took a machine down three times; every install, resolution and pin path runs against a fake exec or a temp folder, so none can spawn mise or npm
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Kit-Hook-Tree: c3e9863
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Kit-Hook-Tree: 1a426ae
@github-actions

Copy link
Copy Markdown

Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published.

@sandstream-kit-reviewer sandstream-kit-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kit review gate at c6a487217fcc: not approved.

  • touches protected paths (github), which the owner approves: scripts/prepush.mjs

…loop

Kit-Hook-Tree: 4e3d44b

# Conflicts:
#	docs/COMMANDS.md
@github-actions

Copy link
Copy Markdown

Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published.

…loop

Kit-Hook-Tree: 51ab5a3

# Conflicts:
#	docs/COMMANDS.md
@github-actions

Copy link
Copy Markdown

Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published.

@sandstream-kit-reviewer sandstream-kit-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kit review gate at d9830c236757: not approved.

  • touches protected paths (github), which the owner approves: scripts/prepush.mjs

…loop

Kit-Hook-Tree: 6694380

# Conflicts:
#	docs/COMMANDS.md
@github-actions

Copy link
Copy Markdown

Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published.

@sandstream-kit-reviewer sandstream-kit-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kit review gate at c68bce2995c4: not approved.

  • touches protected paths (github), which the owner approves: scripts/prepush.mjs

@sandstream
sandstream merged commit 079ea37 into main Nov 27, 2026
33 checks passed
@sandstream
sandstream deleted the fix/mise-latest-fork-loop branch November 27, 2026 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant