feat(lan): mTLS LAN control-plane listener, read-only (VA-8) #136
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/VA-8-lan-listener"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
The agent advertised itself over mDNS (
mdns.rs) but never accepted inbound LAN requests (DEFAULT_PORTwas a placeholder with no socket). This adds the matching listener so a peer agent on the same subnet can connect and run a restricted, read-only set of inventory actions.Trust model: mTLS via the shared agent CA
The listener is a TLS server presenting the agent's enrolled leaf and requiring a client cert, verified against the agent CA the server issues to all its agents. Only a peer holding a valid server-issued agent cert can connect - no separate pairing secret.
Important prerequisite: the agent CA is not shipped by the base enrollment flow (the agent stores only its own leaf + the web-serving root that verifies the server's TLS cert; the agent CA is a separate hierarchy). It is provisioned separately by VS-92 (filed) and stored under the new
AGENT_CA_KEY. Until it is present the listener stays disabled (fail-closed):spawnreturnsNonerather than accepting unauthenticated peers. VA-8 is linked depends-on VS-92.Capability gate (default-deny)
An authenticated peer is confined to a read-only inventory allowlist:
ping,sysinfo,osinfo,cpuinfo,disks_list,processlist,networkinterfaces,listen_ports,agent_stats,time_status,coreinfo. Everything else - mutating (exec,runcommands,host_power, ...), session-opening (terminal_*, tunnels,kvm_*), filesystem (file_*,getdir,log_tail), and network-probing (tcp_probe,dns_lookup) - is refused with an error frame and never executed. The per-peer dispatch context carries no stores and no update/uninstall apply, so a mistakenly-allowed action still cannot persist or tear down the agent.Plumbing
lanmodule: capability gate, peer client-cert verifier builder,ServerConfigbuilder, and a TCP+TLS+WS accept loop bound to the mDNS-advertised port.identity::server_cert_resolverpresents the enrolled leaf server-side (mirrors the existing client resolver).AGENT_CA_KEYstore key.agent_ca_pemfield on the VA-130agentconfigframe, persisted toAGENT_CA_KEY, so the server (VS-92) can push the agent CA to already-enrolled agents on reconnect without re-enrollment.mainalongside the mDNS responder; torn down on shutdown.Testing
Unit tests cover the security-critical logic:
401 lib tests pass; clippy
--deny warningsand fmt clean; full workspace builds.The live two-agent mTLS round-trip (acceptance criteria: two agents discover + handshake, read-only round-trip, gate blocks mutating) can only be exercised once VS-92 provisions the agent CA to agents. This PR is the agent side; it is safe to merge now because it is fail-closed until that material exists.
Part of VA-8 (agent side). Depends on VS-92.