Skip to content

Security Review: Joining the Hoard by Invite

  • Target spec: docs/superpowers/specs/2026-11-23-join-by-invite-design.md (wip/bootstrap-design @ 75204be)
  • Date: 2026-11-23
  • Scope: Cryptographic protocol design, certificate chaining, key lifecycle, tailcat v0.7.0 and golang.org/x/crypto v0.59.0 interactions, and Linux/macOS privilege boundaries (deploy/linux/install.sh, internal/sshsrv, internal/client, internal/transport, and the plan-2 macOS runner).

Summary Verdict

The overall architecture is strong and improves security over manual bootstrapping:

  • Normal runner access has four independent gates: the runner's secret 256-bit WireGuard PresharedKey in its tailcat address, tailcat's AllowedClients node-key filter, the owner-signed versioned PinnedSet of SSH client public keys, and a live 24-hour owner.pub -> day-key -> client-cert chain enforced on open connections as well as handshakes.
  • Dropping any key-file fallback for the owner key and recommending Secretive's .biometryCurrentSet mode makes the 24-hour stolen-laptop cutoff real rather than aspirational.
  • Verification of the Apple documentation note (spec lines 255–258): Confirmed. In Apple's Security.framework (SecAccessControlCreateWithFlags), .biometryCurrentSet requires Touch ID matching the currently enrolled fingerprint set, does not fall back to the macOS login password or Apple Watch, and permanently invalidates the Secure Enclave key if any fingerprint is added or removed. .userPresence permits login-password fallback when Touch ID is declined or unavailable.

Before locking the spec for implementation, three High-severity issues (an offline SAS-grinding MITM on the join fingerprint, missing verifier-side bounds on day-key certificates, and a Linux allmyram-runner -> root privilege-escalation surface during allmyram join), six Medium-severity protocol/state-machine gaps, and four Low-severity hardening items should be addressed in the design.


High-Severity Findings

H1. Active MITM Can Offline-Grind Short Join Fingerprints (Missing Commitment + Static Laptop Payload)

Spec section: Joining a runner, steps 3–4 (lines 333–347) and Left to the builder (lines 482–485).

Issue: If an attacker intercepts the invite delivery channel (e.g., clipboard/chat/terminal paste), substituting <attacker_invite> on the runner while dialing <real_invite> on the laptop, the current step 3–4 exchange allows offline brute-forcing of a short fingerprint so both screens display the exact same code:

  1. Every value the laptop sends in step 3 (owner.pub, pinned client key/set, client tailcat node key, tailnet-peer IP) is static across joins, and the invite's ServerPublic key is already known from <invite>.
  2. Even if fresh random nonces are added to both sides, whichever peer sends its step 3 message second sees the entire transcript prefix first and can grind its own payload offline before replying (for example, grinding the random 256-bit PresharedKey inside runnerTailcatAddr, or grinding a nonce).
  3. Against the laptop: the attacker connects to <real_invite>, reads the laptop's step 3 message, and grinds runnerStep3 to match the target fingerprint already shown on the runner's <attacker_invite> screen.
  4. Against the runner: if the runner speaks first instead, the attacker completes step 3 on <real_invite> first (fixing F_target on the laptop), then accepts the real runner on <attacker_invite>, reads realRunnerStep3, and grinds fakeLaptopStep3 to match F_target.
  5. Grinding SHA-256 takes ~2 ms for a 6-digit (20-bit) code on one CPU core, and under 1 second for a 32-bit code on modern hardware — well inside a normal join pause.

Recommendation: 1. Commit-then-reveal in step 3: - Laptop generates a fresh 256-bit laptopNonce and sends commit = SHA-256("allmyram-join-commit-v1\x00" || laptopNonce || laptopMsg) first. - Runner receives commit and sends runnerNonce (256-bit) || runnerMsg. - Laptop receives the runner's message and reveals laptopNonce || laptopMsg. - Runner verifies commit in constant time before computing or displaying the fingerprint. Neither side can grind in either direction, bounding any active MITM to a single online guess with probability \(2^{-k}\). 2. Unambiguous transcript framing + PSK binding + minimum SAS length: - Hash length-prefixed records with an explicit domain tag ("allmyram-join-sas-v1\x00") and direction byte, rather than raw concatenation, and include the invite's PresharedKey alongside ServerPublic and dialingNodePublic. - Specify a minimum fingerprint entropy floor in the spec rather than leaving length unconstrained (e.g., at least 30–40 bits such as 8–10 base32/alphanumeric characters or 3–4 words; with commitment, even 6 digits gives \(10^{-6}\) single-shot security, and 4 words / ~44 bits eliminates lucky guesses too).


H2. Verifiers Do Not Cap day-key Certificate Span, and Host-Certificate Chaining Bypasses CertChecker.CheckCert Invariants

Spec section: The day key (lines 205–244).

Issue: 1. Unbounded day-key lifetime on verifiers: Secretive's Touch ID dialog only displays "Secretive wants to use key …" — it cannot show what lifetime is inside the SSH certificate bytes being signed — and SSH_AUTH_SOCK is accessible to every process under the laptop user's UID. Lines 219–221 define a valid day-key certificate as: signed by owner.pub, UserCert, and ValidPrincipals == [dayKeyPrincipal]. No upper bound on ValidBefore - ValidAfter is enforced by runners or clients. A rogue process piggybacking on one expected Touch ID tap (or acting moments before laptop theft) can ask the agent to sign a day-key certificate with ValidBefore = now + 10 years, permanently defeating the 24-hour cutoff without needing Touch ID again. 2. Host-certificate verification edge cases when dayCert is expired: Because a host certificate stays valid up to 30 days after its dayCert expires (hostCert.ValidBefore <= dayCert.ValidBefore + 30d), the client cannot call ssh.CertChecker.CheckCert at time.Now() on dayCert. Any custom check written around CertChecker must still explicitly enforce every non-expiry check that CheckCert and sshsrv perform: - Integer wrap / CertTimeInfinity: If dayCert.ValidBefore == ssh.CertTimeInfinity (0xffffffffffffffff), dayCert.ValidBefore + 30*86400 wraps uint64 (and int64(CertTimeInfinity) is -1). Likewise hostCert.ValidBefore == CertTimeInfinity or clientCert.ValidBefore == CertTimeInfinity must be rejected. - Post-dated dayCert: dayCert.ValidAfter <= now and dayCert.ValidAfter < dayCert.ValidBefore must still hold when checking a host certificate. - CriticalOptions: sshsrv/server.go:66 rejects len(cert.CriticalOptions) > 0 because CertChecker.Authenticate otherwise accepts source-address options that sshsrv drops; dayCert and hostCert must also require len(CriticalOptions) == 0. - Explicit authority chain on the client: Lines 233–237 should state explicitly (as line 390 does for the runner) that the client verifies dayCert's signature under owner.pub and checks bytes.Equal(hostCert.SignatureKey.Marshal(), dayCert.Key.Marshal()) plus hostCert's signature under dayCert.Key.

Recommendation: Specify the exact verification rules on both client and runner: - Reject ValidBefore == ssh.CertTimeInfinity on all certificate types (day-key, client, host). - Require len(CriticalOptions) == 0 on all certificate types, including the embedded dayCert. - Enforce hard verifier-side lifetime ceilings: - dayCert: ValidAfter <= now, ValidBefore > ValidAfter, and ValidBefore - ValidAfter <= 24h + 2*backdate (e.g., 24h10m). - clientCert: ValidAfter <= now < ValidBefore, ValidBefore <= dayCert.ValidBefore, and now < dayCert.ValidBefore. - hostCert: ValidAfter <= now < ValidBefore, ValidBefore - ValidAfter <= 30d + 2*backdate, and ValidBefore <= dayCert.ValidBefore + 30d (computed safely after bounding dayCert.ValidBefore).


H3. Running allmyram join as root on Linux Creates an allmyram-runner -> root Privilege-Escalation Surface and File-Ownership Mismatch

Spec section: Constraints (lines 93–98), Joining a runner steps 2 & 5 (lines 328–332, 350–354), Host certificate renewal (lines 398–401), Removing and revoking (lines 425–429).

Issue: deploy/linux/install.sh carefully isolates allmyram-runner (the network-facing daemon) so that compromising allmyram-runner never grants root or allmyram-warden. Under this design: 1. /var/lib/allmyram/runner/state (0700, owned by allmyram-runner:allmyram-runner) holds tailcat-key.json, the host certificate, and the signed PinnedSet. 2. Step 2 runs allmyram join as root. On a rejoin of an existing host, root reads and writes files inside allmyram-runner-controlled /var/lib/allmyram/runner/state (e.g., reading tailcat-key.json and comparing the existing PinnedSet version per line 426). Standard os.ReadFile / path traversal inside a service-writable directory allows a compromised allmyram-runner to plant symlinks or swap paths so root reads or clobbers root-owned files. 3. Conversely, on a first join, files written by allmyram join running as root with 0600 (transport.writeJSON / writeFileAtomic) will be owned by root:root, causing allmyram-runner to fail with EACCES on startup unless explicitly chowned. 4. Running allmyram join as root executes Tailscale's userspace WireGuard engine, gVisor netstack, TLS/HTTP DERP client, STUN probes, and join wire deserialization as root, contradicting install.sh's principle that no network-facing Go service runs as root. 5. Config JSON injection in install.sh: Today deploy/linux/install.sh:370–384 interpolates /etc/allmyram/tailnet-peer and /etc/allmyram/allowed-clients directly into /etc/allmyram/runner.json via unescaped shell heredocs ("egress_check_tailnet_peer": "$(cat "$etc/tailnet-peer")"). That is only safe today because install.sh validates CLI flags up front; if join writes network-supplied values without strict validation, a rogue laptop/invite could inject arbitrary fields (warden_socket, etc.) into runner.json.

Recommendation: - Stop allmyram-runner before join, generate /etc/allmyram/runner-host-key (root:allmyram-runner 0640) as install.sh already does, and run the network-facing allmyram join step as allmyram-runner (e.g., setpriv / runuser -u allmyram-runner) writing into /var/lib/allmyram/runner/state (or, if any part stays root, confine all state_dir access with Go 1.24+'s os.OpenRoot and fchown to allmyram-runner:allmyram-runner). - Have install.sh (or a Go config writer using json.Marshal) strictly validate owner.pub (ssh.ParseAuthorizedKey, plain key, not cert), allowed-clients (key.NodePublic.UnmarshalText), and tailnet-peer (netip.ParseAddr) before writing /etc/allmyram/runner.json.


Medium-Severity Findings

M1. Rejoining Under the Same owner.pub After Re-running allmyram init Silently Discards the New Client Key

Spec section: Setting up the laptop: allmyram init (lines 311–319), Joining a runner steps 3 & 5 (lines 334–335, 350–351), Removing and revoking (lines 423–429).

Issue: 1. Suppose ~/.config/allmyram on the laptop is wiped or moved to a fresh install while the same hardware owner key still lives in Secretive, 1Password, or a YubiKey. The owner runs allmyram init naming that same owner.pub (starting PinnedSet back at version 1 with a fresh client SSH key) and rejoins smaug (which previously reached PinnedSet version 5). 2. Under line 426 ("On a rejoin under the same owner key, the runner keeps whichever set has the higher version, its own or the join's"), smaug keeps version 5 (which pins only the deleted old client key), discards version 1, replies "done", passes install.sh's egress self-check, and then refuses every SSH connection from the laptop. 3. Related spec inconsistencies to clean up: - allmyram init (lines 313–316) omits creating and owner-signing initial PinnedSet version 1 (note this means init prompts Touch ID twice — once for PinnedSet v1 and once for the first day key — which should be stated explicitly). - Lines 335 and 350 still say step ⅗ sends and writes "the pinned client key", whereas line 423 says a join sends the owner-signed versioned PinnedSet.

Recommendation: - Update allmyram init and steps ⅗ to consistently use the owner-signed PinnedSet. - Have the runner include (currentOwnerPub, currentPinnedVersion) in its step 3 join message (or fail the join explicitly if the winning PinnedSet does not contain the joining laptop's SSH client public key). When currentOwnerPub == owner.pub and currentPinnedVersion >= laptopVersion without the laptop's key pinned, invite can advance the laptop's version to currentPinnedVersion + 1 and owner-sign the updated PinnedSet (with Touch ID) during approval.


M2. Permanent Self-Lockout If allmyram revoke Unpins the Last / Active Client Key

Spec section: Removing and revoking (lines 435–447).

Issue: PinnedSet changes are pushed over SSH authenticated by a currently pinned client key. Although lines 442–447 describe the safe manual rotation sequence (pin new -> wait for all runners -> revoke old), allmyram revoke <key> is exposed as an independent library/CLI function. If the owner accidentally runs revoke on the only pinned client key (or revokes the active key before a replacement key has been pinned and acknowledged), every reachable runner accepts the new set, closes the SSH connection, and becomes permanently unreachable over SSH (even holding the owner key), requiring root --join on every runner.

Recommendation: - Refuse empty PinnedSets (len(keys) == 0) on both the laptop signer and the runner verifier. - Have revoke refuse (unless explicitly overridden) to unpin the laptop's currently active client key unless another client private key present on the laptop is already in the PinnedSet version acknowledged by all runners in client.json — or expose key rotation as a single stateful rotate-client-key operation that enforces the two-phase sequence automatically.


M3. Domain Separation, Canonical Encoding, and Agent-Signature Verification for Owner-Signed Objects

Spec section: Members, roles and the owner key (lines 197–202), Removing and revoking (lines 415–423), Left to the builder (line 492).

Issue: 1. Cross-object signature domain separation: The owner key signs two different structures via ssh-agent: OpenSSH user certificates (day-key) and PinnedSet updates. Leaving PinnedSet's wire format open to the builder risks cross-protocol confusion or non-canonical JSON serialization bugs (whitespace, field ordering, duplicate JSON keys). 2. Unverified agent return values: ssh.Certificate.SignCert sets c.SignatureKey = authority.PublicKey() without verifying the signature returned by authority.Sign(...). A misconfigured or hijacked SSH_AUTH_SOCK returning a signature from the wrong key or corrupted bytes would be saved locally and only fail later when dialing runners.

Recommendation: - Define PinnedSet's signed payload as a canonical binary/SSH-marshaled structure starting with a fixed ASCII domain tag that cannot collide with OpenSSH PROTOCOL.certkeys (e.g., "allmyram-pinned-clients-v1\x00"), containing owner.pub, uint64 version (1 <= version < math.MaxUint64), and sorted, deduplicated length-prefixed Marshal()ed public keys. - Always verify every signature returned by ssh-agent against the pinned owner.pub on the laptop before writing the day-key certificate or PinnedSet to disk.


M4. tailcat v0.7.0 Transport Subtleties in invite / join (80-Bit Peer-IP Collisions, Ephemeral Dial Key, DrainTCP, and Multi-Join UI Listeners)

Spec section: How the two machines find each other (line 133), Joining a runner (lines 323–378).

Issue: Inspecting github.com/tailscale/tailcat@v0.7.0 highlights four implementation hazards: 1. onMeow runs before WireGuard PSK auth & PeerEnv maps peers by an 80-bit prefix (tcAddrForKey): On a tailcat.Server with AllowedClients == nil, locoBackend.onMeow (tailcat.go:1670) accepts unauthenticated MeowPing frames over DERP without requiring PresharedKey. An untrusted DERP relay (explicitly untrusted in tailcat's PSK threat model) observes the runner's dialing NodePublic and can send a forged FrameRecvPacket MeowPing whose srcKey shares the first 10 bytes (r[:10]), colliding AllowedIPs (fd7a:115c:a1e0:<80 bits>/128) and making peerByIP (Server.PeerEnv) map iteration ambiguous. In addition, if join dialed the invite using the runner's permanent serverKeyFile.Private, the DERP operator would link the invite session to the runner's long-lived server NodePublic. 2. Userspace TCP truncation on join exit (DrainTCP): tailcat runs gVisor netstack in-process. As tailcat.Client.DrainTCP warns, closing net.Conn and exiting allmyram join right after writing "done" in step 5 can drop the buffered TCP segment/FIN before WireGuard transmits it, causing intermittent split-brain failures (runner configured, client.json not updated). 3. Reusable listener in a future UI (line 133 vs. line 326): Line 133 notes "A future UI can keep a listener open and show joins as pending". A long-lived listener with AllowedClients == nil would make its invite reusable after a runner joins, violating single-use invite semantics if an invite ever leaked. 4. Port filtering, stall DoS, and payload bounds: transport.Listen currently leaves ServedTCPPorts nil and bounds nothing above TCP. On an open-client invite server, a connection that opens TCP and sends nothing would hold the single-connection slot for the full 15 minutes unless step 3 has its own short deadline.

Recommendation: - Have allmyram join dial the invite with a fresh ephemeral key.NewNode() (never the runner's permanent serverKeyFile.Private), include that ephemeral NodePublic inside step 3, and have the laptop cross-check it against Server.PeerEnv's TAILCAT_PEER_KEY. - Have allmyram join either wait for an explicit closing acknowledgement byte/EOF from the laptop after "done" or call Client.DrainTCP with a short timeout before exiting. - Clarify at line 133 that even in a UI, each generated invite is a single-connection, time-bounded throwaway tailcat.Server, never a multi-join listener. - On the invite tailcat.Server, set ServedTCPPorts to only the join port, never write key/.addr files to disk, apply a short step-3 exchange deadline (e.g., 30s from TCP accept to transcript ready) separate from the human approval wait, and bound all join messages (and new SSH commands) with io.LimitReader (e.g., 64 KiB).


M5. Host-Certificate Renewal Downgrade DoS and renew Validation Scope

Spec section: Host certificate renewal (lines 384–401).

Issue: 1. Certificate expiry-downgrade DoS: Within the 24-hour stolen-laptop window, an attacker holding an active day key can invoke the runner's host-cert renewal SSH command with a validly chained host certificate whose ValidBefore = now + 1s. Under line 390 ("checks the certificate chains to owner.pub and certifies its own key and name, saves it"), the runner would overwrite its 20–30 day host certificate with a 1-second certificate, forcing manual allmyram renew <runner> recovery across every runner after expiry. 2. allmyram renew <runner> check scope: Line 394 says renew trusts "the host key pinned in client.json at join (the certificate's key must match it) instead of the expired certificate". Relaxing everything except key matching discards defense-in-depth checks (CertType == HostCert, principal == runner name, valid dayCert signature under owner.pub, CriticalOptions empty). 3. Connect-path resilience: If proactive auto-renewal (<10 days left) fails during a normal connect() (e.g., day key just crossed expiry while client-cert.pub had seconds left, or transient runner write error), failing connect() would break runs while days of host-cert validity remain.

Recommendation: - On the runner's renewal handler, enforce all client-side host-cert checks plus require dayCert to be valid now and newCert.ValidBefore > currentCert.ValidBefore (monotonic expiry, except on root --join under a new owner.pub or new host key). - In allmyram renew <runner>, enforce all normal host-certificate checks (owner.pub chain, HostCert, runner principal, pinned host key, ValidAfter <= now, CriticalOptions empty) and relax only the ValidBefore / dayCert.ValidBefore + 30d expiry check. - Treat proactive (<10 day) renewal failure during normal connect() as a logged warning rather than aborting a healthy connection.


M6. Active-Connection Unpinning Race and macOS Sleep Clock Drift in sshsrv

Spec section: The day key (lines 225–232) and Removing and revoking (lines 412–414).

Issue: 1. Handshake-to-registration race: In sshsrv.ServeConn (internal/sshsrv/server.go:86), PublicKeyCallback checks client authorization inside ssh.NewServerConn before sc is returned to ServeConn. If a revoke (update-pins) arrives on another connection between PublicKeyCallback returning and ServeConn registering sc in its active-connections map, the sweep misses sc and the revoked key stays connected for up to 24 hours. 2. Monotonic timers pause during macOS sleep: On Darwin (affecting the plan-2 macOS runner), Go's time.After / time.NewTimer uses mach_absolute_time, which stops advancing while the Mac is asleep. Relying solely on time.After(time.Until(expiry)) to close expired connections can leave a connection open hours past wall-clock expiry after wake (or across NTP clock jumps on Linux).

Recommendation: - Register sc in ServeConn's active-connection set under the same mutex that updates PinnedSet, then immediately re-verify that the authenticated client key is still pinned and time.Now().Unix() < min(clientCert.ValidBefore, dayCert.ValidBefore); on failure or later revocation/expiry, cancel ServeConn's ctx (so child processes such as git-receive-pack are killed immediately) and close sc. - Check wall-clock time.Now().Unix() >= expiryUnix before accepting each new SSH channel (for nc := range chans) and on a periodic wall-clock ticker (e.g., every 30s) in addition to time.AfterFunc.


Low-Severity & Hardening Findings

L1. Runner Name Collisions / Silent Overwrites in client.json, Plus Missing client.json Lock

Spec section: Joining a runner steps 3–6 (lines 333, 352–361) and Removing and revoking (line 405).

Issue: - The runner sends its own name (defaulting to hostname -s, e.g., debian or macbook), and step 6 says a join "replaces whatever an earlier join wrote". Two machines sharing a generic hostname — or a leaked invite — can overwrite an existing runner's address and pinned host key in client.json if the approval prompt looks like a new join. - day-key and PinnedSet both specify lock files, whereas client.json mutations (invite approval, remove, future UI) have no lock-and-reread specified.

Recommendation: - Validate name against runnerNameRE on the laptop before prompting, prove possession of runnerHostPriv by signing the join transcript in step 3, and have the approval callback/CLI prominently distinguish adding a new runner from replacing an existing runner (host key / address changed). - Use advisory flock (LOCK_EX on persistent 0600 .lock files, never unlinked) for client.json updates just as for day-key and PinnedSet.


L2. --join <invite> Exposes the Bearer Invite in ps / /proc/<pid>/cmdline During Slow Install Steps

Spec section: Joining a runner step 2 (lines 328–332) and Left to the builder (line 488).

Issue: Passing --join <invite> on install.sh's command line exposes the single-use invite in /proc/<pid>/cmdline (ps aux) for the entire 30–90 seconds while install.sh runs apt-get, unpacks gVisor, and restarts containerd before allmyram join dials and consumes the invite. On any host with another local user/process, reading ps lets that process dial the invite first. Also, unlike other install.sh / macOS allmyram install flags, --join must never be persisted for reruns.

Recommendation: - Support reading the invite from stdin / prompt (--join -) or a 0600 file, pass the invite from install.sh to allmyram join over stdin (never a second ps-visible argv), and never persist --join in /etc/allmyram or ~/Library/Application Support/allmyram.


L3. Auto-Detecting --tailnet-peer from 100.64.0.0/10 Can Pick Non-Tailscale CGNAT Interfaces

Spec section: Joining a runner step 3 (lines 335–339).

Issue: 100.64.0.0/10 is RFC 6598 CGNAT, shared with cellular/ISP links, VM/container bridges, and other VPNs (and 100.100.100.100 is Tailscale's local service IP). Selecting an unreachable or non-tailnet 100.64.0.0/10 IP weakens the runner's egress self-check (internal/runner/runner.go:68: a down peer drops packets even when egress isolation is broken).

Recommendation: - Match Tailscale interfaces specifically (tailscale* on Linux, /32 utun* addresses in 100.64.0.0/10 excluding 100.100.100.100 on macOS, or tailscale ip -4 when available), refuse ambiguity when zero or multiple candidates exist unless --tailnet-peer is given explicitly, and print the selected tailnet-peer IP on allmyram invite.


L4. Apply 0700 Directory + 0600 File Checks Uniformly Across ~/.config/allmyram

Spec section: Constraints (lines 99–102).

Issue: Line 100 notes that the day-key loader checks both 0700 on its directory and 0600 on the key file, whereas internal/client/client.go:260 currently uses os.MkdirAll(..., 0o700) without rejecting a pre-existing 0755 directory when reading client.json, client, or tailcat.json.

Recommendation: - Apply the same 0700 directory + 0600 secret-file check across the entire ~/.config/allmyram directory at init and on load.