Skip to content
pols.so docs
Esc
↑↓navigate↵open⌘Jpreview
On this page

Network egress

Choose what a sandbox may reach on the network, from the whole internet to an allowlist of addresses or nothing at all.

Every sandbox has an outbound network policy. You choose it when you create or fork the sandbox, and you can replace it later.

Mode The sandbox can reach
default the public internet
allowlist only the IPv4 and IPv6 prefixes and host names you list
none nothing
pols new --name web                                    # default: the public internet
pols new --name locked --egress allowlist --allow 203.0.113.10/32 --allow 2001:db8::/32
pols new --name pkgs --egress allowlist --allow github.com --allow '*.pypi.org'
pols new --name offline --egress none
pols fork web --name web-offline --egress none         # a fork may choose its own policy
pols egress web allowlist --allow api.anthropic.com    # replace the policy of an existing sandbox

A fork keeps its source’s policy unless you set one. Over the API, pass egress with mode and, for an allowlist, allow (up to 64 CIDR prefixes and host names) to POST /v1/sandboxes or .../fork, and to PATCH /v1/sandboxes/{sandbox} to replace it; over MCP, sandbox_egress replaces it.

How the modes behave

  • An allowlist entry is a CIDR prefix or a host name. Single addresses need /32 (IPv4) or /128 (IPv6). github.com matches that name only; *.pypi.org matches every name below pypi.org, but not pypi.org itself.
  • Host names need a sandbox on Cloud Hypervisor, which every new sandbox is unless it was placed in Incus; a sandbox on Incus refuses them with bad_request. pols answers the sandbox’s DNS queries: names no entry matches do not resolve, and the IPv4 addresses an allowed name resolves to become reachable, on every port, for at least five minutes after each lookup. Other names served from the same address, such as a CDN’s, are then reachable too, since pols does not look into TLS. Hard-coded addresses, other resolvers and DNS over HTTPS open nothing, and IPv6 stays blocked.
  • A sandbox in none, or with an allowlist of prefixes only, has no DNS resolver. For DNS with such an allowlist, allow a public resolver’s address and configure the sandbox to use it, for example in /etc/systemd/resolved.conf.
  • A policy applies to new connections. A changed policy applies at once to a running sandbox or one in standby, and stays for later starts; connections already open may continue. A sandbox that booted without a resolver (in none, or with an allowlist of prefixes only) gets one at its next start, so host names you add while it runs resolve after it is next started.
  • A policy cannot change while the sandbox is being created, stopped, resumed, deleted or resized (conflict), and keys limited to some sandboxes cannot change it. A sandbox on Incus cannot switch between default and the other two modes.

Pick the mode with the sandbox’s purpose in mind: none suits running untrusted code on data you copied in, allowlist suits a sandbox that should talk to one API or one database.

Blocked in every mode

Some destinations are blocked whatever the policy says, and an allowlist entry that overlaps the built-in ranges is refused:

  • other sandboxes, including your own;
  • the sandbox host and the pols infrastructure, including ssh.pols.so and *.on.pols.so, so published ports and published sites cannot be used from inside a sandbox. The pols API at api.pols.so is the exception: in default mode, and in allowlist mode when the allowlist includes its address, a sandbox reaches it on port 443 like any outside client, with an API key;
  • private (RFC 1918), CGNAT and link-local addresses on the network, including the cloud metadata address 169.254.169.254, and IPv6 unique-local and link-local addresses;
  • multicast and broadcast;
  • outgoing SMTP on TCP port 25. To send email from a sandbox, use your mail provider’s submission port or HTTP API.

Incoming traffic

Nothing on the internet can open a connection to a sandbox directly. The only ways in are the ones pols provides, and they work in every egress mode: published ports and SSH through the edge, and the desktop, commands, file transfers and computer use through the control plane.