Skip to content

Wire MITM hooks into runtime enforcement#20659

Open
evawong-oai wants to merge 2 commits into
codex/mitm-proxy-landingfrom
codex/mitm-runtime-enforcement
Open

Wire MITM hooks into runtime enforcement#20659
evawong-oai wants to merge 2 commits into
codex/mitm-proxy-landingfrom
codex/mitm-runtime-enforcement

Conversation

@evawong-oai
Copy link
Copy Markdown
Contributor

@evawong-oai evawong-oai commented May 1, 2026

Stack

  1. Parent PR: Add MITM hook config model #18868 adds MITM hook config and model only.
  2. This PR wires runtime enforcement.
  3. User facing config follow up: Use named MITM permissions config #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 Add MITM hook config model #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.

@evawong-oai evawong-oai force-pushed the codex/mitm-proxy-landing branch from fe69321 to b6be46a Compare May 6, 2026 01:09
@evawong-oai evawong-oai force-pushed the codex/mitm-runtime-enforcement branch from ec08b07 to 6edf86c Compare May 6, 2026 01:10
@evawong-oai evawong-oai force-pushed the codex/mitm-proxy-landing branch from b6be46a to c6c6db9 Compare May 6, 2026 16:09
@evawong-oai evawong-oai force-pushed the codex/mitm-runtime-enforcement branch from 6edf86c to 03765b9 Compare May 6, 2026 16:10
@evawong-oai evawong-oai force-pushed the codex/mitm-proxy-landing branch from c6c6db9 to 12243bc Compare May 6, 2026 17:45
@evawong-oai evawong-oai force-pushed the codex/mitm-runtime-enforcement branch from 03765b9 to 1c1ed25 Compare May 6, 2026 17:46
@evawong-oai evawong-oai force-pushed the codex/mitm-proxy-landing branch from 12243bc to bba0ec9 Compare May 6, 2026 17:47
@evawong-oai evawong-oai force-pushed the codex/mitm-runtime-enforcement branch 2 times, most recently from a5db4d3 to c4188b4 Compare May 6, 2026 18:00
@evawong-oai evawong-oai force-pushed the codex/mitm-proxy-landing branch from 8447355 to 8870e65 Compare May 6, 2026 18:45
@evawong-oai evawong-oai force-pushed the codex/mitm-runtime-enforcement branch from c4188b4 to 912d8e7 Compare May 6, 2026 18:45
@evawong-oai evawong-oai force-pushed the codex/mitm-proxy-landing branch from 8870e65 to fdfdc17 Compare May 6, 2026 19:38
@evawong-oai evawong-oai force-pushed the codex/mitm-runtime-enforcement branch from 912d8e7 to 16c939f Compare May 6, 2026 19:39
@evawong-oai evawong-oai force-pushed the codex/mitm-proxy-landing branch from fdfdc17 to 0ee61a2 Compare May 6, 2026 19:42
@evawong-oai evawong-oai force-pushed the codex/mitm-runtime-enforcement branch from 16c939f to 0bf18c0 Compare May 6, 2026 19:43
@evawong-oai evawong-oai force-pushed the codex/mitm-proxy-landing branch from 0ee61a2 to b11141b Compare May 6, 2026 20:36
@evawong-oai evawong-oai force-pushed the codex/mitm-runtime-enforcement branch from 0bf18c0 to 011f536 Compare May 6, 2026 20:37
@evawong-oai evawong-oai force-pushed the codex/mitm-proxy-landing branch from b11141b to 5c1bf13 Compare May 6, 2026 21:18
@evawong-oai evawong-oai force-pushed the codex/mitm-runtime-enforcement branch 2 times, most recently from c444377 to e342e00 Compare May 7, 2026 19:30
@evawong-oai evawong-oai force-pushed the codex/mitm-proxy-landing branch from a425e22 to 6f6a861 Compare May 7, 2026 19:32
@evawong-oai evawong-oai force-pushed the codex/mitm-runtime-enforcement branch from e342e00 to 599ba13 Compare May 7, 2026 19:32
Copy link
Copy Markdown

@winston-openai winston-openai left a comment

Choose a reason for hiding this comment

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

LGTM for the HTTP CONNECT path. One follow up I think we need to think through: SOCKS5 is also enabled by default and currently still opens a raw tunnel in full mode but the hooks don't apply. We either need to apply equivalent hook enforcement to SOCKS5 TCP HTTPS flows or fail closed for hooked hosts on SOCKS5 so folks can't bypass the hook policy. There's also the open question about what to do about the SOCKS5 UDP setup; my thought is we detect if it's HTTP3/QUIC and if so, mitm it, apply hooks and forward the requests, and otherwise proxy it (or fail closed - maybe there's another config option).

We can discuss this though - these things should be separate follow up PRs. I just want to call them out so that hooks are being applied properly

@evawong-oai evawong-oai force-pushed the codex/mitm-proxy-landing branch from 6f6a861 to f7779d8 Compare May 14, 2026 13:00
@evawong-oai evawong-oai force-pushed the codex/mitm-runtime-enforcement branch from 599ba13 to 5c28c96 Compare May 14, 2026 13:01
@evawong-oai
Copy link
Copy Markdown
Contributor Author

Thanks. I agree.

I left SOCKS5 as follow up work. This PR only covers the HTTP CONNECT path. The next task should decide whether SOCKS5 uses the same hook path or blocks hooked hosts until that path is ready.

It should also cover UDP and QUIC before rollout.

@winston-openai winston-openai force-pushed the codex/mitm-proxy-landing branch from f7779d8 to af01135 Compare May 15, 2026 12:33
@winston-openai winston-openai force-pushed the codex/mitm-runtime-enforcement branch from 5c28c96 to 2c9ccbe Compare May 15, 2026 12:33
@winston-openai winston-openai marked this pull request as ready for review May 16, 2026 08:47
Copy link
Copy Markdown
Contributor

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

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: 2c9ccbe030

ℹ️ 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/mitm.rs Outdated
Comment thread codex-rs/network-proxy/src/http_proxy.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants