| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
| |
The run script starts its VMs in Cloud Hypervisor, too, so it's
pkgs/run-rig, and run-rig (also its lock files), and the examples'
paths are /path/to/rigs.
|
| |
|
|
|
|
|
|
|
|
|
| |
A path rule was a plain string prefix of the request's path, so
https://api.github.com/search/issues, meant for that API endpoint (with
whatever query), also allowed /search/issuesomethingelse, and the only
way around it, /search/issues/, didn't allow the endpoint itself. Now a
rule's path allows itself and the paths below it, /search/issues/...,
but not /search/issuesx; one ending in "/" still allows whatever starts
with it. The query was never part of the match, and still isn't. The
requests' checks and POST /check share the code now.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
So a guest can know beforehand whether it gets somewhere, instead of
finding out by timeouts and retries, and can tell which rule it lacks.
nginx answers POST http://172.16.0.1/check (the guests' port 80 of
172.16.0.1 gets redirected to 172.16.0.1:checkPort, default 10080;
plain HTTP anywhere else stays refused): URIs one per line, at most 100,
and true or false for each, a line each, by the same rules as the
egress: whole domains and path rules for https://HOST[/PATH] (port 443
only), and for tcp:// and udp://HOST:PORT the list's rules, with names
as resolved for the guest's tap (its hosts file), but not to
denyDestinations or the host's own addresses on fcbr0, and not to tcp
port 443, which goes to the proxy. Read-only, about the asking guest's
own list only (by its address, as for its egress), and rate-limited.
In the guest, fc-egress check URI... asks that, over bash's /dev/tcp, as
the guest may have no HTTP client, and prints true or false and the
URI, a line each; exit status 0 if all are allowed, 1 if not, 2 on
errors.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
A VM got the first free tap of its user's, and a tap's address came from
its number, so a VM's address depended on what else ran, and on the
users before it, and a reverse proxy on the host could only guess it
(172.16.0.2, i.e. fctap0, for hermes).
Now addresses are the VMs': the host module takes vms, VM name -> user
and address (vms = { hermes = { user = "tv"; ip = "172.16.0.2"; }; }),
any number of them, and a VM takes any free tap of its user's, which
gets its address while it runs, so at most as many run at the same
time as the user has taps. Taps have addresses of their own, for
VMs without one: from 172.16.0.200 on, so they stand out (but for VMs'
there). The MAC address, which dnsmasq hands out every address by, is
06:00 and the address (06:00:ac:10:00:02 for 172.16.0.2), and with it
the IPv6 addresses; the run script takes the VM's from /etc/fc-vms, or
the tap's own from /etc/fc-taps. The VMs' addresses are also in
config.fc.vms.NAME (user, ip, ip6), for the host's configuration, e.g.
proxyPass = "http://${config.fc.vms.hermes.ip}:9120";
Which address a tap has is up to fcbr0-firewall, which now also runs
when a tap's VM's name (/run/fc-egress/TAP.name, which the run script
writes) changes: the VM's, if it's one of the tap's user's in vms and
on none of their other taps, too, else the tap's own. It puts it into
the tap's new nftables sets addr_TAP and addr6_TAP, in the bridge's
table, which lets the tap send from nothing else (instead of the static
set guests), and in the other, whose per-tap rules go by them (instead
of the tap's fixed addresses); and into /run/fcbr0-addr, ADDRESS: TAP
and TAP: ADDRESS, where egress.lua finds a guest's tap (as long as both
agree, and the address and the tap are the same user's), and the run
script waits for its address before starting the guest. fc-egress vms
shows the taps' addresses, too.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The guests get IPv6: fcbr0 has fdfc:fc::1/64 (module argument prefix6),
the host's dnsmasq sends router advertisements, and each guest takes the
address from its MAC (SLAAC with EUI-64; the guest's networkd is set up
for that, without privacy addresses), so the host knows each tap's
address, as with IPv4.
The rules take IPv6 addresses in brackets, tcp://[42::1]:22 or
udp://[42::/16]:5000-5100, and names now resolve to both families (and
get AAAA records for the guests). Forwarded connections get NATed to
the host's address, like IPv4. Like IPv4 everything else is refused:
the bridge only lets a tap send from its own addresses (or :: for
duplicate address detection), the host only answers neighbour and router
discovery, denyDestinations and the per-guest limits apply. HTTPS stays
IPv4, through the proxy: IPv6 port 443 is refused.
|
| |
|
|
|
|
|
|
|
|
|
|
| |
The output chain started with meta skuid != "fcbr0-egress" accept, but
meta skuid doesn't match packets without a user at all, like those the
kernel sends on its own, so they went on to nginx's restrictions. Most
are replies (ct established, accepted), but IPv6 neighbour and router
discovery (to ff02:: and fe80::) and IGMP (224.0.0.x) aren't, and got
rejected as denyDestinations: the host's own IPv6 stopped working.
Now only packets of the fcbr0-egress user jump to a chain with nginx's
restrictions; everything else passes.
|
| |
|
|
|
|
|
| |
So a log line's destination can be copied into fc-egress allow: HTTPS
connections now log https://SERVER, decrypted requests METHOD
https://HOST/URI, and fc-egress log adds tcp://DST:PORT (or udp://)
after the tap to the kernel's lines for other connections.
|
| |
|
|
|
|
|
|
|
|
| |
Like tcp:// and udp:// rules, HTTPS rules are now URIs:
https://DOMAIN (with subdomains, passed through) and
https://DOMAIN/PATH-PREFIX (decrypted to check the path), instead of
DOMAIN and DOMAIN/PATH-PREFIX. The old forms are refused by fc-egress
and ignored by egress.lua; to convert existing lists:
sed -i -E '/^[a-z]+:\/\//!s#^#https://#' /var/lib/fc-egress/*/*
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The guests' DNS resolves every name to the host, so ssh somename went
to the host, even with a rule for somename's address. Now the rules
can take names, tcp://NAME:PORT[-PORT]: the firewall update resolves
them on the host (IPv4) into the VM's set, and writes their addresses
to a hosts file per tap in /run/fcbr0-hosts, which the guests' dnsmasq
reads (--hostsdir; such entries win over address=/#/). A timer
resolves them again every 5 minutes.
dnsmasq can't tell guests apart, so every guest gets those addresses
for those names, but only VMs whose list has the rule can connect.
fcbr0-firewall now runs as a static user, fcbr0-firewall, which owns
/run/fcbr0-hosts, and may use IPv4 and IPv6 sockets, for resolving.
|
| |
|
|
|
|
| |
A named VM uses the list of the same name unless given another with
--egress; without a name, still the list default. A missing list means
no egress (with a warning), as before; there's no fallback to default.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
A VM can now have a name: run-firecracker-vm --name NAME. It's unique
among the user's running VMs (a lock in the user's runtime directory,
like the taps'), becomes the guest's host name (systemd.hostname= on the
kernel command line), and goes to /run/fc-egress/TAP.name while the VM
runs, for fc-egress. Names are letters, digits and -, and can't look
like a tap's.
fc-egress takes a running VM's name or tap where it takes a VM:
-v VM works on the list the VM uses, use VM LIST switches it to another
list, and vms shows tap, name and list. The logs keep saying taps
(fc-egress vms maps them).
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- denyDestinations (default: loopback, private, link-local, CGNAT,
multicast, ...): no user's rules can open those, neither tcp:// and
udp:// rules nor the proxy, whatever a name resolves to: nginx's own
outgoing connections may only go to port 443 outside them, and not to
the host. tcp:// rules no longer open anything on the host itself.
- fcbr0-firewall no longer runs as root, but with only CAP_NET_ADMIN,
doesn't follow symlinks, and gets started per user when that user's
rules change, so one user can't stop the others' updates. Rules files
are read up to 64k only, by egress.lua, too.
- Limits per guest (maxConnections open, maxNewConnections per second),
and per user in nginx, so one user can't starve the others.
- tcp:// and udp:// connections, and refused ones, get logged
(rate-limited) with the user; fc-egress log shows them.
- The run script keeps its lock files in a directory of the user's own,
not in /tmp, where others could take them first.
|
| |
|
|
|
|
|
|
|
|
|
| |
The host's NAT rules are for connections to the host, but they got
applied to the guests', too: e.g. a redirect of port 11423 to the host's
sshd turned a guest's allowed connection to some address's port 11423
into one to the host, which got rejected ("No route to host").
Our prerouting chain now runs before the host's, and gives everything
from fcbr0 a NAT that changes nothing. A connection only ever gets one
NAT, so the host's rules don't touch it any more.
|
| |
|
|
|
|
|
|
|
|
| |
Rules like tcp://192.0.2.7:22 or udp://192.0.2.0/24:5000-5100 in a user's
egress rules (managed with fc-egress as before) go into the nftables set
allow_USER, and connections from that user's guests that match get
forwarded (NATed to the host's address), or let in, if they're for one
of the host's addresses. fcbr0-firewall fills the sets whenever a
user's rules change, and after nftables reloads. Forwarding needs
net.ipv4.ip_forward, which networking.nat used to set.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
The host module takes users = { NAME = TAPS; ... } instead of a single
user: each user gets that many taps, and rules of their own, in
/var/lib/fc-egress/USER/allowed, managed with fc-egress as before.
The proxy tells whose a guest is by its address: each tap has a fixed
one, handed out by dnsmasq by MAC address (derived from the tap's number,
as the run script does), and the bridge drops anything a guest sends from
another address. The decrypting server gets a socket per user, as it
can't see the guest's address. The run script only takes the user's own
taps.
|
|
|
egress.lua goes along. The host now imports it as
(import .../modules/host { user = ...; }).
|