Consolidate SSH security, shim hardening, and restored terminal replay fixes
Summary
This PR consolidates cmux’s SSH, relay, local-state, terminal-restore, and shim hardening into one reviewable change. SSH control masters now live in a private per-user directory and are separated whenever route or host-key policy differs. Remote exec and restored terminal surfaces retain their remote origin before OSC 52 callbacks can run, so remote output cannot overwrite the local clipboard.
It also hardens daemon and relay authorization, forwarding defaults, proxy credentials, local socket peer checks, shell shims, debug logs, wait-for state, remote links, browser proxy access, and Cloud/SSH replay restoration. The latest main merge is included through 79f62d7026a.
Security fixes
- Route-sensitive SSH options persist
ControlMaster=noandControlPath=noneacross repeated option merges; host-key and handshake policy changes cannot reuse a weaker%Cmaster. - Initial SSH/VM terminals, splits, session restores, respawns, dock restores, and Cloud VM attach replacements carry
isRemoteTerminalbefore runtime callbacks are active. - Remote OSC 52 clipboard writes are rejected for both manual mirrors and remote exec PTYs.
- Private socket, log, shim, marker, proxy-credential, and wait-for paths fail closed on symlinks, hard links, ownership mismatches, or unsafe permissions.
Validation
- Final local verification:
scripts/verify-local.py --allpassed 15/15 checks. - SSH route and host-key policy tests: 26 passed.
- Remote daemon timeout isolation: 2 passed.
- Remote clipboard trust regression: passed.
- Full Go daemon suite: passed.
- Hosted Rust verification for the exact PR SHA: run 36541783897 passed macOS/Linux tests, clippy, MSRV, and release-path checks after the runner retry.
- Gitleaks scanned 106 commits in the final range and found no leaks.
- Independent final GHSA-class audit found no verified P0, P1, or P2 issues. Receipt: 79f62d7-3fcb2b8-ghsa-final.json.
The combined PR’s two macOS lanes are still pending; I’m waiting for those required checks to finish before calling the PR fully green.
Changelog
- Fixed: Harden SSH and local state security, preserve remote terminal trust, and repair restored Cloud/SSH terminal rendering.