feat(egress): support chained upstream CONNECT proxy under the fast-sandbox profile

Author: PangjipingCreated Sep 23, 2026Updated Sep 27, 2026

name: Feature Request about: Suggest an idea for OpenSandbox title: 'feat(egress): support chained upstream CONNECT proxy under the fast-sandbox profile' labels: '' assignees: ''

Why do you need it?

PR #1816 adds opt-in chained upstream proxy support to the egress sidecar's transparent mitmproxy path (OPENSANDBOX_EGRESS_UPSTREAM_PROXY / OPENSANDBOX_EGRESS_UPSTREAM_PROXY_AUTH), so sandbox egress can be routed through a managed forward proxy (corporate egress gateway, DLP boundary, audit point). Closes #1815.

However, the fast-sandbox profile is explicitly rejected at startup (upstream_proxy_config.go): OPENSANDBOX_EGRESS_UPSTREAM_PROXY is not supported with OPENSANDBOX_EGRESS_PROFILE=fast-sandbox. Deployments running the fast-sandbox profile therefore cannot route their egress through a corporate proxy/DLP boundary, and must stay on the per-sandbox sidecar profile to get this capability.

The rejection is deliberate and fail-closed, not a hard technical blocker. The sidecar implementation's security model depends on three things (see the comment at the top of components/egress/pkg/nftables/upstream.go):

  1. The upstream proxy endpoint is infrastructure, not sandbox egress: reachable only by the mitmproxy process UID + destination port (uid+dport-scoped accept rules over the upstream_proxy_v4/v6 sets).
  2. The proxy IP must never land in the sandbox allow sets — otherwise sandbox code could CONNECT to the proxy directly and reach otherwise-denied destinations (an open-relay bypass of the egress policy).
  3. For hostname endpoints, the dnsproxy infra-domain mechanism resolves the name and feeds the resolved IPs into the UID-scoped nft sets.

Fast-sandbox is a different deployment form: one egress control plane serving N sandboxes sharing one host/network domain, and it currently lacks the per-UID DNS/nft scoping equivalent. Without it, supporting the feature would either leak the proxy IP into shared allow sets (security hole) or leave mitmproxy unable to reach the proxy (broken).

How could it be?

Add an equivalent infrastructure DNS/nft scoping mechanism to the fast-sandbox profile so the chained upstream proxy can be enabled there with the same fail-closed guarantees:

  • Per-sandbox (or per-mitmproxy-worker) UID scoping for the upstream_proxy_v4/v6 sets and accept rules, mirroring the sidecar model.
  • The dnsproxy infra-domain registration path (SetInfraDomain + uid-scoped nft callbacks) wired into the fast-sandbox control plane.
  • Startup validation updated to accept OPENSANDBOX_EGRESS_UPSTREAM_PROXY under OPENSANDBOX_EGRESS_PROFILE=fast-sandbox once the scoping infrastructure exists (i.e. lift the check in upstreamProxySpecForProfile).
  • Unit/integration coverage at parity with the sidecar profile, including deny-all policy interplay and metric labels for failed nft updates.

Acceptance: with OPENSANDBOX_EGRESS_PROFILE=fast-sandbox and a configured upstream proxy, (a) all mitmproxy-handled egress is chained via CONNECT through the upstream proxy, (b) sandbox workloads cannot reach the proxy endpoint directly, and (c) misconfigurations fail startup.

Other related information

  • Feature issue: #1815
  • Implementation PR: #1816 (explicitly rejects fast-sandbox; see components/egress/upstream_proxy_config.go and components/egress/pkg/nftables/upstream.go)
  • Related docs: components/egress/docs/mitmproxy-transparent.md, docs/architecture/network/egress.md

Source: opensandbox-group/OpenSandbox