2 Commits

Author SHA256 Message Date
Alphaeus Mote f0268c899d feat(security): bound the unsealed-before-key-exchange window to the stream's age
The stream time a queued v1 message is judged by comes from the NATS server,
which is inside the threat model; once nothing from before the key exchange
can still be in the stream, unsealed messages are refused outright.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 18:13:41 -05:00
Alphaeus Mote 2df42b09ed feat(security): seal, sign and replay-protect every server/agent/browser message
Envelope v2 on top of TLS and NATS permissions: AES-256-GCM with a key per
message (HKDF-SHA256 over an ECDH P-256 secret, message id as salt, direction
as info), the header (kid, type, message id, issue/expiry, sender, subject) as
associated data, and an Ed25519 signature (server signing key / agent NKey)
over header, nonce and ciphertext. v1 is still parsed from unsealed agents.

- Keys: the server's signing + ECDH key set is a Data Protection-encrypted
  setting, current + previous (7 days), rotated from Settings > Message
  Security and announced to sealed agents signed with the old key. Agents keep
  an ECDH key with their credentials and pin the server's keys at enrollment,
  or for agents enrolled earlier at their first credential renewal (HTTPS,
  proof signed with the enrolled NKey covering the message key).
- Replay: issued/expiry on every message (live 2 min, queued commands 2 days,
  job states 7 days, 5 min skew, configurable both sides); seen ids persisted
  on the agent (job store), in the database for agent events, in a bounded
  window otherwise; queued messages remembered on ack.
- Remote View and file/log/registry transfers: per-stream AES-GCM frames with
  counter nonces; duplicates and reordering refused.
- Browser NATS traffic (events, job and shell output, keystrokes) sealed per
  session with a WebCrypto ECDH key.
- Rollout: Sealed chip on the device list and page, inventory reports it,
  Require Sealed Agents (off by default) refuses v1 and sends nothing to
  unsealed agents. Job messages must be signed by the device they name.
- Migrations MessageSecurity (Sqlite, Postgres, SqlServer); README Message
  security section.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 18:10:22 -05:00