From 7fcc48c6284566045efbbb2cff5b844348e74d65 Mon Sep 17 00:00:00 2001 From: Winston Howes Date: Sun, 14 Jun 2026 12:09:25 -0700 Subject: [PATCH] Keep startup CA overrides out of baseline bundle --- codex-rs/network-proxy/src/certs.rs | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/codex-rs/network-proxy/src/certs.rs b/codex-rs/network-proxy/src/certs.rs index 3ef9cb8d96..356ef8c950 100644 --- a/codex-rs/network-proxy/src/certs.rs +++ b/codex-rs/network-proxy/src/certs.rs @@ -23,7 +23,6 @@ use rama_tls_rustls::server::TlsAcceptorData; use sha2::Digest as _; use sha2::Sha256; use std::collections::HashMap; -use std::collections::HashSet; use std::ffi::OsStr; #[cfg(windows)] use std::ffi::OsString; @@ -177,7 +176,10 @@ fn managed_ca_trust_bundle_for_cert_path( .map(|value| (key, value.clone())) }) .collect(); - let trust_bundle = build_managed_ca_trust_bundle(cert_path, &startup_env_values)?; + // Startup overrides are retained only as provenance for policy-gated + // per-child materialization. The baseline must never copy their contents + // before the child's filesystem policy is available. + let trust_bundle = build_managed_ca_trust_bundle(cert_path)?; let path = persist_managed_ca_trust_bundle(cert_path, &trust_bundle)?; Ok(ManagedMitmCaTrustBundle { @@ -187,10 +189,7 @@ fn managed_ca_trust_bundle_for_cert_path( }) } -fn build_managed_ca_trust_bundle( - managed_ca_cert_path: &Path, - startup_env_values: &HashMap<&'static str, String>, -) -> Result { +fn build_managed_ca_trust_bundle(managed_ca_cert_path: &Path) -> Result { let mut trust_bundle = String::new(); let rustls_native_certs::CertificateResult { certs, errors, .. } = crate::native_certs::load_platform_native_certs(); @@ -203,16 +202,6 @@ fn build_managed_ca_trust_bundle( for cert in certs { push_certificate_pem(&mut trust_bundle, cert.as_ref()); } - let mut appended_startup_paths = HashSet::new(); - for path in CUSTOM_CA_ENV_KEYS - .into_iter() - .filter_map(|key| startup_env_values.get(key)) - .map(Path::new) - { - if path != managed_ca_cert_path && appended_startup_paths.insert(path) { - append_pem_file(&mut trust_bundle, path)?; - } - } append_pem_file(&mut trust_bundle, managed_ca_cert_path)?; Ok(trust_bundle) } @@ -903,7 +892,7 @@ mod tests { } #[test] - fn managed_ca_trust_bundle_appends_startup_ca_override_to_baseline() { + fn managed_ca_trust_bundle_keeps_startup_ca_override_out_of_baseline() { let dir = tempdir().unwrap(); let managed_ca_cert_path = dir.path().join("ca.pem"); let startup_ca_bundle_path = dir.path().join("startup-ca.pem"); @@ -918,7 +907,7 @@ mod tests { managed_ca_trust_bundle_for_cert_path(&managed_ca_cert_path, &env).unwrap(); let baseline_bundle = fs::read_to_string(trust_bundle.path).unwrap(); - assert!(baseline_bundle.contains("startup ca")); + assert!(!baseline_bundle.contains("startup ca")); assert!(baseline_bundle.contains("managed ca")); }