Skip to content

Commit 2364978

Browse files
committed
feat(supervisor): dial an https:// upstream proxy with TLS and a client cert
The supervisor sends its resolved sandbox id to the corporate proxy as the Basic username, and that value is an identifier rather than a secret: the proxy must not treat it as authorization on its own. Until now nothing on the hop established either party. The proxy could not tell one caller from another, and the supervisor could not tell the proxy from anything else answering on its address -- the more serious direction, because an impostor there chooses where the traffic actually leaves from while every layer reports success. An https:// proxy is now dialed through TLS before the CONNECT is written: --upstream-proxy-ca roots the proxy's certificate is verified against, and the only roots used --upstream-proxy-client-cert identity presented to the proxy --upstream-proxy-client-key Roots are the operator's CA alone, never the system roots: the proxy is a named internal service, and accepting any publicly-trusted certificate for that name would defeat the verification. The CONNECT request and any credential on it also stop crossing the network in the clear. Every misconfiguration is fatal at startup rather than degrading quietly: an https:// proxy without a CA, TLS material against an http:// proxy (which would be silently ignored while the argv claims the hop is authenticated), half a client identity, or a readable CA bundle holding no certificate. PrefixedStream carries either a plain or a TLS socket through an enum rather than a generic, so it stays one concrete type for callers downstream. Covered end to end: a proxy presenting a CA-signed certificate completes a real TLS CONNECT, and one presenting a certificate outside the pinned CA yields no tunnel.
1 parent 2daf833 commit 2364978

2 files changed

Lines changed: 469 additions & 16 deletions

File tree

‎crates/openshell-sandbox/src/main.rs‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,10 @@ struct Args {
225225
// only as command-line arguments (no `env =`), because the driver
226226
// controls the supervisor's argv while a sandbox image could bake
227227
// matching `ENV` values.
228-
/// Corporate forward proxy URL (`http://host:port`) for upstream TLS egress.
228+
/// Corporate forward proxy URL (`http://host:port` or `https://host:port`)
229+
/// for upstream TLS egress. `https://` authenticates the proxy to this
230+
/// supervisor and encrypts the CONNECT hop; it requires
231+
/// `--upstream-proxy-ca`.
229232
#[arg(long)]
230233
upstream_proxy: Option<String>,
231234

@@ -253,6 +256,20 @@ struct Args {
253256
/// if the sandbox identity is unresolved.
254257
#[arg(long)]
255258
upstream_proxy_auth_sandbox_identity: bool,
259+
260+
/// PEM CA bundle the `https://` proxy's certificate is verified against.
261+
/// Required with an `https://` proxy and rejected without one.
262+
#[arg(long)]
263+
upstream_proxy_ca: Option<String>,
264+
265+
/// PEM client certificate presented to the proxy, for a proxy that
266+
/// authenticates its callers. Set together with the key.
267+
#[arg(long)]
268+
upstream_proxy_client_cert: Option<String>,
269+
270+
/// PEM private key for `--upstream-proxy-client-cert`.
271+
#[arg(long)]
272+
upstream_proxy_client_key: Option<String>,
256273
}
257274

258275
/// Copy the running executable to `dest`, creating parent directories as
@@ -717,6 +734,9 @@ fn main() -> Result<()> {
717734
proxy_auth_allow_insecure: args.upstream_proxy_auth_allow_insecure,
718735
proxy_connect_by_hostname: args.upstream_proxy_connect_by_hostname,
719736
proxy_auth_sandbox_identity: args.upstream_proxy_auth_sandbox_identity,
737+
proxy_ca: args.upstream_proxy_ca,
738+
proxy_client_cert: args.upstream_proxy_client_cert,
739+
proxy_client_key: args.upstream_proxy_client_key,
720740
};
721741

722742
run_sandbox(

0 commit comments

Comments
 (0)