Repository navigation
fix(gate): refuse npx <bin> when the bin is another package's npm name - #1111
Merged
sandstream merged 3 commits intoNov 27, 2026
Merged
Conversation
`@metaharness/redblue` ships a bin `redblue`. Without a local install, `npx redblue init` fetches the unrelated unscoped `redblue` (2017, another maintainer), and gate-bash allowed it with exit 0. `artex-defense` is an unclaimed name that the gate blocked only because it does not exist yet. kit triage npm now reads the triaged version's `bin` and asks the registry about each bin whose name is not the package's own: `same`, `unclaimed` (404) or `other` (owner's version, maintainers, created). The last two print a warning and an `npm-bin` record in .kit-triage.jsonl, whatever the verdict. gate-bash refuses npx / npm exec / pnpm dlx / yarn dlx / bunx of such a name and names the scoped package, or `npx -p @scope/pkg <bin>`. A local bin, or a newer PASS for the unscoped name, still allows it. New modules: triage-npm-bins.ts, install-gate-npx-bin.ts; install-gate.ts grows by 3 lines. Found by kit-research metaharness-artex-defense-vs-kit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published. |
There was a problem hiding this comment.
kit review gate at dd418ee2931c: not approved.
- checks did not pass: build-and-test, checks (format, lint, build, gates)
- touches protected paths (permissions), which the owner approves:
src/install-gate-npx-bin.test.ts,src/install-gate-npx-bin.ts,src/install-gate.ts
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published. |
sandstream
deleted the
claude/web-kit-status-sync-p6fg9a-protected-npx-bin-name
branch
November 27, 2026 11:27
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Protected: this touches the install gate. It is the owner's to merge.
Found by kit-research note
metaharness-artex-defense-vs-kit:gate-bashallowsnpx redblue initwith exit 0.redblueis a bin of@metaharness/redblue. Without a local install, npx fetches the unrelated unscopedredblue(2017, another maintainer).npx artex-defensewas blocked only because that unscoped name is unclaimed.What changes
kit triage npm(src/triage-npm-bins.ts, run after the cooling check inrunTriage): for each bin of the triaged version whose name differs from the package's own name, it makes one registry GET on the unscoped name. The result is one of three states:same: an info line, no fetch.unclaimed(404): a warning.other: a warning with the owner's version, maintainers and creation date.It honours
KIT_NPM_REGISTRYand air-gap (prints NOT CHECKED, never a clean line) and reads at most 10 bins. It reusesfetchRegistryDocandregistrySourcefromtriage-cooling.ts;fetchJsonnow wrapsfetchRegistryDocso a 404 can be told apart from a failure. The package's own verdict is unchanged. The warnings count toward the score the same way cooling lines do.Receipt:
otherandunclaimedare appended to.kit-triage.jsonlastype: "npm-bin"records whatever the verdict. Both scoped packages in the note were HELD by cooling, so a PASS-only receipt would never have reached the gate. PASS readers (check-deps, bare-install, allowScripts cross-check, skill gate) filter bynpm/pip/skilland skip these records.usage-reportcounts them under their own type. They are written by the CLI, the MCPkit_triagetool andgateInstall(new optionalGateDeps.recordBins; the read-only observation deps have none, so they do not write).gate-bash(src/install-gate-npx-bin.ts;install-gate.tsgrows 3 lines, from 1311 to 1314, limit 1339): for a plainnpx,npm exec,pnpm dlx,yarn dlxorbunxof an unscoped name that is the fetched ref, it exits 2 when annpm-binrecord names it. The message names the scoped package andnpx -p @scope/pkg <bin>.node_modules/.bin/<bin>still allows the command, decided by the existingshadowedBins, so acdvoids it as before.kit triage npm <bin>PASS newer than the record also allows it. This is the escape hatch for someone who really means the unscoped package.npm init foois not read asfoo.Docs: a new section in
docs/INSTALL_GATE.md, thetriage npmrows indocs/COMMANDS.mdanddocs/FEATURES.md, andchanges/npx-bin-name.md. No flag-surface change, so the contracts are not regenerated.Verification
install-gate-npx-bin.test.ts: 5 of them fail on main's gate. The other 2 are false-positive guards (npx prettier,npx -p @scope/pkg,npm init redblue, expansion fail-closed), and they pass both before and after. 7 triage tests intriage-npm-bins.test.ts, which is a new module. After the change, all 14 pass. 257 net new test lines (cap 400).node --testoverinstall-gate*,triage*,mcp-server,commands/triage,changelog-fragmentsandgate-bash-refusal: 1577/1577 pass.node dist/cli.js adr check: 4 enforced ADRs, no new violations. No new dependency, no model call.scripts/prepush.mjs --allow "enforcement gate liveness": everything passes except the known local-onlykit review --enforce(noghauth or jscpd/scc/hadolint here) and Semgrep (not installed).npx redblue init→ exit 0.kit triage npm @metaharness/redblue, it → exit 2 ("the npm name 'redblue' is another package (redblue@0.0.1, maintainers , created 2017-10-30)").npx artex-defense→ exit 2 (unclaimed).npx prettier --version→ exit 0.Limits
pnpm dlxandyarn dlxlocal-bin allow uses the existing shadow rule unchanged.node:path. The local-bin test writes both<bin>and<bin>.cmd, so it holds on Windows CI. macOS is unverified, since no CI job runs it.Generated by Claude Code