You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit a13c4dc
Browse filesBrowse the repository at this point in the historyBrowse files
feat(sandbox,podman): trust corporate CA for https:// proxies and intercepted TLS
The corporate proxy chaining only accepted plain http:// proxy URLs, so
operators whose forward proxy terminates TLS with a private corporate CA
had no way to reach it, and TLS-intercepting proxies (mitmproxy, squid
ssl-bump) that re-sign tunneled server certificates broke every upstream
handshake after CONNECT.
The supervisor now accepts https:// proxy URLs: it wraps the connection to
the proxy in TLS before the CONNECT handshake, verifying the proxy
certificate against the built-in Mozilla roots, the system CA bundle, and an
optional operator corporate CA bundle. The upstream dial returns a
Plain/Tls stream enum consumed generically by the relay paths.
The corporate CA is delivered as a driver-supplied command-line argument
(--upstream-proxy-ca-bundle), never an environment variable, matching the
hardened proxy-config model where a sandbox image cannot influence the
operator's egress boundary. It is folded into the sandbox combined trust
bundle (write_ca_files) and the L7 upstream verification store
(build_upstream_client_config) at startup, so intercepted upstream
handshakes succeed and sandbox workloads trust the re-signed certificates.
Configuration is fail-closed: a CA bundle set without a proxy, or an
unreadable or certificate-free file, is fatal rather than silently
weakening the trust boundary.
The shared parse_upstream_proxy_url validator accepts https:// (recording
the scheme so the driver and supervisor agree), keeping the explicit-port
requirement. The Podman driver gains a proxy_ca_bundle operator setting
(TOML, --sandbox-proxy-ca-bundle, OPENSHELL_SANDBOX_PROXY_CA_BUNDLE) that
bind-mounts the host PEM read-only into the sandbox (a CA certificate is not
secret) and points --upstream-proxy-ca-bundle at it, with a create-time
readability check.
The standalone dev gateway task passes OPENSHELL_SANDBOX_PROXY_CA_BUNDLE
through to the generated podman config, so a local gateway can be pointed at
a TLS-intercepting proxy without hand-editing the regenerated TOML.
Refs NVIDIA#1792
Signed-off-by: Philippe Martin <[email protected]>
proxy cannot reach the container host. `NO_PROXY` matching is port-aware and
198
198
resolution-aware: an entry with a `:port` qualifier only bypasses that port,
199
199
and IP/CIDR entries also match hostnames through their validated resolved
200
-
addresses, with the direct dial limited to the addresses the entry contains. Only `http://` proxy URLs in explicit
201
-
`http://host:port` form are supported — the scheme and port are both
202
-
required, and a path, query, or fragment is rejected. Local DNS resolution
200
+
addresses, with the direct dial limited to the addresses the entry contains. `http://` and `https://` proxy URLs in explicit
201
+
`scheme://host:port` form are supported — the scheme and port are both
202
+
required, and a path, query, or fragment is rejected. For an `https://` proxy
203
+
the supervisor wraps the connection to the proxy in TLS before the CONNECT
204
+
handshake, verifying the proxy certificate against the built-in and system
205
+
roots plus the optional operator CA bundle (see below). Local DNS resolution
203
206
and SSRF validation still run before the proxied dial, and the CONNECT
204
207
target sent to the corporate proxy is a validated resolved address, so the
205
208
proxy performs no DNS resolution of its own and the tunnel stays bound to
@@ -216,16 +219,31 @@ enhancement and out of scope.) The workload child's proxy variables are
216
219
unaffected — they are always rewritten to point at the local policy proxy.
217
220
218
221
The configuration is fail-closed: a setting that is present but invalid — an
219
-
empty value, an unsupported or malformed proxy URL, an unreadable auth file,
220
-
a malformed credential, or an auth file or `NO_PROXY` list set while no proxy
221
-
URL is configured — is fatal to supervisor startup instead of being treated
222
-
as unset, so a misconfiguration can never silently degrade to direct dialing
223
-
or unauthenticated proxy access. Only an omitted argument means "no proxy".
224
-
The driver validates the same rules at sandbox-create time through
225
-
validators shared with the supervisor
222
+
empty value, an unsupported or malformed proxy URL, an unreadable auth file or
223
+
CA bundle, a malformed credential, or an auth file, `NO_PROXY` list, or CA
224
+
bundle set while no proxy URL is configured — is fatal to supervisor startup
225
+
instead of being treated as unset, so a misconfiguration can never silently
226
+
degrade to direct dialing or unauthenticated proxy access. Only an omitted
227
+
argument means "no proxy". The driver validates the same rules at
228
+
sandbox-create time through validators shared with the supervisor
226
229
(`openshell_core::driver_utils::parse_upstream_proxy_url` and
227
230
`parse_upstream_proxy_credential`).
228
231
232
+
An optional operator CA bundle (`--upstream-proxy-ca-bundle`, a PEM path the
233
+
driver bind-mounts read-only into the sandbox) extends the trust boundary for
234
+
corporate proxies. A CA certificate is not secret, so unlike the auth file it
235
+
travels as a plain read-only bind mount rather than a driver secret. It is
236
+
trusted in two places: the TLS handshake with an `https://` proxy, and —
237
+
because a TLS-intercepting proxy (mitmproxy, squid `ssl-bump`) re-signs
238
+
tunneled server certificates with the same CA — the sandbox combined trust
239
+
bundle (`write_ca_files`) and the L7 upstream re-encryption store
240
+
(`build_upstream_client_config`). Folding it into both means intercepted
241
+
upstream handshakes succeed and sandbox workload processes trust the re-signed
242
+
certificates; trusting it only for the proxy-listener handshake would leave
243
+
every intercepted upstream connection failing. The bundle is valid with either
244
+
an `http://` or `https://` proxy (an intercepting proxy can be reached over
245
+
plain HTTP) and is fail-closed: an unreadable or certificate-free file is fatal.
246
+
229
247
Proxy credentials are never embedded in the URL: an inline `user:pass@` is
230
248
rejected because it would be stored in `gateway.toml` and exposed in container
231
249
metadata. Operators supply credentials via `proxy_auth_file`; the driver
#[error("proxy URL must include an explicit scheme, e.g. http://proxy.corp.com:3128")]
90
142
MissingScheme,
91
-
/// The URL uses a scheme other than `http` (TLS and SOCKS proxies are
143
+
/// The URL uses a scheme other than `http` or `https` (SOCKS proxies are
92
144
/// not supported by the sandbox supervisor).
93
145
#[error(
94
-
"unsupported proxy scheme '{0}': only http:// forward proxies are\
95
-
supported by the sandbox supervisor"
146
+
"unsupported proxy scheme '{0}': only http:// and https:// forward\
147
+
proxies are supported by the sandbox supervisor"
96
148
)]
97
149
UnsupportedScheme(String),
98
150
/// The URL has no explicit port. Corporate proxies rarely listen on the
/// Parse and validate a corporate upstream-proxy URL.
124
176
///
125
-
/// The accepted grammar is exactly `http://host:port`: the scheme and the
126
-
/// port must both be explicit, only `http://` proxies are accepted, and
127
-
/// inline userinfo is rejected. The URL must address the proxy only: a path
128
-
/// (other than a bare trailing `/`), query, or fragment is rejected rather
129
-
/// than silently discarded.
177
+
/// The accepted grammar is exactly `http://host:port` or `https://host:port`:
178
+
/// the scheme and the port must both be explicit, only `http://` and
179
+
/// `https://` proxies are accepted, and inline userinfo is rejected. The URL
180
+
/// must address the proxy only: a path (other than a bare trailing `/`),
181
+
/// query, or fragment is rejected rather than silently discarded. The
182
+
/// returned [`UpstreamProxyAddr::secure`] records whether the `https://`
183
+
/// scheme was used so the supervisor knows to TLS-wrap the proxy connection.
// Explicit-port presence was verified above; `port()` is `None` only
178
-
// when the URL spells out the scheme default (`:80`), which the url crate
179
-
// normalizes away.
180
-
let port = parsed.port().unwrap_or(80);
235
+
// Explicit-port presence was verified above; `port()` is `None` only when
236
+
// the URL spells out the scheme default (`:80` for http, `:443` for
237
+
// https), which the url crate normalizes away.
238
+
let port = parsed.port().unwrap_or(if secure {443}else{80});
181
239
if port == 0{
182
240
returnErr(UpstreamProxyUrlError::ZeroPort);
183
241
}
184
-
Ok(UpstreamProxyAddr{ host, port })
242
+
Ok(UpstreamProxyAddr{ host, port, secure})
185
243
}
186
244
187
245
/// Return `true` when the raw URL's authority carries an explicit `:port`.
@@ -585,6 +643,20 @@ mod tests {
585
643
let addr = parse_upstream_proxy_url("http://proxy.corp.com:8080").unwrap();
586
644
assert_eq!(addr.host,"proxy.corp.com");
587
645
assert_eq!(addr.port,8080);
646
+
assert!(!addr.secure,"http:// is not TLS-wrapped");
647
+
}
648
+
649
+
#[test]
650
+
fnupstream_proxy_url_accepts_https_with_port(){
651
+
let addr = parse_upstream_proxy_url("https://proxy.corp.com:3130").unwrap();
652
+
assert_eq!(addr.host,"proxy.corp.com");
653
+
assert_eq!(addr.port,3130);
654
+
assert!(addr.secure,"https:// is TLS-wrapped");
655
+
// An explicit scheme-default port (:443) is accepted even though the
656
+
// url crate normalizes it away in the parsed form.
657
+
let addr = parse_upstream_proxy_url("https://proxy.corp.com:443").unwrap();
for url in["https://proxy:443","socks5://proxy:1080"]{
649
-
assert!(matches!(
650
-
parse_upstream_proxy_url(url),
651
-
Err(UpstreamProxyUrlError::UnsupportedScheme(_))
652
-
));
719
+
fnupstream_proxy_url_rejects_socks_schemes(){
720
+
// http:// and https:// are supported; only other schemes (SOCKS, etc.)
Copy file name to clipboardExpand all lines: crates/openshell-driver-podman/README.md
+4-3Lines changed: 4 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -364,16 +364,17 @@ Podman resources after out-of-band container removal or label drift.
364
364
|`OPENSHELL_PODMAN_TLS_CA`|`--podman-tls-ca`| unset | Host path to the CA certificate mounted for sandbox mTLS. |
365
365
|`OPENSHELL_PODMAN_TLS_CERT`|`--podman-tls-cert`| unset | Host path to the client certificate mounted for sandbox mTLS. |
366
366
|`OPENSHELL_PODMAN_TLS_KEY`|`--podman-tls-key`| unset | Host path to the client private key mounted for sandbox mTLS. |
367
-
|`OPENSHELL_SANDBOX_HTTPS_PROXY`|`--sandbox-https-proxy`| unset | Corporate forward proxy URL for the supervisor's upstream TLS dials, chained with HTTP CONNECT. Only credential-free `http://host:port` URLs are supported (scheme and port required). Plain-HTTP requests always dial directly. |
367
+
|`OPENSHELL_SANDBOX_HTTPS_PROXY`|`--sandbox-https-proxy`| unset | Corporate forward proxy URL for the supervisor's upstream TLS dials, chained with HTTP CONNECT. Credential-free `http://host:port`and `https://host:port`URLs are supported (scheme and port required). For an `https://` proxy the supervisor TLS-wraps the proxy connection, verifying the proxy certificate against the built-in and system roots plus `--sandbox-proxy-ca-bundle`. Plain-HTTP requests always dial directly. |
368
368
|`OPENSHELL_SANDBOX_NO_PROXY`|`--sandbox-no-proxy`| unset | Comma-separated `NO_PROXY` list (hostnames, domain suffixes, IPs, CIDRs, each with an optional `:port` qualifier) dialed directly instead of through the corporate proxy. IP/CIDR entries also match hostnames through their validated DNS resolution. |
369
369
|`OPENSHELL_SANDBOX_PROXY_AUTH_FILE`|`--sandbox-proxy-auth-file`| unset | Path to a file containing the proxy credentials as `user:pass`. Staged as a root-only Podman secret so credentials never appear in config or container metadata. Requires the insecure-auth acknowledgement below. |
370
370
|`OPENSHELL_SANDBOX_PROXY_AUTH_ALLOW_INSECURE`|`--sandbox-proxy-auth-allow-insecure`| unset | Explicit acknowledgement (`true`) that the credential is sent as cleartext Basic auth over the plain-TCP connection to the `http://` proxy. Required when the auth file is set; rejected when it is not. |
371
371
|`OPENSHELL_SANDBOX_PROXY_CONNECT_BY_HOSTNAME`|`--sandbox-proxy-connect-by-hostname`| unset | Send the destination hostname in CONNECT requests instead of a validated IP. Last resort for proxies whose ACLs filter on hostnames: the proxy then resolves the name itself, so sandbox SSRF/`allowed_ips` validation no longer binds the connection. |
372
372
|`OPENSHELL_PODMAN_USERNS`|`--userns`| unset | User namespace mode for sandbox containers (e.g. `auto`). When unset, containers use the default user namespace. |
373
+
|`OPENSHELL_SANDBOX_PROXY_CA_BUNDLE`|`--sandbox-proxy-ca-bundle`| unset | Path (on the gateway host) to a PEM CA bundle trusted for the corporate proxy. Bind-mounted read-only into the sandbox (a CA certificate is not secret). Trusted for the `https://` proxy TLS handshake and, because TLS-intercepting proxies re-sign tunneled certificates, folded into the sandbox trust bundle and upstream verification. Requires a proxy URL; the file must exist and hold at least one certificate. |
373
374
374
375
Through the gateway, the same settings are the `https_proxy`, `no_proxy`,
375
-
`proxy_auth_file`, `proxy_auth_allow_insecure`, and
376
-
`proxy_connect_by_hostname` keys under `[openshell.drivers.podman]`; see
0 commit comments