Egress
Per-workload FQDN network control — policies, presets, live grants, and the audit trail.
Network access is the platform's headline capability. A workload's L3 network is default-deny with exactly one route out: the platform's CONNECT proxy. Which hosts it may reach is a policy you set per job, per sandbox, per app — and can change on a running sandbox, or on an app by replacing its instances (see Apps).
NetworkPolicy has no concept of a domain name; this does.
The model
- L3 default-deny. No DNS, no CIDR rule to the internet, no UDP, no QUIC, no IPv6 allow. One additive rule: TCP to the proxy.
- The proxy resolves every name itself. The workload has no resolver that reaches the network, so DNS tunnelling isn't filtered — it's structurally impossible.
- The policy is control-plane state. The proxy is fed live from the api, so a change lands in milliseconds without restarting anything.
- Every decision is audited — allow and deny alike.
HTTP_PROXY is set in the workload for compliant clients, but it is not the boundary. A hostile workload that unsets it simply has no network. Clients that don't speak proxy protocols are caught anyway: the agent answers 127.0.0.1:53 for names the policy already allows and takes the connection through the same authorised path.
Modes
enum Mode {
MODE_NONE = 1, // literal isolation: no proxy route, DNS blackholed
MODE_ALLOWLIST = 2, // proxy; only hosts in `allow` (+ presets)
MODE_PERMISSIVE = 3, // proxy; any public host — still SSRF-guarded and audited
MODE_OPEN = 4, // no proxy: any public address, any port, direct
}MODE_NONE is the default for jobs and the usual steady state for sandboxes. MODE_PERMISSIVE is for install windows, and is best used as a short-lived grant rather than a resting state.
MODE_OPEN takes the proxy out of the path: the pod reaches any public address directly, on any port and protocol, and resolves names through public resolvers. Everything private stays unreachable — the cluster's node network, the pod and service networks (so two open pods cannot reach each other), CGNAT, link-local and cloud metadata, loopback and multicast. It is for workloads that cannot use a CONNECT proxy: containers started inside the workload, git over SSH, database clients. It needs a RUNC environment where the namespace permits runc, and it is chosen when the sandbox or job is created (runtime_egress / egress): it is a property of the pod, so it cannot be granted, and a sandbox created with it accepts no grants. Nothing is audited — the proxy never sees the traffic. Apps and warm pools do not support it yet.
Host rules
egress: {
mode: "allowlist",
presets: ["pypi"],
allow: [
"my-bucket.s3.example.com", // a bare string is the host, tunnelled on :443
{
host: "*.githubusercontent.com",
mode: "terminate",
pathPrefixes: ["/xeonr/"],
methods: ["GET"],
maxResponseBytes: 50_000_000,
},
],
}For the common shapes there are builders — egress.none(), egress.allowlist("registry.npmjs.org"), egress.presets("npm", "go-proxy"), egress.permissive(). An allow list or a preset without an explicit mode means allowlist, since that is the only mode in which either has any effect.
host_pattern is exact or leftmost-wildcard. ports defaults to [443].
ports is not limited to HTTP ports — a rule listing 22, 3306 or anything
else carries that protocol too, with no client configuration. See
Non-HTTP protocols.
Rule modes
| Mode | What the proxy does |
|---|---|
RULE_MODE_TUNNEL (default) | Plain CONNECT. Host and port only; contents opaque. Cheap, and safe with cert-pinning clients |
RULE_MODE_TERMINATE | Terminates TLS with a per-job ephemeral CA, enabling path_prefixes, methods, max_response_bytes and full-URL + response-hash audit |
RULE_MODE_TUNNEL_SNI_PINNED | Escape hatch for clients that reject any injected CA (some apt, go, Electron builds). SNI and host pinned; the audit event is flagged degraded |
Wildcards belong in TERMINATE. In tunnel mode the path is invisible, so a broad wildcard host (*.amazonaws.com, a CDN) is an exfiltration channel. Pin buckets and registries to exact hosts in tunnel mode; when a rule genuinely needs a wildcard, terminate it so the path is scoped and audited.
The MITM CA is generated per job, its private key exists only in the proxy's memory and is destroyed when the job ends, and the agent writes the public cert into the pod's trust stores at container start — never baked into an image. The proxy re-originates TLS upstream against the real root store, so termination inspects traffic without weakening upstream authenticity.
Enforcement per connection
- The
CONNECThost must match the allowlist, and the port must be one the matched rule grants. - If the stream is TLS, the ClientHello's SNI must equal the CONNECT host — this kills domain fronting. An absent, unparseable or encrypted (ECH) SNI fails closed. This applies on every port, not just
443, so a TLS frontend can't be fronted by requesting it on a different port. - A stream that is not TLS carries no ClientHello to check, and can't front with one. It is tunnelled if — and only if — the matched rule lists its port explicitly. A rule with no
portsnever qualifies, andPERMISSIVEdoesn't either. Port80additionally needsallow_plain_http. Such connections are audited asALLOWEDwith the degraded flag set, since their contents are opaque. - The proxy resolves the name itself and dials that exact IP, so there's no rebind window; RFC1918, link-local, IMDS (
169.254.169.254), loopback and ULA answers are rejected. CONNECTto an IP literal is refused. TCP only.- Plain HTTP is off unless the policy or the rule sets
allow_plain_http, and Host-header allowlisting then applies.
A protocol that begins in cleartext and upgrades in place (SMTP STARTTLS,
MySQL's TLS handshake) presents its ClientHello after the proxy has already
decided, so its SNI is never checked. Reaching a TLS frontend that way needs a
policy that already granted both the host and a non-TLS port on it; if that
matters for a given destination, scope the rule to 443 and let the check apply.
Non-HTTP protocols
Nothing needs configuring in the sandbox. The agent gives every allowed name its own loopback address and listens on each port the policy granted for it, so the destination is implied by the address a connection arrives on — which is what makes this work for protocols that name their host nowhere in the stream.
allow: [
{ hostPattern: "ssh.github.com", ports: [443] }, // git over SSH
{ hostPattern: "db.example.com", ports: [3306] }, // mysql
]ssh, mysql, psql and friends then work as-is — no ProxyCommand, no
HTTP_PROXY, no proxy-aware client:
git clone [email protected]:you/repo.git
mysql -h db.example.com -u app -pTwo caveats:
- Seed host keys yourself. SSH's first connection to an unknown host is an
interactive prompt, which fails a non-interactive
git clone. Put the host keys inknown_hostsin your image — for GitHub they're published athttps://api.github.com/metaunderssh_keys. Prefer that toStrictHostKeyChecking=accept-new: on a tunnel you don't control, the host key is the only thing authenticating the far end. - A port the policy withheld is refused locally, not tunnelled to a
403. That's deliberate — a connection refused on:22when the rule only granted:443is the clearer error — but it does mean the audit log has no event for the attempt.
Presets
Platform-maintained expansions, referenced by name. Their expansion is versioned into the policy hash, so a preset change can't silently alter an existing binding.
| Preset | Expands to |
|---|---|
npm | registry.npmjs.org |
pypi | pypi.org, files.pythonhosted.org |
go-proxy | proxy.golang.org, sum.golang.org |
apt-debian | deb.debian.org, security.debian.org |
apt-ubuntu | archive.ubuntu.com, security.ubuntu.com, ports.ubuntu.com |
github-release | github.com, objects.githubusercontent.com, *.githubusercontent.com |
crates | crates.io, static.crates.io, index.crates.io |
maven | repo.maven.apache.org, repo1.maven.org, *.gradle.org |
nuget | api.nuget.org, *.nuget.org |
rubygems | rubygems.org, index.rubygems.org |
deno | deno.land, jsr.io, *.jsr.io |
open-vsx | open-vsx.org |
gitlab-prod | git.prod.wtf |
Named policies
Reusable policies live in EgressPolicyService; jobs, sandboxes and apps reference them by id through EgressRef, or inline a policy directly.
import { EgressPolicy_Mode } from "@xeonr/containers/proto";
const { policy } = await cp.raw.egress.createEgressPolicy({
namespace: "my-app",
name: "s3-read",
policy: {
mode: EgressPolicy_Mode.ALLOWLIST,
allow: [{ hostPattern: "my-bucket.s3.example.com", ports: [443] }],
},
});
await cp.jobs.run({ /* … */, egress: policy.egressPolicyId });A policy edit (UpdateEgressPolicy) reaches Apps that reference the policy: their replicas roll onto the new rules. Sandboxes and jobs keep the rules resolved when they were created, across suspend and resume too; change a running sandbox's egress with a grant.
Managing named policies is a raw call, so the message is the protocol's own — @xeonr/containers/proto re-exports the generated types for exactly this. Referencing one afterwards is not: pass its id as egress anywhere a policy is accepted, since that field takes an id or an inline policy.
Grants
A grant is an additive layer over a sandbox's base policy: the egress in force is the base unioned with every active grant. This is the permissive→strict toggle applied live, which is exactly what an install step needs.
await using grant = await sandbox.grantEgress(egress.presets("pypi"), {
ttl: "5m", // omit for until-revoked
reason: "pip install -r requirements.txt",
});
await sandbox.shell("pip install -r requirements.txt");
// revoked here, on the way out of the scopeHeld in an await using, the window closes with the scope. Without it you are remembering a grant id, and the failure mode of forgetting is a sandbox that keeps reaching the internet long after the install that needed it finished. grant.revoke() is there for callers that cannot use the scope form.
reason lands in the audit log. Each call yields a separately revocable grant; RevokeEgress(sandbox_id, grant_id) removes exactly that layer and leaves the rest. Expiry is computed rather than reaped, so a stalled janitor can never hold a window open past its TTL, and a MODE_NONE grant can cut a running sandbox off without killing the pod.
Active grants are readable on GetSandbox as egress_grants, each with its mode, the hosts it opened, its reason and expiry.
If you're driving grants from an AI agent, note the shape this is designed for: grants are policy-shaped and audited, so a coaxed agent widens access to a named, logged set of hosts rather than to the internet.
Internal targets
The proxy rejects private addresses for everything — that's the SSRF guard. When a namespace genuinely needs to reach an in-cluster service, an admin registers the destination on the namespace:
await cp.raw.namespace.updateNamespace({
namespace: "my-app",
internalTargets: [{ host: "api.xeonr-upl-prod.svc.cluster.local", port: 8080 }],
});The split matters: a policy is namespace-authored, so if "this host is internal" were a policy property, any namespace could name any service in the cluster. Registration is admin-only; a policy must still name the host in its allowlist, but the permission comes from this list, and the two are joined when the control plane compiles the policy.
Traffic still goes through the proxy — same allowlist match, same SNI check, same audit. Only the RFC1918/ULA rejection is relaxed: loopback, link-local (IMDS), CGNAT and multicast stay denied for internal targets too.
Audit
Every decision is an event, queryable per job, per sandbox, or across a namespace.
const { events } = await cp.raw.egress.listEgressEvents({
namespace: "my-app",
principalId: jobId,
});
for await (const ev of cp.raw.egress.streamEgressEvents({ namespace: "my-app" })) {
console.log(ev.event.decision, ev.event.host, ev.event.detail);
}cp.raw is the generated client for every RPC the SDK does not model, and it throws the same error taxonomy as the rest of the surface.
| Decision | Meaning |
|---|---|
ALLOWED | Permitted and connected. The degraded flag is set when the contents are opaque — a TUNNEL_SNI_PINNED rule, or a non-TLS stream whose SNI there was none to check |
DENIED_POLICY | Host or port not in the effective policy |
DENIED_PRIVATE_IP | Resolved to a private/loopback/link-local address (SSRF guard) |
DENIED_IP_LITERAL | CONNECT to an IP address rather than a name |
DENIED_SNI_MISMATCH | A TLS ClientHello whose SNI didn't match the CONNECT host, or was absent/encrypted — or a non-TLS stream on a port the rule didn't grant explicitly (detail says which) |
UPSTREAM_UNREACHABLE | Policy allowed it, the network refused it — the destination was down, not blocked |
method, path and status are populated for TERMINATE rules. event_id is unique per decision, so a live stream and a history query merge exactly. detail carries the human-readable reason, which is usually what you want on a denial.
Debugging a blocked request
ListEgressEventsfor the job or sandbox. ADENIED_POLICYrow names the host that was refused — usually a CDN or a redirect target the allowlist missed.- No event at all? The traffic never reached the proxy. Check the policy isn't
MODE_NONE, and that the client isn't using UDP/QUIC (Go and curl HTTP/3 paths), which is never permitted. Connection refused on a non-HTTP port is the other common cause: the agent only listens on ports the matched rule granted, so add the port toportsrather than looking for a denial that was never recorded. UPSTREAM_UNREACHABLEmeans your policy is fine and the destination isn't answering.- TLS errors under a
TERMINATErule usually mean a cert-pinning client. Switch that rule toRULE_MODE_TUNNEL_SNI_PINNEDand accept host-only scoping. - A workload that hangs with no events is often one that overrode
HTTP_PROXYor a trust-store variable — which is why the API rejects those names.