Documentation
¶
Overview ¶
Package netguard defines the single network-egress policy for untrusted code running on a tau node: which destinations must be blocked so a tenant WASM function or a container the node did not author cannot reach node-local services or cloud infrastructure (loopback, private networks, and the link-local metadata endpoint), while still reaching the public internet.
The same policy feeds two enforcement layers so they can never drift:
- a net.Dialer control guard for the in-process WASM guest's HTTP client (pkg/vm-low-orbit/http) — portable Go, every OS;
- an nftables ruleset for restricted containers (pkg/containers firewall) — Linux only, built from DeniedPrefixes.
Index ¶
- func DeniedPrefixes() []*net.IPNet
- func DialControl(network, address string, _ syscall.RawConn) error
- func InstallBridgeFilter(bridge string) error
- func InstallCgroupFilter(cgroupID uint64, level uint32) error
- func IsDenied(ip net.IP) bool
- func RestrictedDialer(timeout time.Duration) *net.Dialer
- func Uninstall() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeniedPrefixes ¶
DeniedPrefixes returns a copy of the denied networks, for building the nftables sets in the container firewall. Callers split by address family via (*net.IPNet).IP.To4().
func DialControl ¶
DialControl is a net.Dialer.Control function that rejects a connection whose resolved address is denied. Control runs after DNS resolution, on the concrete address being dialled, so it defeats DNS-rebinding — the guard sees the real IP, not the hostname.
func InstallBridgeFilter ¶
InstallBridgeFilter programs the host firewall so containers attached to the named bridge cannot reach denied destinations. Every container on that bridge gets a veth into it, so one interface-scoped, static ruleset covers them all — install once per process. Idempotent (atomic table replace).
The caller passes the bridge of a network reserved for restricted containers, not the shared default one: the rule cannot tell containers apart, so anything else on that bridge is filtered too.
func InstallCgroupFilter ¶
InstallCgroupFilter programs a single, static output-hook rule dropping denied-destination packets from any socket whose cgroup v2 has, at ancestor level `level`, the cgroup identified by cgroupID. Used on the containerd backend, where containers share the host network namespace (no bridge to match on) but restricted ones all run under one parent cgroup: matching that parent with a single rule covers them all, nested cgroups included, without any per-container rule churn. Install once per process against the pre-created parent cgroup.
A wrong level or id installs cleanly but matches nothing — it fails *open* — so the match is exercised end to end by TestCgroupEgressDrop_Integration: a process in a cgroup below the matched parent must be refused a loopback destination and still reach a public one. Requires kernel >= 5.13 and CAP_NET_ADMIN; the level is counted from the cgroup root, so a parent at /sys/fs/cgroup/<ns>/restricted is level 2.
func IsDenied ¶
IsDenied reports whether untrusted code may not connect to ip. It fails closed: a nil or unparseable address is denied.
func RestrictedDialer ¶
RestrictedDialer returns a net.Dialer that enforces the egress policy and the given connect timeout. Use its DialContext for an untrusted http.Transport.
Types ¶
This section is empty.