Skip to main content
By default a sandbox has no outbound network access. Attach a network policy when the workload must reach something outside the box — a public API, a package registry, or an internal system such as a database or private HTTP service.
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 0 for any port
  • Protocoltcp, udp, or any

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 no deny_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).
Attaching a looser policy never weakens a stricter one — detach the stricter policy to open more egress. Attach when creating a sandbox with 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:
In the Python SDK, create(..., rules=[...]) creates the policy and adds rules in one call. If a rule fails, the policy is rolled back so you never keep a half-configured policy. For databases and other non-HTTP services, allow the exact port — do not rely on port 443 alone.

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 under client.network_policies (maps to /v1/network-policies).

Best practices

  1. Stay fail-closed by default — only attach a network policy when outbound is required; prefer allowlist over allow_all.
  2. List every needed destination — public APIs and internal hosts (DB, private API) must each have a rule under allowlist mode.
  3. Keep rules narrow — hostname + exact port beats “any port”; avoid wide CIDRs unless necessary.
  4. Combine with secrets — inject credentials via Identity providers, and only allow the destinations those credentials should talk to.
  5. Detach when unused — remove network policies from idle runtimes; delete unused policies.
Network policies reduce blast radius; they do not stop malicious code from using destinations you intentionally allow. Pair them with least-privilege secrets and human review for high-risk actions.

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