Repository navigation
Releases
v0.3.0
Setup commands that write every file the hand steps of TARGET-SETUP and deploy/README.md write, and a security fix for targets set up with 0.1.0's or 0.2.0's TARGET-SETUP that run the privileged helper: on those, the new gate refuses the read-only and operator keys until they move to a second service account (Upgrading, step 2). Protocol version 2, the tool catalogue, both policy schemas and the helper's units are unchanged from 0.2.0, so a 0.2.0 server works with a 0.3.0 gate and the reverse. The design record behind each change is docs/ARCHIVE.md §14, sessions S8-scope to S8-4 and PRs #77 to #94.
Security
- The gate refuses a key without privileged forwarding on the helper's socket-group account (#90). A GitHub security advisory accompanies this release.
- Who is affected: a target set up by 0.1.0's or 0.2.0's TARGET-SETUP with the privileged helper installed, where a key whose gate policy has no
privileged.enabled: true(a read-only or operator key) is on the same service account as the admin key. Those documents put every key on one account (svc-shell) and added it to the helper's socket group. A target without the helper, or whose only keys on that account forward to the helper, is not affected. - What could happen: below Landlock ABI 9 (every kernel this project is tested on; the CI runners have ABI 8) the gate's sandbox does not govern a connect to a pathname Unix socket. The socket's permissions (
root:svc-shell-priv 0660) and the helper's peer-UID check (client_uid) were all that stood between such a key's commands and the helper, and both passed. Human approval is enforced by the server, not the helper (PRIVILEGED §3). So a compromised server holding the read-only key, with any declared read command able to open a Unix socket, could ask the helper for root actions without any approval, up to what the privileged policy allows. Shown in containers before the fix: a read-only policy's command, inside the gate's own sandbox, got an answer from the helper. - What changes: when a policy has no privileged forwarding and the gate's process belongs to the group that owns
/run/shell-mcp/privd.sockor/run/shell-mcp/privd-broad.sock(read from the socket files; the gate never reads the privileged policy), the gate refuses every request withinstall_insecure, before the sandbox and before any byte of the request,helloincluded: "this account is in the privileged helper's socket group and this policy has no privileged forwarding: serve the keys without forwarding from a second service account outside that group …". It also refuses when/run/shell-mcpcannot be inspected.check-policyas the account printsFAIL install: gate process belongs to group "svc-shell-priv" …, andshell-mcp doctorandshell-mcp checkshow the refusal for the target. The admin key keeps working; the helper, its policy, its units and its socket group are unchanged. - What to do: Upgrading, step 2. SECURITY §2 ("Shared service account") and §5 item 8 state the rule: one account per privilege level.
- Who is affected: a target set up by 0.1.0's or 0.2.0's TARGET-SETUP with the privileged helper installed, where a key whose gate policy has no
Upgrading from 0.2.0
The full steps, with what each command does on a host set up by hand, are README's "Upgrading from 0.2.0" and TARGET-SETUP §4, §7, §8 and §12.
- Install the new
shell-mcp-gateandshell-mcp-privdon every target, then the new server image. The protocol is unchanged (version 2), so the order is free and nothing is refused for a version mismatch; both start per request, so nothing on the target restarts. The server restart drops pending approvals, as on every upgrade. - Targets with the helper: move every key without privileged forwarding to a second service account (required; the security fix). Do it in the same window as step 1: the new gate refuses those keys on the shared account.
- Create the account with
install, with the first key you move: that key's own flags (policy, principal,from=list,.pubfile) and--user svc-shell-std --uid 60125 --gid 60125(your own unused ids; never the socket group). Run it with--dry-runfirst. It appends the account'sMatchblock to the sshd drop-in, writes its keys file with the key's line byte for byte as the old one, its slice drop-in and, withservices.control, its polkit rule (60-shell-mcp-svc-shell-std.rules), checks the policy as the new account and reloads sshd. The key then logs in as either account. An account's keys must agree on the journal: keys whose policy has a journal section and keys whose policy has none go to different accounts. - Give the moved policies' write roots and repositories to the new account (
chown -R svc-shell-std: <root>). - On the server, set the target user of each moved key's instance to the new account (
SHELL_MCP_TARGET_USER=svc-shell-std, oruser:in the targets file), thendocker compose up -d. The host-key pin, the key andfrom=are unchanged. shell-mcp-gate move-key --principal <label> --from-user svc-shell --to-user svc-shell-std, one run per key. For a keyinstallalready put on the new account it finishes the move; any other key's line moves byte for byte with its polkit rule. It refuses the admin key, which stays onsvc-shellwith everything about the helper.- If
svc-shellwas insystemd-journalonly for keys that moved, remove the membership:usermod -r -G systemd-journal svc-shell(installfor the admin key refuses it otherwise). installfor each key of either account, andmove-keyagain, then report every itemunchanged.
- Create the account with
- Optional: adopt the setup commands. On a host set up by hand as TARGET-SETUP says,
shell-mcp-gate installwith the flags that describe it, andshell-mcp-privd install --accept <sha256>over unitsunitsgenerated from the same policy, report every itemunchangedand write nothing; any difference is refused with a diff, never overwritten.policy newnever overwrites a hand-written policy, and is optional: from the example answers files it writes 0.2.0's example policies with their comments rearranged, and with one value changed inadminand the privileged policy, both of which now carry the union of the two examples' deny lists (README, "Upgrading from 0.2.0", step 6). On the server,initrefuses 0.2.0's by-hand secrets directory until it belongs to the image's user:chown -R 65532:65532 secrets, after which it keeps every file.init composeprints the reference compose with your values; diff it against your file before using it. - Check:
shell-mcp doctorin the server's container (docker compose exec shell-mcp /shell-mcp doctor),check-policyas each service account, andjournalctl -t shell-mcp-gatefor the install commands' audit lines.
Added
shell-mcp-gate install(S8-1, #79; several accounts per host since #94): the service account (locked withusermod -L, never the setuidpasswd), its memory slice, its polkit rule, itsMatchblock in the sshd drop-in and the key line, last;check-policyas the account,sshd -tandsshd -T -Cfor every account and for a name that is not one, the reload, and the host-key pin, read locally. It refuses afrom=wider than/24or/64(no override), a key with options, a private key or a host key, ids below 1000 or in use, any file on the host owned by a new id (the owner scan), any supplementary group butsystemd-journal(journal section) and the socket group (privileged forwarding), and every file with other content, with a diff. OneMatchblock per account in the one drop-in; polkit rules60-shell-mcp.rulesfor the first account and60-shell-mcp-<user>.rulesfor others. Idempotent, with--dry-run, rollback of every file on a later failure, temp files that a failed run removes, and one audit line per change or refusal (TARGET-SETUP §12.1, §12.4).shell-mcp-gate move-key(#94): moves one key line between two accountsinstallmade, byte for byte, with its polkit rule, in one transaction with rollback and a read-back of both files. It refuses a key with privileged forwarding and a destination whose groups the moved policy does not allow; it finishes a moveinstallbegan, and a second run reportsunchanged(TARGET-SETUP §12.1, "Moving a key between accounts").shell-mcp-gate host-key(#79): the pin lines from the host's own.pubfiles, as any user, never from the network.shell-mcp-privd install(#79): the fullcheck-policy, then the review (everyREVIEWline and the policy's SHA-256), and nothing written without--accept <that sha256>, on every run; the backup store, the units exactly asunitsgenerates them,systemd-analyze verifywith rollback, the sockets enabled, a socket restarted only when its own file changed, an unused broad pair disabled and removed, and the exposure score (TARGET-SETUP §12.3).policy newin both binaries (S8-3, #83): the gate policy and the privileged policy from one answers file and a preset (read-only,operator,admin), rendered fromexamples/with their comments and loaded strictly by each binary's own loader before anything is written. The answers file is strict (unknown keys, duplicates, wrong types refused), and its comments are untrusted: each line gets its own#prefix, control characters and the Unicode line and paragraph separators are refused, and a comment is bounded.examples/policies/*.answers.yamlreproduce the examples byte for byte (POLICY §9).shell-mcp initandinit compose(S8-2, #82).initwrites the bearer token, the SSH key pair and, with--approver, the approvers file, owned by the image's user, in the image with no network and no capabilities; it never prints the token or the key, keeps every existing file, and refuses wrong owners, modes and keys rather than repair them. The approver's seed is shown on a terminal only: without one,--approveris refused before anything is written.init composeprints the reference comp...
v0.2.0
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
-
Upgrade
shell-mcp,shell-mcp-gateandshell-mcp-privdtogether. 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 withprotocol_mismatch, naming both versions and which side to upgrade, and nothing runs; it is never reported asoutcome_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. -
Add an
acknowledgeto 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-lineacknowledge./usr/local/libexec/shell-mcp-privd check-policy --policy /etc/shell-mcp/privileged.yamlfails on each such command until it has one, and then prints it asREVIEW script. An interpreter on the never list is still refused, acknowledged or not. -
Add
reads_private_keys: trueto any command whose{path:read}legitimately takes a private-key file (for exampleopenssl pkey -puboutorssh-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 withpath_denied, at the preview too. Set it only for a program that never prints part of its input;check-policywarns when it is set on a range or filter program (tail,head,sed,cut,grepand the others in POLICY §4). -
Review
limits.max_memory_mbandpackages.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 examplejqon very large files). The helper's units take theirMemoryMax=from it (step 5).packages.allow_recover(privileged policy; defaultfalse) enablesshell_priv_recover_packages. Leave it off unless you want dpkg recovery through the tools.
-
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=tolimits.max_memory_mbplus 256M, withMemorySwapMax=0andOOMPolicy=continue, and the core unit getsProtectHome=yesunless a root, command, interpreter or the policy file lies under/home,/rootor/run/user, contains one of them (a read root of/or/run), or cannot be resolved; then it staysread-only, as before, andcheck-policynames 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' fixedMemoryMax=(256M core, 1G broad, withoutOOMPolicy=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. -
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; thenshell-mcp checkfrom 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_packagesandshell_priv_reinstall_packages; new descriptions forshell_write_fileandshell_priv_write_file; new output schemas forshell_get_policy,shell_run_read_command,shell_run_command,shell_priv_run_commandandshell_priv_preview_packages(whose input also changed: thereinstalloperation).
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 asRLIMIT_DATA, soft and hard, before the child's first instruction. A command that reaches it fails its allocation, and that is its result, neveroutcome_unknown. git's thread counts are pinned (pack.threads=4,index.threads=1,checkout.workers=1and the others ingitx), so a git operation's memory need does not follow the host's CPU count.check-policyreports the limit and the units'MemoryMax=, and warns when the kernel'signore_rlimit_datais 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 recommendsMemoryMax=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/4and 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_commandandshell_run_commandreport the descriptors (fds), and an approved command is bound to each file's identity.check-policychecks/dev/fdand warns about programs measured to give wrong results with a descriptor:stat,du,file,lsandfindwithout following links,cp -a/-P/-r,taradding a member,findmnt,nginxanddocker 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_filein the helper andhash_filein the gate (underread_file's path rules, refused above 256 MiB). The previews ofshell_priv_write_file,shell_priv_copy_pathandshell_priv_move_path, and ofshell_write_file,shell_copy_pathandshell_move_pathwhen 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 gainprivate_key(and a write'snew.private_key).shell_read_fileandshell_priv_read_filestill 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; needspackages.allow_recover: true) runsdpkg --force-confold --configure --pendingas 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 atlimits.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_packagesaccepts 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), andreinstallas an operation ofshell_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 (defaultfalse), shown incheck-policyand 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, inscripts/ci-local.shand a newexposureCI job, generates the core unit of the example and end-to-end privileged policies and rates it withsystemd-analyze security --offlineon systemd 255 (Ubuntu 24.04), 257 (De...
v0.1.0
The first release: an MCP server that gives AI clients bounded, audited read and write access to Linux hosts over SSH, without a shell.
What it contains
- Three binaries, static, for linux/amd64 and linux/arm64:
shell-mcp(the MCP server, also shipped as a distroless, non-root container image),shell-mcp-gate(the SSH forced command on each target) andshell-mcp-privd(the optional privileged helper for root actions). - The server. Streamable HTTP with a bearer token (MCP 2026-07-28 and 2025-11-25), or stdio. Host and Origin allow-lists, per-client rate limits and an auth-failure lockout, trusted proxies by address. Pinned SSH host keys only, Ed25519 client keys, no agent, forwarding or PTY. Three profiles:
read-only(19 tools, the default),operator(27) andadmin(50).shell-mcp checkverifies every target;shell-mcp toolsprints the catalogue with schema hashes. - The gate. One request per SSH session, checked against a root-owned policy on the target: read and write roots, a built-in deny list and protected set, exact unit and verb lists, pinned git repositories, and declared commands as exact argv templates with typed placeholders. Before it reads a request it sets
no_new_privsand a Landlock sandbox computed from the policy, inherited by everything it runs. Shells, interpreters, wrappers, pagers, editors and privilege changers are refused under any name, including through hard links, renamed copies, multi-call binaries and#!interpreters. Writes are atomic and read back; deletes and git discards remove exactly what their preview listed, or stop. Service control is authorized by a generated polkit rule.check-policyreports what the gate would refuse before it is asked. - The privileged helper. Root actions without sudo, setuid or a root shell: a socket-activated process per request that authenticates the gate's account by kernel peer credentials, applies its own root-owned policy, and runs in a systemd sandbox generated from that policy and pinned to its hash. File operations as root with backups and restore, chown and chmod, declared root commands, apt package operations bound to an approved transaction of exact versions, and a delayed, cancellable reboot or power-off through logind.
- Human approval. Destructive operations and every privileged change need a person's approval on the server's own approval page, with a TOTP code from an enrolled approver's authenticator, bound to the exact operation, its preview and both policies, single-use and short-lived. The model cannot approve. Approvals are off by default (gated tools refuse), and a logged
confirm-argumentopt-out exists for those who accept the model approving. - Supply chain. Every file in a signed
SHA256SUMS; cosign keyless signatures, SLSA build provenance and CycloneDX SBOM attestations for the binaries and the image, all bound to the release workflow at the release tag. Every dependency, image and tool at its newest stable release, enforced in CI. - Documentation.
docs/TARGET-SETUP.md(target hosts),docs/CLIENTS.md(clients, profiles, approvals), the normative design documents, example policies and a hardened reference deployment.
Known limitations
- Targets must be Linux with systemd and a kernel with Landlock ABI 4 or newer (Linux 6.7+); tested on Debian 13, Ubuntu 24.04 and Ubuntu 26.04. The helper's sandbox is exercised end to end on Ubuntu 26.04 only.
- Package operations use apt only. Git LFS repositories, repositories on case-folding filesystems, and git repositories that an account other than root or the service account owns or can write are not supported by the git tools; submodules are never entered.
- Deletes and moves are refused on filesystems without
RENAME_NOREPLACE(for example NFS), and verified replaces on those withoutRENAME_EXCHANGE. - UDP is not restricted by the gate's sandbox (the target kernels cannot govern it).
- Approvals live in memory and are lost when the server restarts. MCP elicitation is not used for approval; clients relay the approval page's URL instead.
- OAuth is not supported: keep the server on a LAN or VPN, behind a TLS-terminating proxy, never on the public internet.
- One profile per server instance; run several instances for several ceilings.
Open items after this release
- N-5: an approved copy or move over an existing file cannot be approved when that file is larger than 256 MiB or starts with a private key, because the preview hashes it through the read operation. Workaround: delete the destination first (its own approval), then copy or move without overwriting.
- N-22: a declared command's
{path:read}is passed as a path, not as the descriptor the gate checked, so an application account that owns a directory on that path can redirect what the command reads to another file the service account can read. Planned as an opt-in per template. - N-25: an account that can write a git submodule's directory in a listed repository can make git status, diff, pull and discard wait until their timeout (a FIFO in the submodule's git files). Nothing runs; the request times out.
- N-26: a declared command that is a
#!script is judged by its interpreter; what the script itself runs is not inspected. Review every script you declare, above all in the privileged policy.
Verify
Image: ghcr.io/tyler-rich/shell-mcp:0.1.0@sha256:9c19075aadb69950eb71d69d840e64ba021fcabf22c7df32a76a229d3c387dd4 (linux/amd64, linux/arm64). Pin the digest.
Every file is listed in SHA256SUMS. The binaries, the examples archive and SHA256SUMS are signed with Sigstore keyless signing (<file>.sigstore.json), and every file and the image carry SLSA build provenance; the binaries and the images also carry CycloneDX SBOM attestations. Only the identity below is a release of this version; anything signed by another ref is not.
cosign verify-blob --bundle shell-mcp-gate_0.1.0_linux_amd64.sigstore.json \
--certificate-identity https://github.com/tyler-rich/shell-mcp/.github/workflows/release-build.yml@refs/tags/v0.1.0 \
--certificate-oidc-issuer https://token.actions.githubusercontent.com \
shell-mcp-gate_0.1.0_linux_amd64sha256sum --ignore-missing -c SHA256SUMSgh attestation verify shell-mcp-gate_0.1.0_linux_amd64 --repo tyler-rich/shell-mcp \
--signer-workflow tyler-rich/shell-mcp/.github/workflows/release-build.yml --source-ref refs/tags/v0.1.0cosign verify ghcr.io/tyler-rich/shell-mcp@sha256:9c19075aadb69950eb71d69d840e64ba021fcabf22c7df32a76a229d3c387dd4 \
--certificate-identity https://github.com/tyler-rich/shell-mcp/.github/workflows/release-build.yml@refs/tags/v0.1.0 \
--certificate-oidc-issuer https://token.actions.githubusercontent.comgh attestation verify oci://ghcr.io/tyler-rich/shell-mcp@sha256:9c19075aadb69950eb71d69d840e64ba021fcabf22c7df32a76a229d3c387dd4 --repo tyler-rich/shell-mcp \
--signer-workflow tyler-rich/shell-mcp/.github/workflows/release-build.yml --source-ref refs/tags/v0.1.0