Skip to navigation

Network rules

The network object on a sandbox create controls outbound traffic: what code inside the sandbox can reach. It has four modes.

ModeSendOutbound traffic
OpennothingEverything is allowed. This is the default.
Blocked"block_all": trueNothing is allowed.
Domain allowlist"allow_domains": [...]Only the listed host names.
CIDR allowlist"allow_cidrs": [...]Only the listed address ranges.

Next step: pick a mode and add it to your create request. You can replace the rules later with one call: see Change the rules on a running sandbox.

The rules cover outbound traffic only. Your exec and file calls go through the provider’s own channel and work in every mode.

How we checked each mode

Every result on this page comes from the same script, run inside a python:3.12-slim sandbox on each provider. It tries four addresses:

import urllib.error
import urllib.request
for url in ["https://pypi.org/simple/", "https://example.com/", "https://1.1.1.1/", "https://8.8.8.8/"]:
try:
status = urllib.request.urlopen(url, timeout=5).status
except urllib.error.HTTPError as err:
status = err.code
except Exception as err:
print(url, "blocked:", type(err).__name__)
continue
print(url, "reachable:", status)

With no network field, on both providers:

https://pypi.org/simple/ reachable: 200
https://example.com/ reachable: 200
https://1.1.1.1/ reachable: 403
https://8.8.8.8/ reachable: 200

Block everything

curl -sS -X POST "$MEADOW_BASE_URL/v1/sandboxes?wait=true" \
-H "Authorization: Bearer $MEADOW_API_KEY" \
-H "Content-Type: application/json" \
-d '{"image": "python:3.12-slim", "timeout_seconds": 300, "network": {"block_all": true}}'
https://pypi.org/simple/ blocked: URLError
https://example.com/ blocked: URLError
https://1.1.1.1/ blocked: URLError
https://8.8.8.8/ blocked: URLError

The image is pulled before the rule applies, so any registry image still works. Installing packages inside the sandbox does not. Build what you need into an image first.

Allow some domains

curl -sS -X POST "$MEADOW_BASE_URL/v1/sandboxes?wait=true" \
-H "Authorization: Bearer $MEADOW_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"image": "python:3.12-slim",
"timeout_seconds": 300,
"network": {"allow_domains": ["pypi.org", "*.pythonhosted.org"]}
}'
https://pypi.org/simple/ reachable: 200
https://example.com/ blocked: URLError
https://1.1.1.1/ blocked: URLError
https://8.8.8.8/ blocked: URLError

An entry is a host name, optionally with one leading *. label, such as *.pythonhosted.org. A plain name does not cover its subdomains. With the allowlist above, https://test.pypi.org/simple/ was blocked on both providers, and it answered 200 from a sandbox with no rules. List each name you need, or use the *. form.

The allowlist above is enough for pip: pip install six==1.16.0 worked on both providers.

What an allowed name opens

Meadow sends each entry to the provider as you wrote it, and the provider applies it. Two things follow.

A wildcard also covers the bare name. With "allow_domains": ["*.iana.org"], https://www.iana.org/, https://data.iana.org/ and https://iana.org/ all answered on both providers. Both providers document this. If the bare name must stay blocked, a wildcard cannot do that on either provider.

The ports differ by provider. We ran one script in a python:3.12-slim sandbox made with each provider’s own SDK, with www.iana.org and github.com on the list:

Connection to an allowed nameDaytonaModal
TLS on port 443 (https://www.iana.org/)200200
Plain HTTP on port 80 (http://www.iana.org/)200Refused
SSH on port 22 (github.com)The server’s banner came backRefused
TLS on port 443 to an allowed host’s address, naming a host off the listClosed during the handshakeReset

On Modal a host name opens TLS on port 443 and nothing else. An https:// URL that redirects to http:// fails there: https://www.iana.org/domains/example does this, and urllib reports Network is unreachable. On Daytona the same URL works. The result was the same for rules given at create and rules set by a change. Other ports were not checked on Daytona. Modal’s documentation states the rule: its domain allowlist allows TLS traffic on port 443 only. We found no setting for ports in either provider’s API, so Meadow cannot make the two match.

If you need another port on Modal, add the host’s address range to allow_cidrs next to the name. With "allow_domains": ["www.iana.org"] and both of its addresses as /32 entries in allow_cidrs, http://www.iana.org/ answered 200 on Modal. A range opens every port and every host on those addresses. On a shared CDN that is more than the one name, and the addresses can change. Daytona cannot combine the two lists, so such a request is served by Modal.

These results are from 2026-11-27, with no Meadow in the path.

What a blocked call looks like differs. Daytona sets the HTTPS_PROXY and HTTP_PROXY variables in the sandbox and filters there, so a client that uses them fails with Tunnel connection failed: 403 Forbidden, and a client that ignores them fails at the name lookup with Name or service not known. Both are blocked.

An allow_domains entry that is not a host name returns 400: a URL, a port, a path, an IP address, or a wildcard in another position.

{
"error": {
"code": "parameter_invalid",
"message": "network.allow_domains entries must be host names such as api.example.com or *.example.com; use allow_cidrs for ip addresses",
"param": "network.allow_domains",
"type": "invalid_request"
},
"request_id": "req_00007d1b"
}

Seen on the hosted beta on 2026-11-28.

Allow some address ranges

curl -sS -X POST "$MEADOW_BASE_URL/v1/sandboxes?wait=true" \
-H "Authorization: Bearer $MEADOW_API_KEY" \
-H "Content-Type: application/json" \
-d '{"image": "python:3.12-slim", "timeout_seconds": 300, "network": {"allow_cidrs": ["1.1.1.1/32"]}}'
https://pypi.org/simple/ blocked: URLError
https://example.com/ blocked: URLError
https://1.1.1.1/ reachable: 403
https://8.8.8.8/ blocked: URLError

Each entry is a CIDR range. A bare address such as 1.1.1.1 returns 400 with network.allow_cidrs entries must be valid cidr ranges. Write 1.1.1.1/32.

The host names in our check sit outside the allowed range and were blocked. Name lookups differ by provider in this mode: on Daytona a lookup of example.com failed, and on Modal it returned an address that the sandbox then could not connect to. Use addresses in your code, or use a domain allowlist.

What we tried beyond HTTPS

The checks above use HTTPS. We also ran a short Python script as nobody in a python:3.12-slim sandbox on each provider and mode. It opened plain TCP connections to 1.1.1.1 on ports 443, 80, and 53 and to a public SSH server on port 22, sent a DNS query to 1.1.1.1 over UDP, and looked up example.com. With no rules, every one of these worked on both providers.

ModeDaytonaModal
block_allPort 22 timed out. Ports 443 and 80 accepted the connection and returned no data. A DNS query to 1.1.1.1 got an answer that said the name does not exist. The lookup of example.com failed.Every connection failed at once. The lookup failed.
allow_domainsThe same as block_all for hosts off the list.Port 443 connected and was reset. Ports 80, 53, and 22 were rejected. The UDP query timed out. The lookup of example.com returned an address.
allow_cidrsEvery connection was rejected. The UDP query timed out. The lookup failed.Every connection was rejected. The UDP query timed out. The lookup of example.com returned an address.

What this means:

  • Apart from the DNS answers below, no data came back from a blocked host in any mode on either provider.
  • A completed TCP connection does not prove a host is reachable. On Daytona a filter accepts connections on ports 443 and 80 and then closes them.
  • On Daytona, DNS queries are answered by a resolver even under block_all. On Modal, a name lookup works under both allowlists. A lookup that leaves the sandbox can carry a few bytes out in the name itself. We did not test whether these resolvers pass lookups for names you did not allow to the internet. If that matters to you, use block_all on Modal, where the lookup failed.
  • These results come from a few connections on one day. Nobody has run a security test of the rules, and the provider applies them.

Change the rules on a running sandbox

PATCH /v1/sandboxes/{sandbox_id} replaces the rules of a running sandbox. Use it to give setup the hosts it needs, then narrow the rules before untrusted code runs.

curl -sS -X PATCH "$MEADOW_BASE_URL/v1/sandboxes/$SANDBOX_ID" \
-H "Authorization: Bearer $MEADOW_API_KEY" \
-H "Content-Type: application/json" \
-d '{"network": {"block_all": false, "allow_domains": ["api.example.com"], "allow_cidrs": []}}'

The response is 200 with the sandbox, and its network field holds the new rules:

{"allow_cidrs": [], "allow_domains": ["api.example.com"], "block_all": false}

On Daytona the rules were in force when the call returned, in every change we ran. On Modal a change that removed access was in force when the call returned in every run. A newly allowed address range on Modal was open at once in two runs and still blocked right after the call in three: in one of those it was open 15 seconds later, and in the other two we did not check again. Check from inside the sandbox before you rely on a new allowance.

What to know:

  • The whole rule set is replaced. A field you leave out is reset, so send every rule you want to keep. {"network": {}} opens the network.
  • {"network": {"block_all": true}} blocks everything.
  • Sending the same rules again is safe.
  • The sandbox must be running. Otherwise the call returns 409.
  • Connections that are already open may be cut when the new rules no longer allow them.
  • On Daytona a change to the allow list also stalled open keep-alive connections to hosts that stayed allowed (seen on the hosted beta on 2026-11-24). A new connection worked. Reconnect after a change.
  • A rule set the provider cannot apply returns 400 and changes nothing. The message names the cause, for example modal can change network rules only on a sandbox created with allow_domains or allow_cidrs; this one was created with an open network.
  • Change one sandbox’s rules one call after another. Two calls at the same moment both return 200 and the last to finish wins.

The providers differ:

DaytonaModal
A sandbox created with an open networkCan be changed.Returns 400 for every change.
A sandbox created with block_allCan be changed.Returns 400 for every change.
A sandbox created with an allow listCan be changed.Can be changed, with the next two rows.
Using allow_domains in a changeWorks.Only when the sandbox was created with allow_domains.
Using allow_cidrs in a changeWorks.Only when the sandbox was created with allow_cidrs.
Opening the network in a changeWorks.Only when the sandbox was created with both lists.
block_all in a changeWorks.Works. Name lookups may still answer.

On Modal, decide at create which kind of rule you will need later. A sandbox that starts on host names can move to other host names or to block_all. To be able to open the network later, create the sandbox with at least one host name and one address range.

On Daytona, the provider’s documentation says only organisations on its tier 3 or tier 4 can change rules on a running sandbox. We have not seen what a lower tier returns.

A change returns 502 with error.code sandbox_unreachable and Retry-After when the provider answers “not found” for a sandbox it still reports as running. The rules were not changed, so send the change again. This is on the hosted beta since 2026-11-27, and we have not seen it on a live sandbox.

Every row above was run on the hosted beta on 2026-11-24, with the check script from the top of this page run inside the sandbox after each change. The Daytona organisation we used could change rules.

Provider differences

The check script at the top of this page gave the same results on Daytona and Modal in all four modes. The providers differ in which ports an allowed name opens (see What an allowed name opens) and in what you can combine.

DaytonaModal
A name in allow_domainsOpens ports 80, 443 and 22. Other ports not checked.Opens TLS on port 443 only.
*.example.com in allow_domainsAlso allows example.com.Also allows example.com.
allow_domains with allow_cidrsNot supported. Daytona is skipped.Supported
More than 10 allow_cidrs entries, more than 100 allow_domains entries, or an IPv6 rangeNot supported. Daytona is skipped.Supported
block_all with portsThe port URL works.Not possible. Modal is skipped at create.
block_all with sshSSH works.Not possible. Modal is skipped at create.
An allowlist with ports or sshBoth work.Both work.

block_all cannot be combined with either allowlist on any provider. That returns 400 with network.block_all cannot be combined with allow_domains or allow_cidrs.

A request with both allowlists is served by Modal when your route allows it, and the skipped Daytona attempt is recorded:

{
"status": "running",
"provider": "modal",
"attempts": [
{"detail": "daytona cannot combine allow_domains and allow_cidrs", "outcome": "unsupported", "provider": "daytona"},
{"duration_ms": 320, "outcome": "served", "provider": "modal"}
]
}

On Modal, a sandbox with block_all cannot be reached from outside at all. A create with block_all and ports or ssh: true skips Modal, and the attempt says why:

{"detail": "modal blocks inbound connections too when network.block_all is set, so ports and ssh cannot be reached; use allow_domains or allow_cidrs, or daytona", "outcome": "unsupported", "provider": "modal"}

When your route allows Daytona, the sandbox is created there. When it does not, the sandbox is failed. Both outcomes were seen on the hosted beta.

If you need inbound access and tight outbound rules on Modal, use an allowlist. With "allow_domains": ["pypi.org"] both the port URL and SSH worked.

On Modal, SSH with any rule that blocks the package mirror needs openssh-server in the image already. See Files, ports, and SSH.

Give a sandbox access to Meadow

To let code in a sandbox call Meadow, create a narrow key and pass it in env. With a domain allowlist, add the host of your MEADOW_BASE_URL to allow_domains. Meadow does not add it for you.

This script mints a key that can make five calls to one model for one hour, creates a sandbox that can reach only Meadow, and runs a model call from inside it as a non-root user. MEADOW_API_KEY is a key with the admin and sandboxes scopes, and PROJECT_ID is its project.

import os
from datetime import datetime, timedelta, timezone
from urllib.parse import urlparse
import requests
BASE = os.environ["MEADOW_BASE_URL"]
HEADERS = {"Authorization": f"Bearer {os.environ['MEADOW_API_KEY']}"} # admin and sandboxes scopes
PROJECT_ID = os.environ["PROJECT_ID"]
INSIDE = '''
import json, os, urllib.request
request = urllib.request.Request(
os.environ["MEADOW_BASE_URL"] + "/v1/chat/completions",
data=json.dumps({
"model": "gemini-3.1-flash-lite-preview",
"messages": [{"role": "user", "content": "Say hello in five words."}],
"max_tokens": 32,
}).encode(),
headers={"Authorization": "Bearer " + os.environ["MEADOW_API_KEY"], "Content-Type": "application/json"},
)
with urllib.request.urlopen(request, timeout=30) as reply:
print("model call:", reply.status, reply.headers["x-meadow-provider"], json.load(reply)["choices"][0]["message"]["content"])
try:
urllib.request.urlopen("https://example.com/", timeout=5)
print("other host: reachable")
except Exception as err:
print("other host: blocked,", type(err).__name__)
'''
expires = (datetime.now(timezone.utc) + timedelta(hours=1)).strftime("%Y-%m-%dT%H:%M:%SZ")
minted = requests.post(f"{BASE}/v1/keys", headers=HEADERS, timeout=30, json={
"project_id": PROJECT_ID,
"name": "in-sandbox",
"scopes": ["models"],
"allowed_models": ["gemini-3.1-flash-lite-preview"],
"max_requests": 5,
"max_tokens": 2000,
"expires_at": expires,
})
minted.raise_for_status()
narrow = minted.json()
created = requests.post(f"{BASE}/v1/sandboxes", headers=HEADERS, params={"wait": "true"}, timeout=330, json={
"image": "python:3.12-slim",
"timeout_seconds": 300,
"env": {"MEADOW_BASE_URL": BASE, "MEADOW_API_KEY": narrow["secret"]},
"network": {"allow_domains": [urlparse(BASE).hostname]},
})
created.raise_for_status()
sandbox = created.json()
try:
print("sandbox", sandbox["status"], "on", sandbox["provider"])
result = requests.post(f"{BASE}/v1/sandboxes/{sandbox['id']}/exec", headers=HEADERS, timeout=90, json={
"command": ["python", "-c", INSIDE],
"cwd": "/tmp",
"user": "nobody",
})
result.raise_for_status()
print(result.json()["stdout"], end="")
print(result.json()["stderr"], end="")
finally:
requests.delete(f"{BASE}/v1/sandboxes/{sandbox['id']}", headers=HEADERS, timeout=60)
requests.delete(f"{BASE}/v1/keys/{narrow['id']}", headers=HEADERS, timeout=30)
sandbox running on daytona
model call: 200 google Hello, it is nice meeting.
other host: blocked, URLError

With "provider": {"only": ["modal"]} added to the create, the same script printed the same three lines with modal.

The key in env is readable by every process in the sandbox. Give it only the models scope, allowed_models, limits, and a short expires_at, and revoke it when the sandbox is gone. Run a coding agent in a sandbox builds on this flow.

More in Known limits.

API reference

Operations on this page: createSandbox, updateSandbox.