Seatbelt: accept loopback-only `egress.allow` port rules (alongside `runtimeConfig.networkProxy`)
Description of the new feature / enhancement
Problem
On macOS, a Seatbelt-contained process can reach host loopback in only two ways:
ingress.hostLoopback: "allow", which opens every port:(allow network-outbound (remote ip "localhost:*"));- the loopback
runtimeConfig.networkProxy, which only proxy-aware HTTP clients can use.
There's nothing in between. For coding-agent sandboxes this forces a bad choice. Test suites need to reach one or two local services, for example a Postgres container on localhost:5432, a build daemon or a test server. But the same loopback also carries Node inspector (9229) and Chrome remote debugging (9222) ports, kubectl port-forwards and other projects' databases, and reaching some of these is a sandbox escape in itself.
Downstream, this is what's behind github/copilot-cli#5105. There, Gradle and Kotlin daemons and Rails against a local Docker database fail with EPERM, even with allowLocalNetwork: true. Copilot's runtime maps that setting to ingress.default: allow with hostLoopback: deny, so a sandboxed process can't even connect to a listener it started itself.
What Seatbelt can already do
The backend docs list "Reach a loopback address / port ✅ Kernel-enforced, port-scoped". The backend already emits a single-port rule for the proxy:
(allow network-outbound (remote ip "localhost:<proxy port>"))
The same rule for caller-listed ports would give port-scoped host loopback. Today, however:
egress.allowis rejected on Seatbelt whenever it's non-empty ("no CIDR/port/protocol primitive exists");- the 1.0.0 policy spec requires
egress.allowandegress.denyto be empty wheneverruntimeConfig.networkProxyis set, and Copilot always sets a proxy.
Proposed technical implementation details
Proposal
- Seatbelt: accept
egress.allowrules whosetoconsists only of loopback CIDRs (127.0.0.0/8or127.0.0.1/32, and::1/128), with explicit TCPports. Each port becomes(allow network-outbound (remote ip "localhost:<port>")). Keep rejecting any otherto, and any rule without ports. - Spec: allow loopback-only
egress.allowrules alongsideruntimeConfig.networkProxy. They don't weaken the proxy's destination filtering, which is about non-local traffic. - Port ranges (
endPort): SBPL has no range syntax. Either expand ranges up to a small cap or reject them on Seatbelt.
Example:
"network": {
"egress": {
"default": "deny",
"allow": [{ "to": [{ "cidr": "127.0.0.1/32" }, { "cidr": "::1/128" }],
"ports": [{ "protocol": "tcp", "port": 5432 }] }]
},
"ingress": { "default": "deny", "hostLoopback": "deny" },
"runtimeConfig": { "networkProxy": "http://127.0.0.1:<port>" }
}
Caveats worth documenting
- As the Seatbelt doc already notes,
localhostin SBPL means every address bound to this host, LAN IPs included. A port rule therefore also allows that port on the host's LAN addresses. In practice that's still far narrower thanlocalhost:*. - This covers outbound only. It doesn't solve "connect to a listener this sandbox started on an ephemeral port", which needs
ingress.default: allowplus knowing the port ahead of time. Ideas for that would be welcome, but port-scoped host loopback alone would unblock the common "tests need the local database" case.
Once this is in mxc, Copilot's runtime would need to expose it, for example as port-level allowedHosts entries or a localPorts setting. I'll link this issue from copilot-cli#5105.
Hi Reuben, thanks for the feature request. Will definitely take a look at this.