Skip to content

Signed self-update for machines and the hub - #12

Merged
skmp merged 10 commits into
mainfrom
skmp/self-update
Nov 28, 2026
Merged

skmp merged 10 commits into
mainfrom
skmp/self-update

Conversation

@skmp

@skmp skmp commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

Owner request (2026-11-27): a self-update API for Switchboard, for switchboard-remote and generally, with updates signed by a private key that stays on the WSL machine and verified by every machine before it applies one. Reason: a machine still on dispatcher 0.6.0 could not clear the input field.

Design

  • Release key: the owner's OpenSSH ed25519 key with a passphrase, on the WSL machine only. Signing and verifying are ssh-keygen -Y sign / -Y verify (OpenSSH 8.1+, namespace switchboard-release). No custom crypto, no new dependency on machines.
  • Bundle: a signed manifest.json (format, product, version (always the dispatcher file's own VERSION), minVersion, created, per file target, size, sha256) plus the three programs, as JSON lines (manifest as base64 + armored signature, then 256 KiB base64 chunks per file, then done); at most 1 MiB of files, 1.5 MiB in all, so it fits the 2 MiB serve frame.
  • CLI (owner's computer, no config): release build [--source deploy/remote], release sign --key ~/.ssh/switchboard_release <dir> (ssh-keygen prompts for the passphrase on the terminal itself), release verify --signers <file> <bundle>. Hub: release publish <bundle> verifies the signature with ssh-keygen -Y verify against the hub's own root-owned pinned signers file (remote.releaseSignersFile, default /etc/voice-coding-mcp/release_signers) plus every file's size and sha256, and stores nothing unverified (no signers file: nothing is published; refusals are release_refused incident events). release list, remote-update <machine> [--yes].
  • Dispatcher 0.13.0 update verb, only with the new --allow-self-update from the machine's own command line (refused with --policy-from-hub, unknown in a policy file). Order: size cap; install location checks (installed under its own name, dir/files not group/other writable, no symlinks); per-user lock; update record and the pinned ~/.config/switchboard-remote/release_signers (regular, user/root owned, not g/o writable, parents too); strict bundle parse with fixed target names only; namespace, OpenSSH version, ssh-keygen -Y verify with a fixed argv, private copies of signers and signature, minimal env, timeout; manifest + per-file size/sha256; strictly newer than the running version and than the highest version ever installed (survives rollback); minVersion; staged files (O_EXCL|O_NOFOLLOW, 0755, fsync) self-tested (compile, new dispatcher answers version with the manifest version, connector --version, hook version); then per file .prev copy + atomic rename, dispatcher last, restore on failure. All from bytes in memory after the hash check (no TOCTOU re-read).
  • Restart: forced-command machines run the new file on the next call. Serve mode exits 77 after answering; connector 0.13.0 reconnects at once and execs itself if its own file was replaced (a 0.12 connector just reconnects after backoff).
  • Rollback: switchboard-remote --rollback at the machine (refused under sshd) swaps .prev files; no hub verb (that would be a downgrade).
  • Hub tool remote_update(machine): re-verifies the stored bundle against the hub's signers file (a bundle swapped on disk after publish is refused), then reads back "update switchboard-remote on laptop from X to Y, signed by the release key SHA256:..., verified on the hub", new update confirmation kind, always risky (risky_ok, later turn), bound to the bundle's sha256; refuses old dispatchers with the bootstrap hint, self-update off, up to date, local machine. Every attempt is an incident-log event (update_installed / update_refused / update_unknown) and an audit line. list_remote_sessions / remote_status mention an older dispatcher than the published release; remote-check shows self-update allowed|off. CLI remote-update --yes works for agent machines through the hub's control socket (sha256-bound).
  • The hub itself: deploy/hub-update (stdlib, byte-identical to voice_coding_mcp/hub_update.py), run by hand: fetch one tag without forcing, annotated, tag object's own name equals the ref, points at a commit, git verify-tag with pinned /etc/voice-coding-mcp/release_signers (gpg.minTrustLevel=fully, no global/system git config), newer than the last installed tag, all by object id; checkout by commit hash, uv sync --frozen (back to previous commit on failure), restart. No automatic hub restart from a voice call.

Threat model (summary, full table in docs/SWITCHBOARD.md)

  • Hub check vs machine check: the hub's verification is a second, independent check that makes the read-back trustworthy; the machine's own verification stays the real gate (a compromised hub user can skip the hub's check).
  • Compromised hub: can only offer bundles the owner signed; it can call update without a confirmation, but can only install the newest signed release on machines with --allow-self-update, never an older, modified or its own one. The hub never writes the signers file.
  • Replay / downgrade: strictly newer than every version installed before (record kept across rollbacks), minVersion.
  • Key compromise on WSL: passphrase, dedicated key, separate namespace; revocation = replace the line in release_signers on each machine and on the hub.
  • Installer tricks: fixed target names (no paths from the bundle), strict JSON (duplicate keys refused), fixed ssh-keygen argv, in-memory bytes from check to write, atomic renames with .prev, self test before any rename.

Tests

New: tests/remote/test_dispatcher_update.py (real ssh-keygen, temp keys: accepted install with .prev, tampered manifest, tampered file, wrong namespace, wrong key, key without the namespace, unsigned/garbled, same/older version, replay after update, rollback keeps refusing, min_version, damaged record, unknown targets incl. traversal names, cut/reordered/padded bundles, short chunks, oversize, duplicate keys, signers file/dir permissions and symlink, missing signers, OpenSSH < 8.1 and missing, flag absent, flag refused from hub/policy file, not installed under its name, unsafe install dir/files/symlink, self test failures, failed rename restores, lock, forced command subprocess incl. --rollback, serve mode exit 77 and refused update), test_update_tools.py (read-back text, early / risky_ok / single use, bundle changed, old dispatcher, self-update off, up to date, local, list note, unknown outcome, incident events and audit), test_release_cli.py, agent end to end in test_agent_tools.py (update over the relay, exit 77, reconnect on the new version, remote-update --yes through the control socket), connector tests, tests/test_hub_update.py (temp git repo: signed, dry run, unsigned, foreign key, lightweight, renamed tag, downgrade, signers perms, dirty tree, missing git namespace, bad names). Tests skip with a message when ssh-keygen is missing or older than 8.1.

Gate (after the hub-verification follow-up): uv sync --locked, ruff check, ruff format --check, mypy --strict src tests clean; pytest (no -n): 2535 passed, 14 failed, 11 skipped under load average around 19; all 14 failures passed when rerun alone (13 in one rerun, the last one three times in a row), none in self-update code.

Bootstrap (once per machine, e.g. the one still on 0.6.0)

Exact commands are in docs/SETUP-AGENTS.md "Updating to 0.13.0: signed self-update". In short, on the machine as its user, from the owner's verified checkout:

cd ~/src/switchboard && git fetch && git checkout --detach <verified 0.13.0 commit>
less deploy/remote/switchboard-remote deploy/remote/switchboard-connect deploy/remote/switchboard-hook
install -D -m 755 deploy/remote/switchboard-remote ~/.local/bin/switchboard-remote
install -D -m 755 deploy/remote/switchboard-connect ~/.local/bin/switchboard-connect
install -D -m 755 deploy/remote/switchboard-hook ~/.local/bin/switchboard-hook   # if hooks are used
install -d -m 700 ~/.config/switchboard-remote
printf 'switchboard-release namespaces="switchboard-release" %s\n' 'ssh-ed25519 AAAA...' > ~/.config/switchboard-remote/release_signers
chmod 644 ~/.config/switchboard-remote/release_signers
awk '{print $3" "$4}' ~/.config/switchboard-remote/release_signers | ssh-keygen -lf -
# add --allow-self-update after --serve ... in ~/.config/systemd/user/switchboard-connect.service
systemctl --user daemon-reload && systemctl --user restart switchboard-connect

Then on the hub remote-check <machine> shows 0.13.0 with self-update allowed, and later releases go by voice ("update ").

Not merged; the hub must be updated before machines rely on the new verb (an older hub ignores it).

🤖 Generated with Claude Code

https://claude.ai/code/session_011moV3EPNNknRWZQ686AChh

skmp and others added 10 commits November 27, 2026 21:12
The new update verb (only with --allow-self-update on the machine's own
command line) verifies a release bundle with ssh-keygen -Y verify against
the pinned ~/.config/switchboard-remote/release_signers, checks every file
against the signed manifest, refuses versions not newer than any installed
before, self-tests the staged files and installs them atomically with .prev
copies. Serve mode exits 77 after an update; --rollback swaps .prev back.
remote/release.py builds and reads bundles with the dispatcher's own checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011moV3EPNNknRWZQ686AChh
Reads back both versions and the signing key, needs risky_ok in a later
turn, sends only the bundle bytes read back, records every attempt as an
incident log event and an audit line, and notes older dispatchers in
list_remote_sessions and remote_status.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011moV3EPNNknRWZQ686AChh
…e additions

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011moV3EPNNknRWZQ686AChh
release publish verifies a bundle against the hub's own root-owned pinned
signers file (remote.releaseSignersFile) with the dispatcher's ssh-keygen
check and every file's size and SHA-256, and stores nothing unverified.
remote_update verifies the stored bundle again, so a bundle swapped on disk
is not offered, and the read-back names the signer verified on the hub.
Refusals are release_refused events of the hub. The machine's own check
stays the gate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011moV3EPNNknRWZQ686AChh
@skmp
skmp merged commit 21dcb2e into main Nov 28, 2026
@skmp
skmp deleted the skmp/self-update branch November 28, 2026 02:27
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