diff --git a/docs/4-implementation/networking/network.md b/docs/4-implementation/networking/network.md index 8b9632a3d..2fab0bc59 100644 --- a/docs/4-implementation/networking/network.md +++ b/docs/4-implementation/networking/network.md @@ -11,9 +11,10 @@ Agent containers always run in a private netns. ## Network map -One picture of the whole hive — two planes: **infra -containers share the host netns** and bind host ports directly; -**compute containers (agents + CI) each get a private netns** behind +One picture of the whole hive — two planes: **the few infra +containers that bind host ports (the secret store and the queue) share the +host netns**; **every other container (agents, CI, and the service +containers such as the forge and matrix) gets a private netns** behind the bridge. The unix-socket control plane rides the VFS, and none of that touches it. diff --git a/docs/4-implementation/scheduler/ci.md b/docs/4-implementation/scheduler/ci.md index 3deaca45b..170ec69a8 100644 --- a/docs/4-implementation/scheduler/ci.md +++ b/docs/4-implementation/scheduler/ci.md @@ -76,7 +76,7 @@ needs `deploy.forgejo.enable` or a hive on its host. ## Container design -- **Private netns, bridge-attached**: the container runs in its own network namespace (`privateNetwork = true`, `hostBridge`), takes its address from the gateway's DHCP, and resolves through the gateway's dnsmasq on the bridge IP. It can't reach host-loopback services — the core dashboard at `127.0.0.1:7000` and the raw forge port are unreachable from CI. +- **Private netns, bridge-attached**: the container runs in its own network namespace (`privateNetwork = true`, `hostBridge`), takes its address from the gateway's DHCP, and resolves through the gateway's dnsmasq on the bridge IP. It can't reach host-loopback services — the core dashboard at `127.0.0.1:7000` is unreachable from CI, and the forge answers only by name through the gateway. - **Non-ephemeral**: runner credentials (`.runner`) persist across restarts, written to the container's state dir on registration and reused after. - **Sandbox fallback**: nspawn containers can't create user-namespaces, so nix's sandboxing would always fail. Module sets `nix.settings.sandbox-fallback = true` in the container — nix builds run unsandboxed (safe because the container is already isolated). See `docs/5-project/process/gotchas.md`. - **Credential isolation**: no forge admin credential enters the container. swarm-controller holds the forge admin token; the runner holds only the registration token and its own `.runner`, and the host unit that fetches the token holds a store identity that reads that one path. Only `swarm-ci-runner-register.service` loads the registration token; the daemon unit and the jobs it runs have it neither in their environment nor among their credentials. @@ -206,7 +206,7 @@ nspawn containers can't create user-namespaces, so the module sets `nix.settings A malicious `default.nix` or build script in a PR can therefore: -- **Make arbitrary network requests** to any address reachable from the container. The container runs in its own netns behind the hive bridge, so it reaches the forge by name at `https://` (no admin credentials) and **can't** reach host-loopback services: the unauthenticated core dashboard at `127.0.0.1:7000` and the raw forge port are off-limits (a firewall rule drops bridge→127.0.0.0/8 traffic). +- **Make arbitrary network requests** to any address reachable from the container. The container runs in its own netns behind the hive bridge, so it reaches the forge by name at `https://` (no admin credentials) and **can't** reach host-loopback services: the unauthenticated core dashboard at `127.0.0.1:7000` is off-limits (a firewall rule drops bridge→127.0.0.0/8 traffic), and the forge has no port to reach at all: it answers only by name through the gateway. - **Write to the container filesystem**, including corrupting the runner's state dir or `.runner` credentials. No forge admin token enters the container: swarm-controller holds it and publishes only the registration token, which only `swarm-ci-runner-register.service` loads, so a job step can't read it. A build process can still reach the forge over the network, and it runs as the runner's own user, so it can read `.runner` and act as this runner; it can't issue admin API calls.