Skip to content

TD-5305: the sandbox's egress proxy and its audit rows - #131

Merged
captcrock merged 1 commit into
mainfrom
td/5305-egress-proxy
Nov 24, 2026
Merged

captcrock merged 1 commit into
mainfrom
td/5305-egress-proxy

Conversation

@captcrock

Copy link
Copy Markdown
Contributor

Full sandbox (owner brief section 4), design sandboxing.md R3. This is PR 1 of 2 as agreed: the proxy and audit first, then the bridge in TD-5306. Nothing uses the proxy yet, and network stays fully off. TD-5306 adds the setting (off by default) and the bridge from inside the bubblewrap network namespace.

core/tstd/sandbox/proxy.py is an asyncio proxy for CONNECT and plain http://, with no SOCKS, no TLS interception and no new dependency. It has no listener of its own: the daemon hands it one connection at a time. On Linux that will be over a socket pair, so nothing on the host listens.

  • Token: each command gets its own ProxyGrant token, read from Basic Proxy-Authorization. A missing, wrong or revoked token gets 407 and nothing is dialled. One command's token never carries another's grant.
  • Host rules: the host must be on the grant's list (boundary.network). A bare name allows ports 80 and 443; host:port allows that port. An IP literal must itself be listed.
  • Resolution: the proxy resolves the name itself. It refuses an answer that is loopback (IPv4-mapped included), link-local, unspecified, multicast, reserved, or one of this computer's own addresses, and refuses the whole answer list if any one fails. It then dials the address it checked.
  • Plain HTTP: the upstream request goes without proxy headers and with Connection: close, so a second request cannot name an unchecked host.

Audit: every allow and deny becomes a row in the new append-only network_egress table (schema v8): tool call id, host, port, the address dialled, verdict and reason. No traffic or URL path is kept. An audit failure neither opens nor hangs the connection.

Prime directive §2.3: the proxy is added to test_outbound_hosts.py's outbound-capable set with its reason: it dials only hosts the person listed, for a command they ran.

Groundwork for TD-5306, checked on this Linux machine with the product's real seccomp filter, inside bwrap --unshare-all:

  • the namespace's loopback is up;
  • a direct connection out fails with ENETUNREACH;
  • socket(AF_UNIX) is still refused;
  • a socket passed in over an inherited socket pair (SCM_RIGHTS) carries traffic.

So design option 1, keeping the filter as it is, works.

Tests: test_sandbox_proxy.py (new). It contacts no outside host: the allowed host is a local server reached through a connect seam from an RFC 5737 test address. Full core suite: 9062 passed. The one failure, the outbound-hosts confinement test, is fixed in this PR. ruff and mypy are clean. Release scan: 0 hits.

🤖 Generated with Claude Code

sandboxing.md R3, first PR of two (signed off ahead of the work): an
asyncio HTTP proxy for CONNECT and plain http:// with no listener of
its own. A request needs the command's own token (407 otherwise); the
host must be on the grant's list from boundary.network (a bare name is
ports 80 and 443, an IP literal only when listed); the proxy resolves
names itself, refuses loopback, link-local and own-host answers, and
dials the address it checked. Plain HTTP is one request per connection.
Every allow and deny is a network_egress audit row (schema v8) with the
tool call id. Nothing uses it yet: TD-5306 adds the setting and the
bridge from inside the sandbox's network namespace. Network stays off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@captcrock
captcrock merged commit a16cbaa into main Nov 24, 2026
4 checks passed
@captcrock
captcrock deleted the td/5305-egress-proxy branch November 24, 2026 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant