Commit Graph

108 Commits

Author SHA1 Message Date
Winston Howes
0477e8b603 Merge branch 'dev/winston/mitm-command-ca-bundles' into dev/winston/credentialed-routes-e2e 2026-06-04 22:48:00 -07:00
Winston Howes
7a3610fc2f Merge branch 'dev/winston/mitm-ca-bundle-helpers' into dev/winston/mitm-child-ca-materialization 2026-06-04 03:47:28 -07:00
Winston Howes
48afc5d89d Merge branch 'dev/winston/mitm-startup-ca-env' into dev/winston/mitm-ca-bundle-helpers
# Conflicts:
#	codex-rs/network-proxy/src/certs.rs
2026-06-04 03:47:13 -07:00
Winston Howes
caebf7980f Merge branch 'dev/winston/mitm-platform-ca-roots' into dev/winston/mitm-startup-ca-env
# Conflicts:
#	codex-rs/network-proxy/src/certs.rs
2026-06-04 03:46:27 -07:00
Winston Howes
750e73e047 Preserve startup CA overrides in MITM bundle 2026-06-04 03:44:47 -07:00
Winston Howes
338aa0ab38 Merge branch 'dev/winston/mitm-ca-bundle-helpers' into dev/winston/mitm-child-ca-materialization 2026-06-03 22:30:13 -07:00
Winston Howes
0d6f4047c5 Fix Windows CA handle metadata init 2026-06-03 22:29:55 -07:00
Winston Howes
f4f971624e Trim child CA tests 2026-06-03 22:20:01 -07:00
Winston Howes
f39f0f4300 Materialize child MITM CA bundles 2026-06-03 22:19:17 -07:00
Winston Howes
130450a9fa Track startup MITM CA env 2026-06-03 22:15:30 -07:00
Winston Howes
fb6ce7fef9 Bound child CA directory scan 2026-06-03 19:58:12 -07:00
Winston Howes
14d16d2dd4 Fix Windows MITM CA bundle identity check 2026-06-03 19:53:12 -07:00
Winston Howes
3eea6386bb Merge branch 'dev/winston/mitm-command-ca-bundles' into dev/winston/credentialed-routes-e2e
# Conflicts:
#	codex-rs/backend-client/src/client.rs
#	codex-rs/backend-client/src/lib.rs
2026-06-03 19:39:58 -07:00
Winston Howes
c9014ad029 Address child CA review feedback 2026-06-03 19:26:44 -07:00
Winston Howes
b468d85335 Merge dev/winston/mitm-platform-ca-roots into dev/winston/mitm-child-ca-materialization 2026-06-03 18:56:27 -07:00
Winston Howes
5891f041b2 Preserve always-trusted macOS roots 2026-06-03 18:55:52 -07:00
Winston Howes
9f9257e9cd Restore managed MITM CA bundle accessor 2026-06-03 18:55:52 -07:00
Winston Howes
de3ce08628 Materialize child MITM CA bundles 2026-06-03 18:29:46 -07:00
Winston Howes
4d37e04e81 Load platform MITM CA roots 2026-06-03 18:25:38 -07:00
Winston Howes
4ba48cfa67 Merge branch 'dev/winston/credentialed-routes-refresh' into dev/winston/socks5-tcp-mitm 2026-06-01 17:45:39 -07:00
Winston Howes
46b3c36f2e Merge branch 'dev/winston/credentialed-routes-discovery' into dev/winston/credentialed-routes-mitm
# Conflicts:
#	codex-rs/backend-client/src/client.rs
2026-06-01 17:43:03 -07:00
Winston Howes
bca18cba40 Wire managed MITM CA trust into child env (#22668)
## Stack
1. Parent PR: #18240 uses named MITM permissions config.
2. This PR wires managed MITM CA trust into spawned child processes.

## Why
When Codex terminates HTTPS for limited mode or MITM hooks, child HTTPS
clients need to trust Codex's managed MITM CA. Exporting proxy URLs
alone is not enough, but blindly replacing user CA settings would be
wrong: it can break custom enterprise/test roots, leak unreadable CA
files into generated bundles, or make the child env disagree with its
sandbox policy.

## Summary
1. Build immutable managed CA bundles under `$CODEX_HOME/proxy` that
include native roots, the managed MITM CA, and only inherited or
command-scoped CA bundles the child is allowed to read.
2. Export curated CA env vars alongside managed proxy env vars while
preserving user CA override semantics, including nested Codex
`SSL_CERT_FILE` precedence.
3. Thread generated CA bundle paths into child sandbox readable roots,
including debug sandbox execution, so the exported env vars work inside
sandboxed commands.
4. Remove only Codex-generated MITM CA bundle env when a child
intentionally drops managed proxying for escalation or no-proxy retry.
5. Document the managed CA bundle behavior and cover env injection,
per-child bundle generation, sandbox readable roots, and no-proxy
cleanup in tests.

## Validation
1. Ran `just test -p codex-network-proxy`.
2. Ran `just test -p codex-protocol`.
3. Ran `just fix -p codex-network-proxy -p codex-protocol`.
4. Tried focused `codex-core` validation, but the crate currently fails
to compile in `core/tests/suite/guardian_review.rs` because an existing
`Op::UserInput` initializer is missing `additional_context`.

---------

Co-authored-by: Eva Wong <evawong@openai.com>
2026-06-01 23:23:59 +00:00
viyatb-oai
bf72be5927 fix(config): use deny for Unix socket permissions (#24970)
## Why

Unix socket permissions still accepted and displayed `"none"` while file
permissions use the clearer `"deny"` spelling. This keeps network Unix
socket policy vocabulary consistent with filesystem policy vocabulary.

## What changed

- Replace the Unix socket permission variant and serialized spelling
from `none` to `deny` across config, feature configuration, and network
proxy types.
- Update app-server v2 serialization, TUI debug output, focused tests,
and generated schemas to expose `"deny"`.
- Add coverage for denied Unix socket entries in managed requirements
and profile overlay behavior.

## Security

This is a vocabulary change for explicit Unix socket rejection, not a
network access expansion. Denied entries continue to be omitted from the
effective allowlist.

## Validation

- `just fmt`
- `just write-config-schema`
- `just write-app-server-schema`
- `just test -p codex-config -p codex-core -p codex-app-server-protocol
-p codex-tui -E
'test(network_requirements_are_preserved_as_constraints_with_source) |
test(network_permission_containers_project_allowed_and_denied_entries) |
test(network_toml_overlays_unix_socket_permissions_by_path) |
test(permissions_profiles_resolve_extends_parent_first_with_child_overrides)
| test(network_requirements_serializes_canonical_and_legacy_fields) |
test(debug_config_output_formats_unix_socket_permissions)'`\n- Automatic
`bench-smoke` follow-up from `just test`\n- `cargo clippy -p
codex-config -p codex-core -p codex-features -p codex-network-proxy -p
codex-app-server-protocol -p codex-app-server -p codex-tui --all-targets
-- -D warnings`
2026-05-28 23:53:26 +00:00
Winston Howes
954d300c16 Merge commit '4ef969503a01ba8f824453a9727cdaa8f89c5044' into HEAD 2026-05-26 16:32:14 -07:00
Winston Howes
3b2cecaaaf Merge commit 'cdbbc6f300007a64d075966e69638f35e269b0c8' into HEAD 2026-05-26 16:31:36 -07:00
Winston Howes
e29a8a4de6 Preserve Linux CA bundles for MITM trust 2026-05-26 16:30:59 -07:00
Winston Howes
db382ca2a1 Merge commit 'a96f9ec06beecb1da56eaa4f68eb7d76f7284caf' into HEAD 2026-05-26 15:47:36 -07:00
Winston Howes
a3b1fda437 Merge commit 'd257d2d6891e49d49270098502370dacb9819f75' into HEAD 2026-05-26 15:45:44 -07:00
Winston Howes
595d035fbc Trust managed MITM CA in Linux sandboxes 2026-05-26 15:44:40 -07:00
Winston Howes
55ae82e0d3 Merge commit '260e31dde51294cc93cfdae156d992d2d1f62417' into HEAD 2026-05-26 13:52:08 -07:00
Winston Howes
9cdaddbf6c Merge commit 'c8024267ba' into HEAD 2026-05-26 13:49:53 -07:00
Winston Howes
e910c8c788 Address MITM CA trust review feedback 2026-05-26 13:48:08 -07:00
Winston Howes
4fd3fd5f02 Merge commit 'b3186c6a2e3ec52ab195a29959135eac23c2c024' into HEAD 2026-05-26 13:21:20 -07:00
Winston Howes
298756de03 Merge commit '220b2627de1c12dab34568835a3eda93846f75fd' into HEAD 2026-05-26 13:19:28 -07:00
Winston Howes
672045c2f0 Clean up MITM CA env wiring 2026-05-26 13:18:18 -07:00
Winston Howes
e31b3b5201 Merge dev/winston/credentialed-routes-refresh into dev/winston/socks5-tcp-mitm 2026-05-26 11:19:13 -07:00
Winston Howes
5d7599f9fc Merge dev/winston/credentialed-routes-discovery into dev/winston/credentialed-routes-mitm 2026-05-26 11:14:43 -07:00
Winston Howes
4dc6530cfa Merge main into dev/winston/mitm-ca-trust 2026-05-26 11:12:18 -07:00
rreichel3-oai
b14f11d3d2 [codex] Enable Node env proxy for managed network proxy (#23905)
## Summary
- set `NODE_USE_ENV_PROXY=1` when Codex applies managed network proxy
environment overrides
- keep the Node opt-in in the proxy environment key set used by
shell/runtime env handling
- cover the new env var in the focused network proxy env test

## Why
Codex already sets HTTP proxy environment variables for child processes
when the managed network proxy is active. Node's built-in network
behavior needs the `NODE_USE_ENV_PROXY` opt-in to honor those env vars,
so Node-based skill scripts can otherwise skip the managed proxy path
and fail under restricted network access.

## Validation
- `just fmt` in `codex-rs`
- `cargo test -p codex-network-proxy` in `codex-rs`
2026-05-22 01:27:25 -04:00
evawong-oai
3cae84009a Use named MITM permissions config (#18240)
## Stack
1. Parent PR: #18868 adds MITM hook config and model only.
2. Parent PR: #20659 wires hook enforcement into the proxy request path.
3. This PR changes the user facing PermissionProfile TOML shape.

## Why
1. The broader goal is to make MITM clamping usable from the same
permission profile that already controls network behavior.
2. This PR is the config UX layer for the stack. It moves MITM policy
into `[permissions.<profile>.network.mitm]` instead of exposing the flat
runtime shape to users.
3. The named hook and action tables belong here because users need
reusable policy blocks that are easy to review, while the proxy runtime
only needs a flat hook list.
4. This PR validates action refs during config parsing so mistakes in
the user facing policy fail before a proxy session starts.
5. Keeping the lowering here lets the proxy keep its simpler runtime
model and lets PermissionProfile remain the single source of network
permission policy.

## Summary
1. Keep MITM policy inside `[permissions.<profile>.network.mitm]` so the
selected PermissionProfile owns network proxy policy.
2. Use named MITM hooks under
`[permissions.<profile>.network.mitm.hooks.<name>]`.
3. Put host, methods, path prefixes, query, headers, body, and action
refs on the hook table.
4. Define reusable action blocks under
`[permissions.<profile>.network.mitm.actions.<name>]`.
5. Represent action blocks with `NetworkMitmActionToml`, then lower them
into the proxy runtime action config.
6. Reject unknown refs, empty refs, and empty action blocks during
config parsing.
7. Keep the runtime hook model unchanged by lowering config into the
existing proxy hook list.
8. Preserve the #20659 activation fix for nested MITM policy.

## Example
```toml
[permissions.workspace.network.mitm]
enabled = true

[permissions.workspace.network.mitm.hooks.github_write]
host = "api.github.com"
methods = ["POST", "PUT"]
path_prefixes = ["/repos/openai/"]
action = ["strip_auth"]

[permissions.workspace.network.mitm.actions.strip_auth]
strip_request_headers = ["authorization"]
```

## Validation
1. Regenerated the config schema.
2. Ran the core MITM config parsing and validation tests.
3. Ran the core PermissionProfile MITM proxy activation tests.
4. Ran the core config schema fixture test.
5. Ran the network proxy MITM policy tests.
6. Ran the scoped Clippy fixer for the network proxy crate.
7. Ran the scoped Clippy fixer for the core crate.

---------

Co-authored-by: Winston Howes <winston@openai.com>
2026-05-20 17:10:37 -07:00
evawong-oai
f6970214d2 Wire MITM hooks into runtime enforcement (#20659)
## Stack
1. Parent PR: #18868 adds MITM hook config and model only.
2. This PR wires runtime enforcement.
3. User facing config follow up: #18240 moves MITM policy into the
PermissionProfile network tree.

## Why
1. After the hook model exists, the proxy needs a separate behavior
change that can be tested at the request path.
2. This PR makes hooked HTTPS hosts require MITM, evaluates inner
requests after CONNECT, mutates headers for matching hooks, and blocks
hooked hosts when no hook matches.
3. It also fixes the activation path so a permission profile with MITM
hook policy starts the managed proxy.
4. Keeping this separate from #18868 lets reviewers focus on runtime
effects, telemetry, and request mutation.

## Summary
1. Store compiled MITM hooks in network proxy state.
2. Require MITM for hooked hosts even when network mode is full.
3. Evaluate inner HTTPS requests against host specific hooks.
4. Apply hook actions by replacing request headers before forwarding.
5. Block hooked hosts when no hook matches and record block telemetry.
6. Treat profile MITM hook policy as managed proxy policy so the proxy
starts when needed.
7. Keep the duplicate authorization header replacement and query
preserving request rebuild in this runtime PR.
8. Add runtime tests and README guidance for hook enforcement.

## Validation
1. Ran the network proxy MITM policy tests.
2. Ran the hooked host CONNECT test.
3. Ran the authorization header replacement test.
4. Ran the core permission profile proxy activation test for MITM hooks.
5. Ran the scoped Clippy fixer for the network proxy crate.
6. Ran the scoped Clippy fixer for the core crate.
2026-05-20 14:08:14 -07:00
evawong-oai
3d94e24a3d Add MITM hook config model (#18868)
## Stack
1. This PR adds MITM hook config and model only.
2. Runtime follow up: #20659 wires hook enforcement into the proxy
request path.
3. User facing config follow up: #18240 moves MITM policy into the
PermissionProfile network tree.

## Why
1. Viyat asked for the original parent PR to be split so reviewers can
inspect the policy model before request behavior changes.
2. This PR gives the proxy a typed MITM hook model, validation, matcher
compilation, permissions TOML plumbing, schema support, and config
tests.
3. This PR deliberately does not change CONNECT or MITM request
handling.
4. Keeping runtime behavior out of this PR makes the review boundary
simple: does the policy model parse, validate, compile, and lower
correctly.

## Summary
1. Add the MITM hook config model and matcher compilation.
2. Validate hosts, methods, paths, query matchers, header matchers,
secret sources, and reserved body matching.
3. Add wildcard matcher support for path, query value, and header value
matching.
4. Add permissions TOML and schema support for flat runtime hook config.
5. Add config loader tests for MITM hook overlay behavior.

## Validation
1. Regenerated the config schema.
2. Ran the network proxy MITM hook unit tests.
3. Ran the core permission profile MITM hook parsing tests.
4. Ran the core config schema fixture test.
5. Ran the scoped Clippy fixer for the network proxy crate.
6. Ran the scoped Clippy fixer for the core crate.

## Notes
1. Runtime enforcement moved to #20659.
2. User facing PermissionProfile TOML shape remains in #18240.
2026-05-20 12:51:12 -07:00
Winston Howes
e552ffb176 Inject Codex auth into credential route proxy 2026-05-15 19:16:20 -07:00
Winston Howes
dba0f036dc Move credential route proxy metadata to headers 2026-05-15 19:16:02 -07:00
Winston Howes
28ce16562d Route credentialed traffic through MITM proxy 2026-05-15 19:15:47 -07:00
Winston Howes
74bc589e46 Add SOCKS5 TCP MITM coverage 2026-05-15 10:33:45 -07:00
Winston Howes
591b173259 Inject Codex auth into credential route proxy 2026-05-15 10:21:12 -07:00
Winston Howes
8bb4b38635 Move credential route proxy metadata to headers 2026-05-15 10:21:12 -07:00
Winston Howes
1e2356c6f4 Route credentialed traffic through MITM proxy 2026-05-15 10:21:12 -07:00
Winston Howes
9fa22ca31e Fix MITM CA trust build failures 2026-05-15 10:12:05 -07:00