fix(network-proxy): keep MITM CA private signer in memory only#324
Merged
Conversation
Re-express upstream openai/codex #29013 (c5a9a95ab6) onto our fork. Generate one managed MITM CA per proxy process and retain the private signer only in process memory. Persist only content-addressed public CA certificates (ca-<sha256>.pem) under $CODEWITH_HOME/proxy, hold a cross-process shared lease per active cert, and prune artifacts left by inactive proxy processes. Validate generated trust-bundle paths by their content hash. Per-host leaf certs are signed from the in-memory signer, shared process-wide via Arc<ManagedMitmCa>. No CA private key is written to disk, so no deny-read sandbox rule is needed (our fork already exposes only the content-addressed trust bundle as a readable sandbox root). Adapted to our pre-#29014 tree: keeps the single-arg trust-bundle builder and native-cert loading and does not pull the startup custom-CA follow-up (#29014).
andrei-hasna
force-pushed
the
upstream-sync/cluster-20-proxy-ca-key-memory
branch
from
July 20, 2026 16:29
290ad17 to
935852b
Compare
Contributor
Author
|
Not merged (automated merge pass): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Re-expresses upstream openai/codex #29013 (
c5a9a95ab6, "Keep managed MITM CA private keys in proxy memory") onto our fork.The managed MITM CA private signer is now generated per proxy process and kept only in process memory — it is never written to
$CODEWITH_HOME/proxy. Only the public CA material is persisted, content-addressed:KeyPairlives only insideManagedMitmCa(shared process-wide viaArc<ManagedMitmCa>behind aLazyLock<Mutex<..>>cache keyed by proxy dir).ca-<sha256>.pem) and trust bundles (ca-bundle-<sha256>.pem) are written under$CODEWITH_HOME/proxy.is_generated_trust_bundle_path/is_generated_managed_ca_artifact_path).mitm.rsnow holdsArc<ManagedMitmCa>).Because no CA private key is written to disk, no deny-read sandbox rule is required. Our fork already exposes only the content-addressed trust bundle as a readable sandbox root (
with_managed_mitm_ca_readable_root), so there was no deny-read-of-key rule to remove — the change keeps ordinary sandbox setup independent of CA-key state.Upstream refs
c5a9a95ab6— primary change ported here.527ccb4a5d— the startup custom-CA follow-up; intentionally not pulled (out of scope), so the trust-bundle builder keeps our single-arg / native-cert-loading form (pre-#29014 tree).How it was re-expressed onto our fork
Our
network-proxy/src/certs.rssits at the pre-#29014 base, so the port keeps our existingmanaged_ca_trust_bundle_for_cert_path/build_managed_ca_trust_bundleandis_managed_mitm_ca_trust_bundle_pathshapes and only layers in #29013:load_or_create_ca()(read cert+key from disk) →ManagedMitmCa::create()+persist_managed_ca_certificate()(public cert only).managed_ca_paths()→managed_ca_dir(); removedca.pem/ca.keyfixed-path constants.generate_ca()now returns theKeyPair(kept in memory) instead of serialized key PEM.validate_existing_ca_key_file(no on-disk key to validate).is_current_generated_trust_bundle_path(its only remaining caller lives in the un-ported #29014); the public path check now uses the content-hashis_generated_trust_bundle_path.Tests (ported from #29013)
managed_ca_private_key_is_not_persisted— only the public cert + lock files land on disk.managed_ca_artifact_pruning_preserves_only_active_certificates— leased certs survive; unleased certs/bundles and their leases are pruned; unrelated files untouched.generated_trust_bundle_path_requires_matching_content_hash— tampered bundles are rejected.Verification
cargo check -p codex-network-proxy: PASScargo nextest -p codex-network-proxy(test-fast): 164 passed / 0 failed (incl. the 3 new tests)cargo clippy -p codex-network-proxy --tests -- -D warnings: clean (exit 0)just fmt-check: cleanAdapt cluster — opened for human review (overlaps our fork customizations); not auto-merged.