Skip to content

Ports and the port guard

Host services take fixed ports. Every per-agent port is derived from that agent's uid, is loopback-only, and is enforced by nftables rather than by convention.

Host port map

Host ports are not uniformly loopback — most of them bind every interface, so firewall them at the host or network edge.

port service binds
80, 443 Caddy, in front of the login proxy all interfaces
3978 teams gateway all interfaces
8731 cockpit HTTP, served by agentctl-webview-gateway.service 127.0.0.1 only, always
8732 slack gateway all interfaces
8734 auth broker all interfaces
8735 web-view gateway dial-in listener all interfaces
8736 web-view login proxy all interfaces — it is the entry point a browser has to reach
8737 local PII filter 127.0.0.1 only; there is no setting that widens it

8733 is reserved and unused.

Per-agent bands

Every band is loopback-only and sits at base + uid − 1000, so an agent's ports are a pure function of its uid and never move as other agents come and go.

band use
9222+ Chrome CDP
18730+ channel WS (telegram transport, or a cross-host connector's local WS)
22730+ KasmVNC (private display)
28730+ web-view WS

Every band sits below the ephemeral range (32768+), so the kernel can never hand one out first. The matching X display number is :100 + uid − 1000, clear of the shared :99 and of :0–:10.

The bands are enforced

Every agentctl apply renders /etc/agentctl/nftables/agent-ports.nft from the same band table the CLI uses, and reloads it with nft -f unconditionally. That installs table inet agentctl on the output hook, dropping any packet to a guarded port whose originating meta skuid does not own it. agentctl-portguard.service (WantedBy=sysinit.target) loads it at boot, before anything binds.

rule detail
kasm band (22730+) cross-uid allowance: uid 0, for agentctl-webview-gateway.service
web-view WS band (28730+) cross-uid allowance: uid 0, for agentd fetching a workspace upload's bytes with ws write --pull
9222+, 18730+ owner-only, root included
a missing /usr/sbin/nft fails the apply with exit 1; nftables is a hard package dependency
scope the guard governs locally originated traffic: traffic leaving on lo is accepted first
apply --dry-run returns before the host-wide tail, so it never renders agent-ports.nft
apply <agent> the host-wide tail needs the full agent set, so a single-agent apply also renders and reloads nothing
rollback systemctl disable --now agentctl-portguard.service, then leave it disabled

To parse-check the ruleset by hand, nft -c -f /etc/agentctl/nftables/agent-ports.nft. The file exists only after the host's first apply.

To reach another agent's port by hand, use sudo -u <agent> curl …: setuid happens before the socket is created, so the socket carries the agent's uid and matches the accept rule. A plain root curl is dropped on every band except kasm and web-view WS.

The rollback's ExecStop deletes only table inet agentctl, never Azure's ip security or Docker's ip nat / ip filter. Leave the unit disabled afterwards, because the next apply re-asserts the guard.