Hi all,
I run untrusted, short-lived workloads on Machines inside an app with its own private network. The goal is that nothing a workload sends leaves the Machine. Two questions:
- Network policy scope. As far as I can tell from the docs, an egress rule names only TCP or UDP and a port. Is there a supported way to restrict ICMP/ICMPv6 egress, or lookups through the internal resolver (fdaa::3), for one app or one private network? Failing that, can a policy admit no egress at all, rather than “allow one unusable tuple”? I already contain this inside the guest; I’m asking about a host-level floor underneath it.
- Verification traffic. To prove the in-guest containment works, I periodically send a small, bounded number of safe control packets from the Machine’s root namespace: a few dozen TCP SYNs and ICMPv6 echoes, to a single host I own, plus a handful of ordinary DNS lookups. Nothing goes anywhere else and nothing touches Fly’s systems. Is that acceptable, or is there a way you’d prefer this be done?
A pointer to docs is welcome too. Thanks!
Hi… It might be worth expanding on this point, since this is a very non-obvious limitation of the network policies.
(I would like to see more lockdown-ability in network policies, as well.)
Sure. As I understand the semantics, a policy only restricts egress once it contains at least one egress rule. An empty egress list doesn’t mean “deny all”, it means “no restriction”. So the closest thing to deny-all I found is a single rule for a destination nothing can connect to: TCP, port 0 (that’s the tuple I refer to). In practice that blocks ordinary connections, but it’s a workaround rather than a stated guarantee.
It also can’t help with the other half of my question. Rules name only TCP or UDP and a port, so ICMP and lookups through the internal resolver are outside what a policy can express at all.
What I’m hoping for is an explicit “deny all egress” option, ideally one that also covers ICMP and the resolver for apps that don’t need them. If anyone from Fly can confirm the intended semantics, or say whether that’s on the roadmap, that would settle it.
Hi,
For deny-all egress, once a policy has at least one egress rule, the default for egress becomes deny-all (Network Policies: https://fly.io/docs/machines/guides-examples/network-policies/#how-it-works). A single rule like TCP port 0 is a legitimate way to switch that default on, as you observed/found, everything not explicitly allowed is dropped. With no egress rules at all, egress isn’t restricted.
Rules can only name TCP or UDP and a port, and policies apply to Machines within an app; they can’t be scoped to a private network. Two kinds of traffic are allowed by the host before network policies are evaluated, so a policy can’t restrict them: ICMPv6, including echo requests to external IPv6 addresses, and DNS (port 53) and other platform services at fdaa::3. ICMPv4 is covered by the policy’s default deny.
Your verification traffic is OK and it won’t cause any issues. A few dozen SYNs and echoes to a host you own, plus a handful of DNS lookups, is fine (basically the same as regular outbound traffic). As per above, when you test against a deny-all policy, the ICMPv6 echoes and the fdaa::3 lookups will succeed, so keep that in mind.
We don’t have anything in the roadmap regarding network policies for machines, but I hope this covers your use case!