Skip to content

Materialize child MITM CA bundles#26315

Closed
winston-openai wants to merge 17 commits into
dev/winston/mitm-startup-ca-envfrom
dev/winston/mitm-ca-bundle-helpers
Closed

Materialize child MITM CA bundles#26315
winston-openai wants to merge 17 commits into
dev/winston/mitm-startup-ca-envfrom
dev/winston/mitm-ca-bundle-helpers

Conversation

@winston-openai

@winston-openai winston-openai commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Why

Sandboxed children need a bounded, immutable CA bundle assembled only from CA inputs they are allowed to read. The proxy must not expose its private key or shared working directory to achieve that.

What

  • add bounded, policy-checked readers for CA bundles and SSL_CERT_DIR
  • materialize selected child CA material with the managed MITM CA into immutable hashed bundles
  • preserve startup override behavior when per-command materialization is unavailable
  • keep bundle selection and materialization in codex-network-proxy

Stack

Validation

  • just test -p codex-network-proxy
  • just bazel-lock-check

@winston-openai

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7fcc48c628

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread codex-rs/network-proxy/src/certs.rs Outdated
Comment thread codex-rs/network-proxy/src/child_ca.rs Outdated
Comment thread codex-rs/network-proxy/src/child_ca.rs Outdated
@winston-openai winston-openai marked this pull request as ready for review June 19, 2026 00:17

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 23ba4ebbc3

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +163 to +167
Err(err) => {
warn!(
ca_bundle_path = %ca_dir_path.display(),
"failed to read child MITM CA directory; skipping it: {err}"
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve SSL_CERT_DIR on partial directory failures

When SSL_CERT_DIR contains multiple paths and any one directory materializes successfully, this branch logs and skips a later directory that fails policy/bounds/read checks, after which the function can still return Some(trust_bundle) and the caller removes SSL_CERT_DIR. In that scenario roots from the failed directory were still available to OpenSSL-style clients through the original env var, but they are dropped from every materialized bundle. Fresh evidence is this multi-path loop continues after an error and still returns Some if another directory contributed contents.

Useful? React with 👍 / 👎.

Comment on lines +39 to +40
)
.unwrap_or_default();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep failed CA-file overrides when folding SSL_CERT_DIR

When a custom CA env var points at a bundle this helper refuses to copy, for example because it exceeds the 4 MiB helper cap, while SSL_CERT_DIR is readable, read_child_ca_bundle_contents returns None but this default turns the failure into an empty bundle; the subsequent directory append then materializes a new path and overwrites the original env var. That drops the original file-backed roots even though leaving the variable alone would still let the child use them, so the failure case needs to stay distinct from the “value is already the managed bundle” no-op case.

Useful? React with 👍 / 👎.


[target.'cfg(windows)'.dependencies]
schannel = "0.1"
windows-sys = { version = "0.52", features = ["Win32_Foundation", "Win32_Storage_FileSystem"] }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Refresh the Bazel lockfile for new Rust deps

Adding this direct dependency, along with the new libc dependency above, changes Rust dependency metadata, but the commit only updates Cargo.lock and leaves MODULE.bazel.lock unchanged. The repo’s bazel-lock-check path is explicitly meant to catch that stale lockfile state, so this will need the just bazel-lock-update output committed with the dependency change.

AGENTS.md reference: AGENTS.md:L37-L40

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Closing as superseded by the focused #29013 and #29014 stack. The replacement isolates the persisted MITM private key and preserves file-backed custom CAs present at Codex startup, with zero codex-core changes. Per-command bundle materialization, generic sandbox carvebacks, and additional shell-snapshot plumbing are intentionally deferred because they are not required for this scoped completion work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant