Sandboxes
Outbound network
Deny, allowlist or open, with allow and block rules by domain, IP address or CIDR range. How a sandbox's internet access is set, changed and enforced.
Each sandbox has an egress mode:
| Mode | The sandbox can reach |
|---|---|
deny | Nothing on the internet. The default. |
allowlist | Only what allow lists. |
open | Any public address. Needs the Team plan. |
Private networks, the host and other sandboxes are blocked in every mode.
{ "egress": { "mode": "allowlist", "allow": ["pypi.org", "files.pythonhosted.org", "*.githubusercontent.com"] } }*.example.commatches every subdomain ofexample.com, notexample.comitself. List both if you need both.- If you send
allowlistwith noallow, your organization's default list is used. New organizations start withpypi.org,files.pythonhosted.organdregistry.npmjs.org. Change defaults under Policy in the dashboard.
Allow and block rules
allow and deny each take up to 200 rules. A rule is a domain, an IP address or a CIDR range, with an optional port:
| Rule | Means |
|---|---|
pypi.org | That domain |
*.github.com | Any name under github.com |
203.0.113.7 | One address |
198.51.100.0/24 | A range |
[2001:db8::/32] | An IPv6 range (brackets let you add a port) |
db.example.com:5432 | One port |
203.0.113.0/24:8000-8100 | A port range |
example.com:* | Every port |
- An allow rule with no port means ports 80 and 443. A block rule with no port means every port.
- Blocked always wins over allowed.
denyworks inallowlistandopenmode. For example, open internet except a few domains and ranges:
{ "egress": { "mode": "open", "deny": ["*.tracker.example", "198.51.100.0/24"] } }- Private ranges can't be allowed. A rule that isn't valid is refused with a message saying why, so nothing is dropped silently.
Change rules while a sandbox runs
PUT /sandboxes/{id}/egress with any of mode, allow and deny (fields you leave out stay as they are). New connections follow the new rules at once. A paused sandbox wakes first. You can do the same on the sandbox's page in the dashboard.
{ "mode": "allowlist", "allow": ["pypi.org", "203.0.113.0/24"], "deny": ["203.0.113.66"] }A sandbox can't be switched wider than the maxMode it started with. By default that is what its first rules needed, so a deny sandbox stays closed. To keep the option of opening it later, start it with egress.maxMode:
{ "egress": { "mode": "deny", "maxMode": "open" } }Allowing a port other than 80 or 443 needs maxMode: "open". Asking for more than maxMode allows answers 409 egress_too_wide.
Every change is written to the audit log as sandbox.egress, with the rules before and after.
How it's enforced
The rules are enforced inside the VM, by a firewall and a proxy that the sandbox's own code can't change. Commands don't run as root, and changing rules needs your API key, which a sandbox never holds.
- Domains are checked by a proxy inside the VM (the HTTPS
CONNECThost, or the HTTPHostheader). HTTP clients use it on their own (HTTP_PROXYandHTTPS_PROXYare set). Tools that ignore proxy settings don't leak; their connections fail. - Addresses and ranges are also written into the firewall, so any program can reach an allowed address directly, and nothing can reach a blocked one. For a database or another non-HTTP service, allow its address or range.
- A domain that resolves to an address in a blocked range is blocked too.
- In
openmode, blocking a domain sends web traffic (ports 80 and 443) through the proxy so it can be checked. To block a domain on other ports, block its address or range. - UDP other than DNS is blocked.
Blocked attempts are written to the audit log, with the domain or address.
Data sent out
Outbound data is counted per sandbox. The first 5 GB a month are free, then $0.05 per GB.