Skip to content

Commit 707a50f

Browse files
committed
fix(sandbox,podman): strip new reserved proxy vars and complete docs/tests
Follow-ups from review: - Add OPENSHELL_UPSTREAM_PROXY_AUTH_ALLOW_INSECURE and OPENSHELL_UPSTREAM_PROXY_CONNECT_BY_HOSTNAME to the supervisor-only strip list so workload child processes never inherit them, matching the documented contract for the other reserved proxy variables, and cover both in the supervisor-only variable test. - Document all five OPENSHELL_SANDBOX_* proxy variables in the mise run gateway help text, marked Podman-only and stating the auth-file/acknowledgement pairing, and complete the gateway-key list in the Podman README. - Add NO_PROXY composition coverage for bracketed IPv6 entries with port qualifiers, bare IPv6 entries, and IPv6 CIDR matching against an IPv6-literal host and against a hostname's resolved addresses, including the port-qualified CIDR form. Signed-off-by: Philippe Martin <[email protected]>
1 parent cdf5d89 commit 707a50f

4 files changed

Lines changed: 77 additions & 2 deletions

File tree

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,9 @@ Podman resources after out-of-band container removal or label drift.
351351
| `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. |
352352
| `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. |
353353

354-
Through the gateway, the same settings are the `https_proxy`, `no_proxy`, and
355-
`proxy_auth_file` keys under `[openshell.drivers.podman]`; see
354+
Through the gateway, the same settings are the `https_proxy`, `no_proxy`,
355+
`proxy_auth_file`, `proxy_auth_allow_insecure`, and
356+
`proxy_connect_by_hostname` keys under `[openshell.drivers.podman]`; see
356357
`docs/reference/gateway-config.mdx`.
357358

358359
This is an operator-owned egress boundary: the supervisor reads it from reserved

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

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,6 +1198,54 @@ mod tests {
11981198
}
11991199
}
12001200

1201+
#[test]
1202+
fn no_proxy_bracketed_ipv6_entry_honors_port_qualifier() {
1203+
// The colons of an IPv6 literal must not be misread as a port
1204+
// qualifier; only the bracketed form can carry one.
1205+
let cfg = no_proxy_cfg("[fd00::1]:8443");
1206+
assert!(bypasses_port(&cfg, "fd00::1", 8443));
1207+
assert!(bypasses_port(&cfg, "[fd00::1]", 8443));
1208+
assert!(!bypasses_port(&cfg, "fd00::1", 443));
1209+
assert!(!bypasses_port(&cfg, "fd00::2", 8443));
1210+
1211+
// A bare IPv6 entry keeps every-port semantics.
1212+
let cfg = no_proxy_cfg("fd00::1");
1213+
assert!(bypasses_port(&cfg, "fd00::1", 8443));
1214+
assert!(bypasses_port(&cfg, "fd00::1", 443));
1215+
}
1216+
1217+
#[test]
1218+
fn no_proxy_ipv6_cidr_matches_resolved_addresses_of_hostnames() {
1219+
let cfg = no_proxy_cfg("fd00::/8");
1220+
// An IPv6-literal host inside the range bypasses at hostname level.
1221+
assert!(bypasses(&cfg, "fd00::7"));
1222+
assert!(!bypasses(&cfg, "2001:db8::1"));
1223+
1224+
// A hostname resolving into the range dials directly, restricted to
1225+
// the resolved addresses the entry contains.
1226+
let inside = sock("fd00::42", 443);
1227+
let outside = sock("2001:db8::1", 443);
1228+
match cfg.decision("svc.internal", 443, &[outside, inside]) {
1229+
ProxyDecision::Direct(addrs) => assert_eq!(addrs, vec![inside]),
1230+
ProxyDecision::Proxy(ep) => panic!("expected direct dial, got proxy {ep:?}"),
1231+
}
1232+
}
1233+
1234+
#[test]
1235+
fn no_proxy_ipv6_cidr_honors_port_qualifier() {
1236+
let cfg = no_proxy_cfg("fd00::/8:6443");
1237+
assert!(bypasses_port(&cfg, "fd00::7", 6443));
1238+
assert!(!bypasses_port(&cfg, "fd00::7", 443));
1239+
match cfg.decision("svc.internal", 6443, &[sock("fd00::42", 6443)]) {
1240+
ProxyDecision::Direct(addrs) => assert_eq!(addrs, vec![sock("fd00::42", 6443)]),
1241+
ProxyDecision::Proxy(ep) => panic!("expected direct dial, got proxy {ep:?}"),
1242+
}
1243+
assert!(matches!(
1244+
cfg.decision("svc.internal", 443, &[sock("fd00::42", 443)]),
1245+
ProxyDecision::Proxy(_)
1246+
));
1247+
}
1248+
12011249
#[test]
12021250
fn no_proxy_hostname_match_authorizes_all_resolved_addresses() {
12031251
let cfg = no_proxy_cfg("internal.corp");

‎crates/openshell-supervisor-process/src/process.rs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ const SUPERVISOR_ONLY_ENV_VARS: &[&str] = &[
8585
openshell_core::sandbox_env::UPSTREAM_HTTPS_PROXY,
8686
openshell_core::sandbox_env::UPSTREAM_NO_PROXY,
8787
openshell_core::sandbox_env::UPSTREAM_PROXY_AUTH_FILE,
88+
openshell_core::sandbox_env::UPSTREAM_PROXY_AUTH_ALLOW_INSECURE,
89+
openshell_core::sandbox_env::UPSTREAM_PROXY_CONNECT_BY_HOSTNAME,
8890
];
8991

9092
pub fn is_supervisor_only_env_var(key: &str) -> bool {
@@ -2269,6 +2271,8 @@ mod tests {
22692271
openshell_core::sandbox_env::UPSTREAM_HTTPS_PROXY,
22702272
openshell_core::sandbox_env::UPSTREAM_NO_PROXY,
22712273
openshell_core::sandbox_env::UPSTREAM_PROXY_AUTH_FILE,
2274+
openshell_core::sandbox_env::UPSTREAM_PROXY_AUTH_ALLOW_INSECURE,
2275+
openshell_core::sandbox_env::UPSTREAM_PROXY_CONNECT_BY_HOSTNAME,
22722276
] {
22732277
assert!(
22742278
is_supervisor_only_env_var(key),

‎tasks/scripts/gateway.sh‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,28 @@ Environment:
4141
Podman supervisor sideload image. Defaults to
4242
openshell/supervisor:dev and is built on demand.
4343
44+
Corporate proxy (Podman driver only):
45+
OPENSHELL_SANDBOX_HTTPS_PROXY
46+
Corporate forward proxy URL for sandbox TLS
47+
egress, in explicit http://host:port form.
48+
OPENSHELL_SANDBOX_NO_PROXY
49+
Comma-separated NO_PROXY list (hostnames, domain
50+
suffixes, IPs, CIDRs, optional :port qualifiers)
51+
dialed directly instead of through the proxy.
52+
OPENSHELL_SANDBOX_PROXY_AUTH_FILE
53+
Path to a file with proxy credentials as
54+
user:pass. Requires the acknowledgement below —
55+
the gateway refuses to start with one but not
56+
the other.
57+
OPENSHELL_SANDBOX_PROXY_AUTH_ALLOW_INSECURE
58+
Set to true to acknowledge that the credential
59+
is sent as cleartext Basic auth over the
60+
plain-TCP connection to the http:// proxy.
61+
OPENSHELL_SANDBOX_PROXY_CONNECT_BY_HOSTNAME
62+
Set to true to send the destination hostname in
63+
CONNECT instead of a validated IP. Last resort
64+
for hostname-filtering proxy ACLs.
65+
4466
Docker and VM runs delegate to gateway:docker and gateway:vm setup scripts.
4567
EOF
4668
}

0 commit comments

Comments
 (0)