From d6c5c010f3764e2a7bc7c6b654ef7986d704199b Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 17 Nov 2026 02:28:41 +0000 Subject: per-VM egress whitelists Whitelists are now named, any number per user, in /var/lib/fc-egress/USER/LIST, and each VM uses one of them: run-firecracker-vm --egress LIST (default: default). The run script writes the list's name to /run/fc-egress/TAP when it takes the tap, and empties it when the VM exits; a list that doesn't exist allows nothing. A user's VMs can only use that user's lists. So the unit of policy is the tap (i.e. the running VM) rather than the user: nftables sets allow_TAP, nginx decrypt sockets decrypt-TAP.sock, egress_taps.lua maps guest addresses to tap and user. fcbr0-firewall updates a tap when its file in /run/fc-egress changes, and all of a user's taps when anything in the user's directory does. nginx's connection limit stays per user. fc-egress takes -l LIST (default: default), and has new commands lists and vms (running VMs' taps and their lists). Log lines now say user, tap and (nginx's) list: "ALLOW|DENY USER TAP LIST ...", kernel: "fc-egress ALLOW|DENY USER TAP". The old rules file, /var/lib/fc-egress/USER/allowed, is now just a list named "allowed"; rename it to "default" to keep using it. --- README.md | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index a03cb12..497c07c 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ Optional arguments: - `proxyPort` (default 10443): where the proxy listens; the guests' port 443 gets redirected there. -- `denyDestinations`: addresses no user's rules can open, neither for +- `denyDestinations`: addresses no whitelist can open, neither for tcp:// and udp:// rules nor through the proxy, whatever a name resolves to. Default: loopback, private, link-local, CGNAT, multicast and the like (IPv4 and IPv6). The host's own addresses are always out of reach @@ -84,9 +84,10 @@ nix-build pkgs/run-firecracker-vm \ ## Egress The guests resolve every name to the host, and all their HTTPS goes to -the proxy, which decides by the server name and the rules of the guest's -user, in `/var/lib/fc-egress/USER/allowed`. Each user manages their own -with `fc-egress`: +the proxy, which decides by the server name and the VM's whitelist. +Each user has any number of named whitelists, in +`/var/lib/fc-egress/USER/LIST`, and manages them with `fc-egress` +(`-l LIST`; without it, the list `default`): ```sh fc-egress list @@ -95,10 +96,22 @@ fc-egress allow github.com/NixOS/ # only paths starting with /NixOS/ fc-egress allow tcp://192.0.2.7:22 # plain TCP to that address and port fc-egress allow udp://192.0.2.0/24:5000-5100 fc-egress deny github.com/NixOS/ +fc-egress -l work allow example.com # the list "work" +fc-egress lists fc-egress log -f ``` -Changes apply to the next connection. Whole domains get passed through +Each VM uses one list, `default` unless given another: + +```sh +./result/bin/run-firecracker-vm --egress work +``` + +A list that doesn't exist allows nothing. `fc-egress vms` shows the +running VMs' taps (as in the log) and their lists. Which list a running +VM uses is in `/run/fc-egress/TAP`; to switch, write another name there +(`echo default > /run/fc-egress/fctap3`). Changes to lists and switches +apply to the next connection. Whole domains get passed through encrypted. Domains with path rules get decrypted to check each request, with certificates from a CA the host creates on first start (`/var/lib/fcbr0-egress/ca.pem`). The guest trusts that CA if it exists -- cgit v1.3.1