Skip to content

feat(install-gate): block a prebuilt binary install without a kit triage release receipt - #1109

Merged
sandstream merged 5 commits into
mainfrom
claude/web-kit-status-sync-p6fg9a-protected-release-binary-gate
Nov 27, 2026
Merged

sandstream merged 5 commits into
mainfrom
claude/web-kit-status-sync-p6fg9a-protected-release-binary-gate

Conversation

@sandstream

Copy link
Copy Markdown
Owner

Protected paths (src/install-gate.ts). This PR is the owner's to merge. Stacked on the kit triage release PR (#1108), which must merge first.

What

kit gate-bash passed a prebuilt binary install silently (kit-research#233, G1). Meanwhile npm i -g was held by cooling and curl … | sh was refused:

curl -fsSLO https://h.example/releases/v1.2.3/tool-linux-amd64.tar.gz
tar xzf tool-linux-amd64.tar.gz
chmod +x tool
./tool install
mv tool /usr/local/bin/

Now that command exits 2:

kit install-gate: BLOCKED: release binary: https://h.example/releases/v1.2.3/tool-linux-amd64.tar.gz is fetched and made executable (chmod +x tool), with no fresh `kit triage release` receipt in <cwd>. Run `kit triage release https://h.example/releases/v1.2.3/tool-linux-amd64.tar.gz` first (fail-closed)

With a release receipt for that URL from the last 7 days in .kit-triage.jsonl (the same file, window and freshReceipts reader as the bare-install gate), it exits 0. URLs are compared in one canonical spelling (src/release-url.ts, shared with the triage command).

How

src/install-gate-release*.ts (new) reads one command's pipelines in order. install-gate.ts gains 7 lines: parseInstallCommand collects the chains for every command it already scans (nested sh -c, $(…), powershell -Command, heredoc expansions), and gateVerdict checks them before the "no install" early return.

  • Fetches: curl (-o, -O, -J, --url, clusters such as -fsSLO), wget, gh release download -R o/r <tag> -p <asset>, Invoke-WebRequest/iwr/Invoke-RestMethod/curl/wget with -OutFile, Start-BitsTransfer. A fetch piped into tar x/gunzip counts as fetched and extracted.
  • Extractions: tar/bsdtar (old-style, clustered, long options, -C), unzip -d, 7z x -o, gunzip/xz/bzip2/zstd -d, Expand-Archive -DestinationPath.
  • Install steps: chmod with an execute bit, Unblock-File, running it (./x, an interpreter's script, Start-Process, & .\x.exe, msiexec /i), mv/cp/ln/rsync/Move-Item/Copy-Item onto PATH (/usr/local/bin and other bin dirs, ~, $HOME, /home/*, /Users/*, $env:LOCALAPPDATA, %LOCALAPPDATA%, C:\Program Files), install(1) anywhere, and extraction straight into an install location (-C /usr/local, /opt, C:\Program Files). A rename keeps the file's origin.

Decisions

  • Only the chain is blocked. A bare curl -O x.tar.gz, or a download that is only extracted or read (jq . a.json), stays allowed.
  • Source tarball + make: yes, that is an install. ./configure, make and cmake run build files that came in the download. A build after cd into the extracted tree, or make -C <dir>, counts as running the fetched code. curl -O data.tar.gz && tar xzf data.tar.gz && make train (or python train.py) does not: a bare name or a build with no cd runs the caller's own tree. A ./path or dir/path run after an extraction does count.
  • Fail-closed: an expanded URL or file name (curl -o x $URL), gh release download with a glob or without -R and a tag, curl -K, wget -i, a move to an expanded destination, or no directory to read receipts from is refused as unverifiable.
  • Not chains: chmod +x ./scripts/build.sh with no download in the command, git clone … && make, tar xzf vendored.tgz && ./vendored/run (nothing fetched).
  • A downloaded script counts too. curl -o x.sh https://h.example/install.sh && sh x.sh passed silently before; it now needs a receipt. A GitHub-hosted one still also gets its existing repo triage.
  • PowerShell words keep their backslashes (the shared POSIX unquoting turned .\setup.exe into .setup.exe).

Limits (also in docs/INSTALL_GATE.md)

  • The receipt binds the URL; the triaged file's digest is recorded, but the gate cannot see the bytes a later download receives.
  • A download in one tool call and its execution in a later one are separate commands and are not chained.
  • The hook is still registered with matcher Bash (src/agent-config.ts). The gate reads the command the same way for tool name PowerShell (tested end to end through kit gate-bash), but Claude Code only sends PowerShell tool calls to it if the matcher includes them. Widening the matcher is an owner decision for a follow-up; it changes every installed hook config.

Tests

Three sibling test files, 36 tests, offline, receipts written by hand (install-gate-release.test.ts, -steps.test.ts, -uses.test.ts): the G1 chain blocks and names the command; fresh, canonical-spelling, stale (8 days), other-URL and wrong-type receipts; 10 POSIX and 6 PowerShell chains; 9 false-positive guards; source tarballs; unreadable chains; and the compiled kit gate-bash hook exiting 2 then 0 for tool names Bash and PowerShell. All existing tests that touch the gate (51 files) still pass.

Platforms

Linux tested. Pure string parsing with no fs, shell or process code beyond the shared receipt reader. The PowerShell and Windows-path cases run on the Windows CI shards. macOS is unverified: no CI job runs it.

Prepush

node scripts/prepush.mjs --allow "enforcement gate liveness" on this branch: build, format, lint, changed-file tests, coverage gate, test growth (964 net lines over both PRs, reason in the Test-Growth: trailer of #1108's second commit; 242 of them here), self-audit and the session-URL checks pass; kit adr check passes (no new dependency, no model). Only the known local-only items remain: kit review --enforce (setup gaps: gh auth, infisical, uninstalled scanners) and Semgrep not run (!).

This PR does not touch src/commands/gate.ts, so I expect no conflict with the fail-closed deny-path work there. The refusal text goes through gate.ts's existing triageAdvice, which appends its generic Triage it first line after the exact kit triage release <url> command.

Refs kit-research#233.


Generated by Claude Code

…age release receipt

A download followed by an extract and a run, a chmod +x, a build in the
extracted tree, a move onto PATH or install(1) passed kit gate-bash
silently (kit-research#233, G1), while npm i -g is held by cooling and
curl | sh is refused.

install-gate-release.ts reads a command's segments in order: fetches (curl,
wget, gh release download, Invoke-WebRequest -OutFile, Start-BitsTransfer),
extractions (tar, unzip, 7z, gunzip and friends, Expand-Archive), and the
steps that execute or place what was fetched. Each chain needs a fresh
`release` receipt for its URL in .kit-triage.jsonl (the 7-day window other
triage uses); without one the gate blocks with exit 2 and names the exact
`kit triage release <url>` command.

- A bare download is allowed; so is extraction, except into an install
  location (/usr/local, /opt, bin directories, C:\Program Files).
- A source tarball built after cd into it (or make -C) counts as running
  it. A dataset extracted beside the caller's own make or python script
  does not.
- Fail-closed: an expanded URL or file name, gh release download with a
  glob, curl -K, wget -i, or a move to an expanded destination is refused.
- PowerShell forms are read with backslash paths intact, for tool names
  Bash and PowerShell.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CI's coverage gate wants a sibling test per new source file. The fetch and
step forms move to install-gate-release-steps.test.ts and the cases that are
not chains to install-gate-release-uses.test.ts, both read through
parseInstallCommand so `sh -c` and `powershell -Command` bodies are covered;
they gain direct checks of the curl, wget, Invoke-WebRequest and gh parsers
and of the extract, run and destination readers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@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 660747771f59: not approved.

  • touches protected paths (permissions), which the owner approves: src/install-gate-release-steps.test.ts, src/install-gate-release-steps.ts, src/install-gate-release-uses.test.ts, src/install-gate-release-uses.ts, src/install-gate-release.test.ts, src/install-gate-release.ts, src/install-gate.ts

Base automatically changed from claude/web-kit-status-sync-p6fg9a-triage-release to main November 27, 2026 11:26
…-sync-p6fg9a-protected-release-binary-gate

# Conflicts:
#	docs/COMMANDS.md
#	docs/INSTALL_GATE.md
Comment thread src/install-gate-release.test.ts Fixed
@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 8048dc824f72: not approved.

  • checks did not pass: CodeQL, build-and-test, checks (format, lint, build, gates)
  • touches protected paths (permissions), which the owner approves: src/install-gate-release-steps.test.ts, src/install-gate-release-steps.ts, src/install-gate-release-uses.test.ts, src/install-gate-release-uses.ts, src/install-gate-release.test.ts, src/install-gate-release.ts, src/install-gate.ts

…pe the URL fully in the release test

gateVerdict went over the CCN 15 standards limit with the release-binary
refusal. The test built a regex from a URL escaping only . and ?, which
CodeQL flags as incomplete escaping.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@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.

…lease-binary-gate

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@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 d9dfe4ca3450: not approved.

  • touches protected paths (permissions), which the owner approves: src/install-gate-release-steps.test.ts, src/install-gate-release-steps.ts, src/install-gate-release-uses.test.ts, src/install-gate-release-uses.ts, src/install-gate-release.test.ts, src/install-gate-release.ts, src/install-gate.ts

@sandstream
sandstream merged commit eae61f2 into main Nov 27, 2026
33 checks passed
@sandstream
sandstream deleted the claude/web-kit-status-sync-p6fg9a-protected-release-binary-gate branch November 27, 2026 13:37
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.

3 participants