aboutsummaryrefslogtreecommitdiffstats
path: root/modules/host/egress.lua
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-17 01:59:29 +0000
committertv <tv@krebsco.de>2026-11-17 01:59:29 +0000
commitb050c6af6aedbe78201addb4abe2636ab075d14e (patch)
treee46faa905fa85748892a5a70ba49678f5670b913 /modules/host/egress.lua
parent31611aa9bd7b39a4f700f1641bca2edb16619c64 (diff)
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.
Diffstat (limited to 'modules/host/egress.lua')
-rw-r--r--modules/host/egress.lua6
1 files changed, 4 insertions, 2 deletions
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