From b050c6af6aedbe78201addb4abe2636ab075d14e Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 17 Nov 2026 01:59:29 +0000 Subject: host: harden against users turning on the host or each other - 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. --- modules/host/egress.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'modules/host/egress.lua') diff --git a/modules/host/egress.lua b/modules/host/egress.lua index 6875608..6c507a1 100644 --- a/modules/host/egress.lua +++ b/modules/host/egress.lua @@ -31,7 +31,10 @@ local function rules(user) if not f then return domains, paths end - for line in f:lines() do + -- Only the first 64k, so a huge file can't slow down everyone's egress. + local text = f:read(65536) or "" + f:close() + for line in text:gmatch("[^\n]+") do local domain, path = line:match("^%s*([^/%s]+)(/?%S*)%s*$") if valid_name(domain) then if path == "" then @@ -42,7 +45,6 @@ local function rules(user) end end end - f:close() return domains, paths end -- cgit v1.3.1