Skip to content

v0.2.0

Choose a tag to compare

@github-actions github-actions released this 30 Oct 10:49
· 17 commits to main since this release
Immutable release. Only release title and notes can be modified.
b47e94b

The open items after 0.1.0, closed or decided: a memory limit for every process the gate and the helper start, commands that read the file the gate checked, privileged #! scripts reviewed by name, private keys kept out of every output and replaceable under approval, recovery of an interrupted dpkg through the tools, and protocol version 2. The server, the gate and the helper must be upgraded together (below). The design record behind each change is docs/ARCHIVE.md §14, sessions S6-1 to S7-7 (PRs #61 to #73).

Upgrading from 0.1.0

  1. Upgrade shell-mcp, shell-mcp-gate and shell-mcp-privd together. This release speaks protocol version 2 and 0.1.0 speaks version 1. Any mismatch between the server and a gate, or between a gate and its helper, fails with protocol_mismatch, naming both versions and which side to upgrade, and nothing runs; it is never reported as outcome_unknown. Install the new gate and helper on every target first (both start per request, so nothing restarts), then the new server image. Requests fail closed in between. The server restart drops pending approvals, as on every upgrade.

  2. Add an acknowledge to every privileged command whose program is a #! script. The helper now refuses to load a privileged policy that declares a script without one, so it serves nothing until the policy is fixed. A symlink to a script or a renamed copy counts: the file is judged by its content. Review each script and add a one-line acknowledge. /usr/local/libexec/shell-mcp-privd check-policy --policy /etc/shell-mcp/privileged.yaml fails on each such command until it has one, and then prints it as REVIEW script. An interpreter on the never list is still refused, acknowledged or not.

  3. Add reads_private_keys: true to any command whose {path:read} legitimately takes a private-key file (for example openssl pkey -pubout or ssh-keygen -y), in the gate policy or the privileged policy. Without it, a command whose {path:read} or {path:read:fd} names a file that holds a private key is now refused with path_denied, at the preview too. Set it only for a program that never prints part of its input; check-policy warns when it is set on a range or filter program (tail, head, sed, cut, grep and the others in POLICY §4).

  4. Review limits.max_memory_mb and packages.allow_recover.

    • limits.max_memory_mb (gate policy and privileged policy; default 1024, from 128 to 16384) bounds the data memory of every command, git, systemctl, journalctl and apt-get process. 0.1.0 had no such bound. Raise it for a command that needs more than 1024 MiB (for example jq on very large files). The helper's units take their MemoryMax= from it (step 5).
    • packages.allow_recover (privileged policy; default false) enables shell_priv_recover_packages. Leave it off unless you want dpkg recovery through the tools.
  5. Regenerate and reinstall the helper's units, after the policy edits above (the units are pinned to the policy's hash):

    /usr/local/libexec/shell-mcp-privd units --policy /etc/shell-mcp/privileged.yaml --out /etc/systemd/system
    systemctl daemon-reload

    The new units set MemoryMax= to limits.max_memory_mb plus 256M, with MemorySwapMax=0 and OOMPolicy=continue, and the core unit gets ProtectHome=yes unless a root, command, interpreter or the policy file lies under /home, /root or /run/user, contains one of them (a read root of / or /run), or cannot be resolved; then it stays read-only, as before, and check-policy names the path responsible. If the policy did not change, a new helper still starts with the 0.1.0 units, but without these directives: the old units' fixed MemoryMax= (256M core, 1G broad, without OOMPolicy=continue) is below the new limits, so a command using more than about 256 MiB in the core unit ends the whole instance instead of failing its own allocation. Regenerate in every case.

  6. Check. As the service account, shell-mcp-gate check-policy --policy <each gate policy>; as root, /usr/local/libexec/shell-mcp-privd check-policy --policy /etc/shell-mcp/privileged.yaml; then shell-mcp check from the server, which shows each target's gate version and protocol. Diff the tool catalogue (shell-mcp tools) against 0.1.0's: two new tools, shell_priv_recover_packages and shell_priv_reinstall_packages; new descriptions for shell_write_file and shell_priv_write_file; new output schemas for shell_get_policy, shell_run_read_command, shell_run_command, shell_priv_run_command and shell_priv_preview_packages (whose input also changed: the reinstall operation).

A 0.1.0 gate or helper refuses a policy that uses any new key or placeholder (limits.max_memory_mb, {path:read:fd}, reads_private_keys, packages.allow_recover; strict parsing), so add those only once the new binaries are installed.

Added

  • A memory limit for every child of the gate and the helper (N-30, S6-1, #61): limits.max_memory_mb, as above, applied as RLIMIT_DATA, soft and hard, before the child's first instruction. A command that reaches it fails its allocation, and that is its result, never outcome_unknown. git's thread counts are pinned (pack.threads=4, index.threads=1, checkout.workers=1 and the others in gitx), so a git operation's memory need does not follow the host's CPU count. check-policy reports the limit and the units' MemoryMax=, and warns when the kernel's ignore_rlimit_data is set. A large file planted in a submodule's git files (N-25) now ends a git operation within about a second, naming the limit. TARGET-SETUP §4 recommends MemoryMax= on the service account's slice as the outer bound.
  • {path:read:fd} (N-22, S6-2, #62): an opt-in placeholder for gate commands that passes the file as the gate's open descriptor (/dev/fd/4 and up) instead of a path, so the command reads the file the gate checked, whatever happens to its name afterwards. It closes the owner-matched {path:read} redirect for such commands. Regular files only, at most 8 per template; the privileged policy refuses it. exec_preview, exec, shell_run_read_command and shell_run_command report the descriptors (fds), and an approved command is bound to each file's identity. check-policy checks /dev/fd and warns about programs measured to give wrong results with a descriptor: stat, du, file, ls and find without following links, cp -a/-P/-r, tar adding a member, findmnt, nginx and docker compose (POLICY §4).
  • Replacing a private-key file under approval, with hashes only (N-5, S6-4 #64 and S7-3 #68). Two read-tier ops return a file's size, SHA-256, line count and whether it holds a private key, never its content: priv_hash_file in the helper and hash_file in the gate (under read_file's path rules, refused above 256 MiB). The previews of shell_priv_write_file, shell_priv_copy_path and shell_priv_move_path, and of shell_write_file, shell_copy_path and shell_move_path when they are gated, hash an existing destination with them, so a key file, or a certificate bundle with its key, can be replaced under an approval that binds the old and new hashes without showing either. The previews gain private_key (and a write's new.private_key). shell_read_file and shell_priv_read_file still refuse the key. A privileged replace backs the old key up, root-only, like any other file; PRIVILEGED §6 says how to remove those backups after a rotation for compromise. TOOLS.md shows how to generate a key on the host with a gate command and move it into place, which keeps the key away from the client and its model provider.
  • Recovering an interrupted dpkg through the tools (N-14, S7-4, #69): shell_priv_recover_packages (operator, always approval-gated; needs packages.allow_recover: true) runs dpkg --force-confold --configure --pending as root in the broad unit, under the package operations' protections. The approval binds the unfinished packages, read from dpkg's status with its journal folded in, by hash; any change before the run is refused. At a hang-up or the deadline it answers early and lets dpkg finish: dpkg gets no SIGINT (it has no graceful stop) and is killed only at limits.max_timeout_s. The result comes from dpkg's state. With nothing unfinished it answers at once, with no approval and nothing run.
  • Removing and reinstalling what the recovery leaves (N-36, S7-7, #73):
    • shell_priv_remove_packages accepts an unfinished database when dpkg's journal is empty and the request names exactly the unfinished packages that do not need a reinstall (for example one whose dependency nothing provides). Its preview lists every unfinished package with its version and state (unfinished), and its hash binds that state.
    • A new tool, shell_priv_reinstall_packages (operator, always approval-gated), and reinstall as an operation of shell_priv_preview_packages, reinstall exactly the half-installed or reinstreq packages, each pinned to the version dpkg names, through the install's lock rule, record and stop points, with the result from dpkg's state.
    • Both use the existing allow-lists (packages.remove, packages.install); no new key.
  • reads_private_keys (N-35, S7-6, #72): an optional command key in the gate policy and the privileged policy (default false), shown in check-policy and in both policy summaries (shell_get_policy, priv_policy). It lets the command's {path:read} files hold a private key (Upgrading, step 3), and its output then also gets the PEM-width masking described under Fixed.
  • An offline exposure check of the helper's units (N-28, S6-5, #65): scripts/exposure/run.sh, in scripts/ci-local.sh and a new exposure CI job, generates the core unit of the example and end-to-end privileged policies and rates it with systemd-analyze security --offline on systemd 255 (Ubuntu 24.04), 257 (Debian 13) and 259 (Ubuntu 26.04), images pinned by digest, failing above the score recorded in scripts/exposure/scores.txt.

Changed

  • Protocol version 2 (S6-2, #62; ARCHITECTURE §4.0), frozen from this tag: any later wire change is a new version. Mismatches behave as in Upgrading, step 1. Every peer checks the version of a request or response before any other action on it, which is what makes "a mismatch means nothing ran" true; it is now a stated requirement, with tests in the gate and the helper. The session hello (shell-mcp-gate/1) is unchanged.
  • Privileged #! scripts need an acknowledge (N-26, S6-3, #63), as in Upgrading, step 2. check-policy prints REVIEW script and the acknowledge on the command's line, and priv_policy reports a script finding. The gate is unchanged: its scripts run as the service account inside its sandbox, and keep the WARN.
  • The GTFOBins warning checks more (N-31 #63, N-33 #67): in both check-policy commands it also covers every interpreter on a #! script's chain, and matches a program or interpreter by binary identity as well as by name, so a hard link or renamed copy of a listed binary (sed, make, …) gets the warning, which names the listed program and how it matched. It is a warning only and never refuses a policy. Policy loads cost about 2% more with 250 commands.
  • The core unit hides /home, /root and /run/user (ProtectHome=yes) where nothing the instance needs is under them, otherwise read-only as before (N-28, S6-5, #65). For the e2e policy its systemd-analyze security score is 1.3 instead of 1.4, and the e2e threshold followed (a policy whose unit holds extra capabilities scores higher; scripts/exposure/scores.txt).
  • Both helper units' MemoryMax= follows limits.max_memory_mb (plus 256M, with MemorySwapMax=0 and OOMPolicy=continue) instead of the fixed 256M (core) and 1G (broad) (S6-1, #61).
  • The approval page never shows a private key (S6-4, #64): in any argument or preview value, each PEM private-key block, from its BEGIN line through the END line of the same label, is shown as private key, not shown: <bytes> bytes, sha256 <hex>, with the text around it as it is; a BEGIN without its END is masked to the end of the value. The approval still binds the real value. Before, the page showed up to 4096 bytes of a value, enough for a whole key. The two write tools' descriptions now say that content passes through the client and its model provider, and to generate private keys on the host.
  • git_diff leaves out files that hold a private key (S7-6, #72): every changed file that holds a key on either side is left out and named in a [REDACTED] "<path>": holds a private key; its changes are not shown line, so the output can start with such lines.

Fixed

  • A private key's body could reach the client without its BEGIN line through journal, command or diff output (N-35, S7-6, #72). A source that cuts its own slice before redaction, such as journalctl -n, a command printing a range of a file, or a diff hunk, could start inside a key's body. Now:
    • Every output: an END line of a private-key label with no BEGIN before it masks back to the start of the text, or to the previous mask.
    • Journal output also masks runs of 64- or 70-character base64 lines outside a shown PEM block (the PEM-width heuristic), keeping the timestamp prefix.
    • Commands: a {path:read} or {path:read:fd} naming a file that holds a key is refused unless the command declares reads_private_keys. A file above 256 MiB is not searched, and its command's output gets the heuristic.
    • git_diff: as under Changed. The hunk header git fills from the line above a hunk was a second way out.
  • Output redaction pairs a private-key block's labels (N-34, S7-1, #66): a block ends at the first END line of its BEGIN line's label, or at the end of the output. Before, any END line closed it, so in a malformed block such as BEGIN RSA … END EC … the text after the mismatched END was shown. The approval page uses the same finder.
  • The private-key refusal of file reads covers the whole file (S7-1, #66): read_file, priv_read_file and priv_hash_file looked for a key header only in the first 64 KiB, so a key further into a file could be returned from inside its body by offset or tail_lines. They now search the whole file up to 256 MiB, and above that the first 64 KiB, the requested window and the 1 MiB before it.
  • A copy's source is searched whole for a private key (S7-3, #68): the gate's copy and the helper's priv_copy looked only at the first 64 KiB, so a key past them was copied (never returned to the client). It is now refused, as reads are.
  • A gated shell_write_file over a file above 256 MiB is refused at its preview with too_large (S7-3, #68). Before, its preview had no hash, and the approved write was bound only to the file's size and mode.
  • The helper's reap of a command's leftover processes (S6-1 #61, S7-5 #70). It reports the real error when listing a command's children fails, retries within its bound, falls back to scanning /proc, and still answers outcome_unknown unless wait4 confirms none is left. After an OOM kill in the core unit the listing could still fail every time: the unit's Landlock rule holds the inode of the helper's /proc/<pid>, memory pressure could reclaim its dentry, and the path then reached a new inode the rule does not cover. A process the command had started in a session of its own then lived until systemd stopped the instance. The helper now reads its own /proc/<pid> only through an O_PATH descriptor opened before Landlock and kept for the instance's life. No unit, Landlock rule, policy or protocol change; the gate is not affected.
  • Listings over /proc no longer hide errors (S6-1, #61): the gate's check that no_new_privs holds on every thread fails when a thread cannot be read, and the task count behind RLIMIT_NPROC refuses to start a command when /proc cannot be counted, rather than dropping the limit.
  • The package operations' refusal of an unfinished database names the route that fits each package (S7-4 #69, S7-7 #73): the recovery, a removal of exactly the unfinished packages, or the reinstall. Before, every state got "run dpkg --configure -a", which leaves a half-installed or reinstreq package, and one with a missing dependency, as they were. The state is read with dpkg's journal folded in, as dpkg reads it, and the power operations' refusal says the same. The recovery is no longer offered when it would change nothing (only packages that need a reinstall or whose dependency is missing remain). The index update was never refused in this state, and need not be: apt-get update never opens dpkg's database (now documented).

Other merged changes

  • The 0.1.0 image digest pinned in deploy/, SECURITY §7 and CLIENTS, and the release recorded (#58, #59). The release notes and ARCHITECTURE §7 say which files carry provenance: every file SHA256SUMS lists, and the image; SHA256SUMS itself is covered by its signature (#59).
  • The post-release scoping of the open items after 0.1.0, docs/handoff/POST-RELEASE.md (#60).
  • The release workflow's loopback registry image updated (Dependabot, #71).

Decided, not built

  • A per-command sub-cgroup in the helper (N-32, S7-5). It would end a command's whole process tree atomically (cgroup.kill) and keep the command's memory apart from the helper's. Not built: systemd 255 (Ubuntu 24.04) cannot express the ProtectControlGroups=private it needs, private falls back to a writable cgroup tree where cgroup namespaces are missing, and both gains already fail closed (an OOM that ends the helper is answered outcome_unknown, never a success). Revisit when Ubuntu 24.04 (systemd 255) is no longer a supported target.
  • Installing a missing dependency while dpkg is unfinished (N-36, option (i)). Removing the unfinished package and then installing normally reaches the same state through bound paths, and an install in that state would configure packages no allow-list names.
  • Lifting the 256 MiB hashing cap of the overwrite previews, and the gate move's commit-side cap (N-5): deferred. An overwrite of a larger file is refused (too_large).

Not covered

  • What the dpkg recovery, removal and reinstall leave to an administrator on the host (N-36; PRIVILEGED §6, "What the recovery leaves"):
    • a failed upgrade that left a package needing a reinstall when the index no longer has the old version;
    • a package whose dependency is missing while an installed, configured package depends on it (removing it would remove a working package too, which the exact-set rule and apt refuse);
    • a package to configure together with one that needs a reinstall: the recovery reports verify_failed first, then the reinstall finishes it;
    • a package left half-installed with flag ok (classed as needing a reinstall; not measured);
    • a dependency present only at a version that does not satisfy it (classed "to configure", so the recovery is offered and reports what it could not finish).
  • Key text without its header that the N-35 changes do not catch (POLICY §3, "What is left"):
    • a command whose template writes a file's path literally, or whose program opens files by itself (from its configuration, or under a directory placeholder such as grep -r {path:read}): its input is not searched, and only the END rule applies to its output;
    • a file that holds a key's body without its header (not searched as a key);
    • a {path:read} swapped by the owning account between the search and the command's own lookup ({path:read:fd} closes it);
    • a journal window holding only a key's short last line, or a fragment shorter than one PEM-width line from an opted-in command.
  • A FIFO in a submodule's git files (N-25) makes a git operation wait until the request's timeout (30 s by default), with git's process group killed and nothing run. Accepted and documented (POLICY §7).

Verify

Image: ghcr.io/tyler-rich/shell-mcp:0.2.0@sha256:323149155f5be042949ec5291812104351f365a693dbdfb8cd2171b95ee30e6a (linux/amd64, linux/arm64). Pin the digest.

SHA256SUMS lists every release file except itself and the Sigstore bundles. The binaries, the examples archive and SHA256SUMS are signed with Sigstore keyless signing (<file>.sigstore.json). Every file SHA256SUMS lists, and the image index, carry SLSA build provenance; SHA256SUMS itself has no attestation (gh attestation verify SHA256SUMS finds nothing), and its cosign signature covers it. The binaries and the platform images also carry CycloneDX SBOM attestations. Only the identity below is a release of this version; anything signed by another ref is not.

Run the cosign verify-blob command for each binary you use, the examples archive and SHA256SUMS, and the gh attestation verify command for each file you use that SHA256SUMS lists.

cosign verify-blob --bundle shell-mcp-gate_0.2.0_linux_amd64.sigstore.json \
  --certificate-identity https://github.com/tyler-rich/shell-mcp/.github/workflows/release-build.yml@refs/tags/v0.2.0 \
  --certificate-oidc-issuer https://token.actions.githubusercontent.com \
  shell-mcp-gate_0.2.0_linux_amd64
sha256sum --ignore-missing -c SHA256SUMS
gh attestation verify shell-mcp-gate_0.2.0_linux_amd64 --repo tyler-rich/shell-mcp \
  --signer-workflow tyler-rich/shell-mcp/.github/workflows/release-build.yml --source-ref refs/tags/v0.2.0
cosign verify ghcr.io/tyler-rich/shell-mcp@sha256:323149155f5be042949ec5291812104351f365a693dbdfb8cd2171b95ee30e6a \
  --certificate-identity https://github.com/tyler-rich/shell-mcp/.github/workflows/release-build.yml@refs/tags/v0.2.0 \
  --certificate-oidc-issuer https://token.actions.githubusercontent.com
gh attestation verify oci://ghcr.io/tyler-rich/shell-mcp@sha256:323149155f5be042949ec5291812104351f365a693dbdfb8cd2171b95ee30e6a --repo tyler-rich/shell-mcp \
  --signer-workflow tyler-rich/shell-mcp/.github/workflows/release-build.yml --source-ref refs/tags/v0.2.0