Skip to content

v7.4.0 — post-quantum hardening

Latest

Choose a tag to compare

@Jovancoding Jovancoding released this 05 Dec 22:31

Changed

  • Agent messages are encrypted by default (AgentChannel, SwarmTransportClient). seal() encrypts to the recipient (X25519 + ML-KEM-768, AES-256-GCM) unless the caller passes encrypt: false, and a recipient without a key-exchange key is refused instead of being sent plaintext. SwarmTransportClient with a channel encrypts unless encrypt: false. Received plaintext is still accepted, so 7.3 senders keep working during an upgrade, and is reported through the new onEvent callback; requireEncryption or ASI_STRICT_MODE=enforce refuses it (enforce also ignores encrypt: false). The message format is unchanged and 7.3 recipients open 7.4 messages.
  • Legacy Ed25519-only keys are warned about and audited, and refused under enforce. When NETWORK_AI_PQ_LEGACY=allow (or setPostQuantumPolicy) lets a legacy key through, the process emits one NAI_PQ_LEGACY warning and reports each use to ASI strict mode (would-deny in audit mode). ASI_STRICT_MODE=enforce refuses legacy keys whatever the setting, and legacyEd25519Allowed() returns false there.

Added

  • Forward secrecy for agent messages — AgentChannel.rotatePrekey() / currentPrekey() create short-lived key-exchange keys (default 1 h, prekeyTtlMs 5 min – 24 h) signed by the agent's own key and publish them to its directory; AgentDirectory.publishPrekey() verifies them against the agent's card, and lookup() returns the current prekey (kemKeyId). Senders encrypt to it, the prekey id is bound into the message key, and each prekey's secret is erased shortly after it expires (by an unref'd timer, so idle agents erase on time too; close() erases everything at shutdown), so stealing an agent's keys later does not decrypt recorded messages. Messages to the long-term card key (older senders) still open unless requireForwardSecrecy is set. SwarmTransport exchanges prekeys automatically: clients fetch the server's (nai.prekey) and send their own, servers return theirs when a caller is out of date, and a client whose server restarted drops the lost prekey and recovers on its next call (calls are never retried automatically).
  • EgressProxy({ requirePqTls: true }) — every upstream connection must negotiate hybrid post-quantum key exchange (TLS 1.3 + X25519MLKEM768); a classical-only upstream is refused (502, audited) rather than downgraded. The proxy refuses to start on a Node.js build without ML-KEM (OpenSSL 3.5+, e.g. Node 22.20+ / 24) or with an http:// route. pqTlsCa adds private CAs. Credential injection, scrubbing, spend limits, tripwires, redirects (not followed), timeouts, and the response size limit behave as before; gzip, deflate, and br responses are decoded before scrubbing. Without the option the proxy is unchanged.
  • AgentChannelEvent (plaintext-sent, plaintext-received, prekey-rotated), the forward-secrecy-required refusal code, the asi option on AgentChannel, and the crypto ASI event kind.

Upgrade notes

  • Code that read body.payload from sealed messages, or relied on plaintext by default, must pass encrypt: false. Cards issued without a key-exchange key (only possible from plain JavaScript) now make seal() throw; reissue them with generateAgentKeys() keys or send with encrypt: false.
  • Encrypted messages are about a third larger than plaintext (base64) plus about 1.5 KB of key-exchange data, so payloads near the 1 MiB maxMessageBytes default may need a higher limit.
  • Use one AgentChannel per agent identity when using prekeys: prekey secrets live only in that channel's memory and are not persisted, so after a restart an agent publishes a new prekey and messages sealed to the old one fail (decrypt-failed) and must be resent.

Full Changelog: v7.3.1...v7.4.0