sshd: removing a key closes its connections #256

closed cmc opened this on 2026-09-28 02:36 UTC · keys priority security

Discussion

cmc 2026-09-28 02:36 UTC

A removed SSH key keeps working on connections that were already open.

Authentication caches the key ID and scope in the connection's permissions. runExec (internal/sshd/sshd.go:299) reloads the user per exec but never the key; TouchSSHKey's result is ignored. With the CLI's ControlMaster, a connection carrying many sessions is the normal case, so a compromised key stays usable after keys remove for as long as its holder keeps the connection open.

Decision: revocation is immediate.

  • Revalidate key existence, owner and current scope before every exec and every git transport session.
  • sshd tracks open connections per key. keys remove, repo deploy-key remove and account disable close every connection on the affected keys, cancelling running commands, pushes included. An interrupted receive-pack updates no refs.
  • An e2e test: open a multiplexed connection, remove the key, confirm the next exec is refused and a long-running command is cut off.

referenced in commit 7a6343d02d by cmc: wiki: architecture and security pages

2026-09-28 04:30 UTC

referenced in commit 4e0958a163 by cmc: plans: open issues from the architecture and UX reviews

2026-09-28 05:43 UTC

closed by cmc in commit 4bbf4f8114: wiki: revocation closes open connections

2026-09-28 21:48 UTC

referenced in commit 2b840816c9 by cmc: e2e: removing a key cuts its multiplexed connection and a push in flight

2026-09-28 21:48 UTC

referenced in commit c0969481b0 by cmc: sshd: re-read the key per exec; revocation cuts its connections

2026-09-28 21:48 UTC

referenced in commit bf64c30c08 by cmc: gitutil: Transport takes a cancel channel and kills its process group

2026-09-28 21:48 UTC

referenced in commit 9f77ab1b00 by cmc: store: announce key revocations; LiveSSHKeys

2026-09-28 21:48 UTC

referenced in commit 0d343c917d by cmc: sshd: the disable test waits for the connection's account to be recorded

2026-09-28 22:41 UTC