Manage policies on the Network Policies page in the platform (sidebar), or via
client.network_policies / /v1/network-policies. This is separate from Identity → Providers (secrets).Default egress posture
Every new runtime is fail-closed:
You do not start from “open internet.” You open only what the job needs.
The built-in system default is hidden from the Network Policies list and from
list_for_runtime (use include_system=True to see it). It cannot be detached or deleted. Once you attach any network policy of your own, those policies define egress; the system default is only the fallback when nothing else is attached.
DNS needed to resolve hostnames still works under restrictive modes. Private / link-local / cloud metadata ranges stay blocked unless you explicitly allowlist that destination — including under allow_all.
When outbound access is needed
Keep the default deny posture if the sandbox only runs local code, files, and shell. Attach a policy when the sandbox must call:
List every destination the workload needs. An allowlist that includes only
api.openai.com will block your internal DB — and an allowlist that includes only the DB will block the LLM API. To reach a private database or internal API under allowlist, add an explicit rule for that host (and port).
Why attach a network policy?
Pair policies with Identity Providers so credentials are injected only for destinations you also allow.
Enforced with eBPF
Network policies are enforced with eBPF in the Linux kernel — production-grade, battle-tested datapath enforcement used widely across cloud-native platforms. That gives you:
You define what a sandbox may reach; eBPF enforces it on every outbound attempt.
Egress modes
Every policy has an egress mode. Destination rules (host / IP / CIDR + port + protocol) apply to allowlist and denylist.
Prefer
allowlist for production agents. Use allow_all only when you truly need broad egress. Use denylist when most of the internet is fine but a few hosts must stay blocked.
Rule shape
- Destination — hostname, IP, or CIDR
- Port — specific port, or
0for any port - Protocol —
tcp,udp, orany
Multiple policies
You can attach more than one network policy to a runtime. When that happens, the most restrictive mode wins:
Examples:
- Any attached
deny_all→ no outbound access. - Any
allowlist(and nodeny_all) → default deny; destinations from attached allowlists are allowed. If a denylist is also attached, overlapping destinations stay denied. - Only
denylist→ outbound allowed except denied destinations. - Only
allow_all→ broad outbound access (sensitive private/metadata ranges still blocked unless explicitly allowed).
network_policy_ids=[...], or later with attach(...). Rule changes and attach/detach apply to running sandboxes without recreate.
Create a network policy with rules
Use an allowlist when the sandbox must reach both a public API and an internal system:Attach when creating a sandbox
Attach to a running sandbox
List, get, and update a network policy
Manage network policy rules
Detach and delete a network policy
SDK reference
All network policy operations live underclient.network_policies (maps to /v1/network-policies).
Best practices
- Stay fail-closed by default — only attach a network policy when outbound is required; prefer
allowlistoverallow_all. - List every needed destination — public APIs and internal hosts (DB, private API) must each have a rule under allowlist mode.
- Keep rules narrow — hostname + exact port beats “any port”; avoid wide CIDRs unless necessary.
- Combine with secrets — inject credentials via Identity providers, and only allow the destinations those credentials should talk to.
- Detach when unused — remove network policies from idle runtimes; delete unused policies.
Next
Web Services
Expose HTTP apps inside the runtime over HTTPS
Identity Providers
Inject credentials as environment variables
Create Runtime
Attach policies at sandbox create