Skip to content

Decision: should code in a sandbox session be able to reach the spawner, the backend and other sessions on the Docker sandbox network? #4870

Open

Description

@yannickmonney

Summary

On a Docker deployment, a program running in any sandbox session can open network connections to the spawner, to backend-api and to the runtime port of other sessions, including sessions of other organizations. Every API tried refused an unauthenticated request with 401 (only the spawner's /health answers without credentials), so no credential or data was reachable in what was tested. What is open is network reachability: the spawner's request signature and each runtime's token are the only barriers. The spawner mounts the host's Docker socket, which the repository's own comments call "effectively root on the host", with the signature and a loopback-only port meant to keep "unauthenticated callers off the socket". Kubernetes restricts session reachability with a NetworkPolicy; Docker does not.

This issue collects the evidence and the options so the team can decide whether the Docker posture should change. It proposes no fix.

Why now

Since v0.5.87 (#4817) an organization member's chat can start code in a default-profile ("light") sandbox, on by default (Chat tools › Code), and a document the model reads can steer it into doing so. Standard-agent task runs on the shared engine (#4844) run code there too. The reachability below is identical for all three session profiles; it is a property of the network, not of the light sandbox. What grew is the set of people, and of prompts and documents, that can lead to code running on it.

The admin docs now say what a light sandbox can reach (docs/*/platform/admin/sandboxes.md, added in #4849); before that they said only that it is isolated.

What the repository says today

  • Every session container (default, agent-light, agent) joins the --internal bridge tale-sandbox-net together with the spawner (sandbox), the egress proxy, the LLM gateway and backend-api, which is dual-homed ("the in-sandbox connectors bridge reaches this api directly over the sandbox network (VK-authed)", compose.yml:496-500; also :785-793, :909-911, :994-996; the network is created --internal by the CLI, compose.yml:1093-1102).
  • Public traffic leaves through the egress proxy, whose IP-layer firewall refuses private and metadata addresses (services/sandbox-egress/entrypoint.sh:16). Private ranges are deliberately left out of the transparent redirect (_DIRECT_CIDRS, services/sandbox-runtime/entrypoint.sh:453), and NO_PROXY names backend-api, backend-relay and sandbox-llm-gateway (services/sandbox/src/session/docker-session-args.ts:499-507: sessions reach the gateway and the backend "directly on the internal bridge — not through tinyproxy"). Agent sessions use the gateway for model calls and the backend for the connector bridge (/api/connectors/*) and tool dispatch (/api/tools/*).
  • The spawner's stated security model (services/sandbox/Dockerfile:7-12, compose.yml:818-822): "/var/run/docker.sock is bind-mounted in. Anyone with write access to the socket is effectively root on the host … The HMAC on every API call + the loopback-only host port (127.0.0.1:8003) keep unauthenticated callers off the socket." The loopback-only port mapping does not apply to a container on the sandbox network, which reaches the spawner's container port directly.
  • Spawner requests are signed with a timestamp and a nonce (services/sandbox/src/auth.ts). Each session's runtime checks a token derived from the spawner's secret and the session id (deriveRunnerdToken, docker-session-backend.ts:180).
  • Kubernetes: the NetworkPolicy limits session Pods to the egress proxy, the LLM gateway Service (:8080) and DNS, and allows ingress to the runtime port from the spawner only (services/sandbox/docs/sessions.md:1010-1015). Not run on a cluster for this issue.
  • SANDBOX_EGRESS_ALLOWLIST limits public hosts only; it does not touch the bridge.

What was observed

A local rig laid out like compose.yml: spawner, egress proxy and a relay standing in for backend-api on one --internal network, released 0.5.86 images. A Python program run through the spawner's exec route in session A (organization X), once per profile. Session B belongs to a different organization.

Target, from a program in session A Result
egress proxy :3128 TCP connect succeeds (the designed path)
spawner :8003 TCP connect succeeds. GET /health answers 200 without credentials: status, Docker server version, workspace and Docker-data disk state, runtime image state and last error. GET /v1/sessions unsigned: 401
backend relay :3175 (stands in for backend-api) TCP connect succeeds. POST /api/tools/execute without a token: 401
session B's runtime port :8200 TCP connect succeeds. GET /health without a token: 401
169.254.169.254:80 no answer within 3 s. The rig has no metadata service, so this shows the bridge does not route it, not that a rule fired
a public IP, TCP :443 connect succeeds (transparent redirect through the egress proxy)
a private or metadata address through HTTP_PROXY 500 "Unable to connect": the egress firewall refuses it

The results are the same for default (uid 65534), agent-light and agent (uid 10001). Nothing in the program's environment is a credential. The only names matching KEY, TOKEN or SECRET are GPG_KEY (a 40-hex fingerprint, as the official Python images set it) and CLAUDE_CODE_MAX_OUTPUT_TOKENS (a number).

Not examined: a real Compose deployment (hostnames such as sandbox and backend-api resolve there; the rig used addresses), the LLM gateway and its authentication (the rig has none), Kubernetes, the Docker-in-Docker variant of the agent profile, and anything behind the authentication of the services reached.

What is at stake, and what is not

  • Nothing reached accepted an unauthenticated request. No credential was readable from the program.
  • What remains is reachable surface: the spawner's request parsing and signature check, the backend's sandbox-facing routes (/api/tools, /api/connectors, /api/sandbox-blob), each session's runtime, and the unauthenticated /health answer.
  • Isolation between sessions, including those of different organizations, rests on each runtime's token alone; the network does not separate them.
  • A flaw in how any of those services handles an unauthenticated or malformed request would become reachable from code a member's prompt, or an injected document, can run. For the spawner that flaw would sit in front of the Docker socket.
  • Kubernetes deployments are stricter than Docker deployments for the same product feature.

Constraints any change has to respect

  • The runtime daemon runs as the same user as the program. On a default session tini (root) runs setpriv --reuid 65534 … node runnerd.mjs, and the program is uid 65534 too (observed in /proc). A rule keyed on the user cannot tell "the daemon may reach backend-api" from "the program may not".
  • Input files for run_code reach the sandbox by URL, fetched by that daemon from backend-api (SANDBOX_HTTP_API_BASE_URL, default http://backend-api:3005; stageUrlForBlobRef in backend/core/node_only/sandbox/helpers/stage_url.ts: "the sandbox net has no route to the bucket"). Closing the path to backend-api needs another way for those bytes to arrive. The daemon also takes small inline payloads (up to 1 MiB); run_code itself has no inline path for input files.
  • The entrypoint already installs the egress redirect as root before it drops privileges (entrypoint.sh, setup_session_transparent_egress, then setpriv), so per-profile network rules have a place to live.
  • The spawner and the runtime image are versioned and rolled separately, so a change to how staged files travel has to work with an older runtime during an upgrade.

Options (not exhaustive, no preference stated)

  1. Keep the posture. Document it precisely (done in fix(platform): harden chat tools and light sandboxes after review #4849) and rely on service authentication.
  2. A per-profile network policy installed by the session entrypoint: for the default profile allow loopback, DNS, the egress proxy and, while staging needs it, backend-api, and refuse the rest of the bridge.
  3. Change how staged files reach the runtime (the spawner or the platform pushes the bytes in instead of the runtime pulling from backend-api), then withhold backend-api from the default profile.
  4. Separate networks per profile or per session, so sessions cannot see each other or the spawner; the spawner and the backend reach a session through its runtime port only. This touches the Compose generator and ensureSandboxNetwork.
  5. Reduce what the reachable services say or accept, for example /health detail only for authenticated or loopback callers. A complement to the options above, not a substitute.

Questions

  • Is direct reachability of the spawner, the backend and other sessions from session code acceptable on Docker while Kubernetes denies it?
  • Should the answer differ per profile? default runs untrusted chat code and page rendering; agent sessions run an authenticated agent that legitimately uses the gateway and the connector bridge.
  • Is this to be handled as a hardening issue here, or through the private advisory process in SECURITY.md? The facts are already public (the docs page above and fix(platform): harden chat tools and light sandboxes after review #4849).

Reproduce

From a program in a sandbox session. The addresses are those of the sandbox network (docker network inspect tale-sandbox-net lists them); the snippet only connects and sends unauthenticated requests.

import socket, urllib.request, urllib.error

def tcp(host, port):
    try:
        socket.create_connection((host, port), timeout=3).close()
        return 'connect'
    except Exception as error:
        return type(error).__name__

def http(url, method='GET'):
    opener = urllib.request.build_opener(urllib.request.ProxyHandler({}))  # ignore HTTP_PROXY
    request = urllib.request.Request(url, method=method, data=b'{}' if method == 'POST' else None)
    try:
        return opener.open(request, timeout=4).status
    except urllib.error.HTTPError as error:
        return error.code
    except Exception as error:
        return type(error).__name__

SPAWNER, BACKEND, OTHER_SESSION = '<spawner ip>', '<backend-api ip>', '<other session ip>'
print('spawner', tcp(SPAWNER, 8003), http(f'http://{SPAWNER}:8003/health'), http(f'http://{SPAWNER}:8003/v1/sessions'))
print('backend', tcp(BACKEND, 3005), http(f'http://{BACKEND}:3005/api/tools/execute', 'POST'))
print('other session', tcp(OTHER_SESSION, 8200), http(f'http://{OTHER_SESSION}:8200/health'))

Expected on the rig: connect 200 401, connect 401, connect 401.

Related

#4871 (the disk side of the same sandbox exposure), #4849 (the review that found this, and the docs that state it), #4726 and #3977 (other ways a busy or hostile session affects the control plane).

Observed at main a83e645e27.

Activity

  1. added
    priority: medium
    needs discussion
    on Oct 12, 2026
  2. yannickmonney commented on Nov 14, 2026

    @yannickmonney
    ContributorAuthor

    Decision

    Direct reachability is not acceptable. Docker, Kubernetes and Incus get one reachability contract, based on the Incus ACL:

    • A session may connect only to: the egress proxy (tcp 3128, DNS 53), the LLM gateway (tcp 8080, agent and agent-light only), backend-api on tcp 3005, its own loopback, and the infrastructure the spawner hands it (its inner Docker bridge, its organization's buildkitd network and registry mirror, and on Incus the node's registry caches).
    • A session accepts connections only from the spawner, on tcp 8200.
    • No session may connect to the spawner.

    On Docker:

    • The network tale-sandbox-net gets a fixed subnet with a separate session range, and the services get static addresses that the spawner passes to each session.
    • The spawner (Docker backend only) refuses new inbound connections on its sandbox-net interface and fails closed if it cannot install the rule. The backend reaches it through a name that exists only on the internal network.
    • The runtime entrypoint commits an outbound allowlist by destination, covering IPv4 and IPv6, and an inbound fence against other sessions, as root before it drops privileges. The session does not boot without them. The same image runs on every backend, so this is tested on all three.
    • The spawner's unsigned /health returns only its status.

    Kubernetes is brought to the same contract: narrowed egress, and a real ingress policy for :8200 from the spawner only.

    Answers

    • Acceptable on Docker? No, not for the spawner or for other sessions. backend-api stays reachable on :3005 and relies on its own authentication.
    • Different per profile? Only the gateway (closed to default) and the Docker-in-session extras (inner bridge, buildkit network).
    • Advisory or hardening? A hardening issue in the open. Anything that does accept an unauthenticated request goes through SECURITY.md.

    Rationale

    The spawner fronts the Docker socket, so a flaw in it means root on the host, and organizations should not be separated by a token alone. Fences at the receiving end hold even against a session that is root in its own network namespace. The allowlist names what sessions legitimately reach on private addresses, so the build cache, Docker-in-session and the registry caches keep working. Static service addresses keep it valid across backend redeploys. Staging is unchanged, so spawner and runtime versions can still roll separately.

    Implementation units (all on main)

    1. fix(sandbox): unsigned /health answers status only (S)
    2. fix(sandbox): Docker-backend spawner refuses inbound connections on sandbox-net; SANDBOX_URL uses an internal-only name (M)
    3. feat(cli): fixed subnet, session range and static service addresses for tale-sandbox-net (L)
    4. feat(sandbox-runtime): outbound allowlist and session ingress fence, per profile, fails closed, tested on all backends (L, after 3)
    5. fix(sandbox): Kubernetes egress and ingress policies match the contract; fix the docs (M)
    6. docs(sandbox): one contract table, admin docs in every locale, manual-test box and automation row (S, after 2, 4 and 5)

    Cross-issue amendments (decisions taken together with #5409, #4942, #2873, #4942):

  3. added
    agent-ready
    and removed
    needs discussion
    on Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readypriority: mediumsecurity

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions