Skip to content

Commit dfae55c

Browse files
committed
fix(sandbox,podman): allow proxy auth without insecure acknowledgement for https:// proxies
For an https:// proxy the Proxy-Authorization credential travels inside the verified TLS session, so the proxy_auth_allow_insecure acknowledgement is unnecessary. Previously both http:// and https:// proxies required it, producing a misleading cleartext-risk diagnostic for a path that is already encrypted. Skip the requirement when the proxy URL uses https://; the acknowledgement is still tolerated if set. Updated in both the supervisor and Podman driver validation paths, with docs and tests. Signed-off-by: Philippe Martin <[email protected]>
1 parent f2848be commit dfae55c

4 files changed

Lines changed: 52 additions & 19 deletions

File tree

‎crates/openshell-driver-podman/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ Podman resources after out-of-band container removal or label drift.
367367
| `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. |
368368
| `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. |
369369
| `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-
| `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. |
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 with an `http://` proxy; not required for `https://` proxies (the credential travels inside the verified TLS session) but tolerated if set. Rejected when no auth file is configured. |
371371
| `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. |
372372
| `OPENSHELL_PODMAN_USERNS` | `--userns` | unset | User namespace mode for sandbox containers (e.g. `auto`). When unset, containers use the default user namespace. |
373373
| `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. |

‎crates/openshell-driver-podman/src/config.rs‎

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,8 @@ impl PodmanComputeConfig {
316316
/// `gateway.toml` and exposed in container metadata.
317317
pub fn validate_proxy_config(&self) -> Result<(), crate::client::PodmanApiError> {
318318
use openshell_core::driver_utils::{UpstreamProxyUrlError, parse_upstream_proxy_url};
319-
if let Some(url) = &self.https_proxy {
320-
parse_upstream_proxy_url(url).map_err(|err| {
319+
let proxy_secure = if let Some(url) = &self.https_proxy {
320+
let addr = parse_upstream_proxy_url(url).map_err(|err| {
321321
crate::client::PodmanApiError::InvalidInput(match err {
322322
UpstreamProxyUrlError::Empty => {
323323
"https_proxy must not be empty when set".to_string()
@@ -330,7 +330,10 @@ impl PodmanComputeConfig {
330330
err => format!("https_proxy {err}"),
331331
})
332332
})?;
333-
}
333+
addr.secure
334+
} else {
335+
false
336+
};
334337

335338
// The supervisor treats a present-but-empty driver-supplied argument
336339
// as a fatal misconfiguration, so never accept (and later pass) one.
@@ -364,8 +367,10 @@ impl PodmanComputeConfig {
364367
// Basic auth over the plain-TCP proxy connection is readable by
365368
// anyone on the network path; sending it requires an explicit
366369
// operator acknowledgement rather than being an implicit side
367-
// effect of configuring credentials.
368-
if self.proxy_auth_allow_insecure != Some(true) {
370+
// effect of configuring credentials. For an https:// proxy the
371+
// credential is inside the verified TLS session, so the
372+
// acknowledgement is unnecessary (but tolerated).
373+
if self.proxy_auth_allow_insecure != Some(true) && !proxy_secure {
369374
return Err(crate::client::PodmanApiError::InvalidInput(
370375
"proxy_auth_file sends the credential as cleartext Basic auth over the \
371376
plain-TCP connection to the http:// proxy; set proxy_auth_allow_insecure \
@@ -854,6 +859,16 @@ mod tests {
854859
}
855860
}
856861

862+
#[test]
863+
fn validate_proxy_config_accepts_auth_file_without_acknowledgement_for_https_proxy() {
864+
let cfg = PodmanComputeConfig {
865+
https_proxy: Some("https://proxy.corp.com:3130".to_string()),
866+
proxy_auth_file: Some("/etc/openshell/secrets/proxy-auth".to_string()),
867+
..PodmanComputeConfig::default()
868+
};
869+
assert!(cfg.validate_proxy_config().is_ok());
870+
}
871+
857872
#[test]
858873
fn validate_proxy_config_accepts_connect_by_hostname_with_proxy() {
859874
for by_hostname in [Some(true), Some(false)] {

‎crates/openshell-supervisor-network/src/upstream_proxy.rs‎

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -461,11 +461,10 @@ impl UpstreamProxyConfig {
461461
};
462462

463463
// Cleartext-credential acknowledgement. `Proxy-Authorization: Basic`
464-
// travels over plain TCP to the http:// proxy, so credentials are
465-
// only sent when the operator explicitly opted in. The compute driver
466-
// enforces the same pairing at sandbox-create time; enforcing it here
467-
// as well keeps the supervisor fail-closed against a bypassed or
468-
// foreign driver.
464+
// travels over plain TCP to an http:// proxy, so credentials are
465+
// only sent when the operator explicitly opted in. For an https://
466+
// proxy the credential is inside the verified TLS session, so the
467+
// acknowledgement is unnecessary (but tolerated).
469468
let allow_insecure = match auth_allow_insecure.as_deref().map(str::trim) {
470469
None => false,
471470
Some("true") => true,
@@ -480,7 +479,7 @@ impl UpstreamProxyConfig {
480479
"{ARG_PROXY_AUTH_ALLOW_INSECURE} is set but no {ARG_PROXY_AUTH_FILE} is configured"
481480
));
482481
}
483-
if auth_file.is_some() && !allow_insecure {
482+
if auth_file.is_some() && !allow_insecure && !secure {
484483
return Err(format!(
485484
"{ARG_PROXY_AUTH_FILE} sends the credential as cleartext Basic auth \
486485
over the plain-TCP proxy connection; refusing without \
@@ -1416,7 +1415,7 @@ mod tests {
14161415
}
14171416

14181417
#[test]
1419-
fn auth_file_without_insecure_acknowledgement_is_fatal() {
1418+
fn auth_file_without_insecure_acknowledgement_is_fatal_for_http_proxy() {
14201419
// Basic auth over the plain-TCP proxy connection is readable on the
14211420
// network path; sending it requires the explicit opt-in.
14221421
let err = config_from(&[
@@ -1428,6 +1427,23 @@ mod tests {
14281427
assert!(err.contains("cleartext"), "{err}");
14291428
}
14301429

1430+
#[test]
1431+
fn auth_file_without_insecure_acknowledgement_is_allowed_for_https_proxy() {
1432+
install_crypto_provider();
1433+
let file = tempfile::NamedTempFile::new().unwrap();
1434+
std::fs::write(file.path(), "user:secret\n").unwrap();
1435+
let path = file.path().to_str().unwrap().to_string();
1436+
let cfg = config_ok(&[
1437+
(HTTPS_PROXY, "https://proxy.corp.com:3130"),
1438+
(PROXY_AUTH_FILE, &path),
1439+
]);
1440+
let ep = proxy_endpoint(&cfg, "example.com").unwrap();
1441+
assert!(
1442+
ep.proxy_authorization.is_some(),
1443+
"https:// proxy must accept auth without the insecure acknowledgement"
1444+
);
1445+
}
1446+
14311447
#[test]
14321448
fn invalid_insecure_acknowledgement_value_is_fatal() {
14331449
for value in ["false", "yes", "1", "TRUE"] {

‎docs/reference/gateway-config.mdx‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -693,14 +693,16 @@ health_check_interval_secs = 10
693693
# supervisor, so a credential accepted here is never rejected in-container.
694694
# Keep gateway.toml and the auth file owner-readable only (mode 0600).
695695
#
696-
# WARNING: the supervisor sends the credential as a Proxy-Authorization:
697-
# Basic header over the plain-TCP connection to the http:// proxy. Basic
696+
# WARNING: with an http:// proxy the supervisor sends the credential as a
697+
# Proxy-Authorization: Basic header over the plain-TCP connection. Basic
698698
# auth is base64, not encryption: anyone on the network path between the
699699
# sandbox host and the proxy can recover the credential. Because of that,
700-
# proxy_auth_file requires the explicit acknowledgement
701-
# proxy_auth_allow_insecure = true; without it the configuration is
702-
# rejected at gateway startup. Only opt in when the path to the proxy is a
703-
# trusted network segment.
700+
# proxy_auth_file with an http:// proxy requires the explicit
701+
# acknowledgement proxy_auth_allow_insecure = true; without it the
702+
# configuration is rejected at gateway startup. Only opt in when the path
703+
# to the proxy is a trusted network segment. For an https:// proxy the
704+
# credential is sent inside the verified TLS session, so the
705+
# acknowledgement is not required (but tolerated if set).
704706
#
705707
# proxy_ca_bundle points at a PEM CA bundle (on the gateway host) trusted for
706708
# the corporate proxy. A CA certificate is not secret, so the gateway

0 commit comments

Comments
 (0)