Skip to content

[codex] Use IPv6 loopback for managed macOS HTTP proxy#24642

Open
viyatb-oai wants to merge 1 commit into
mainfrom
codex/proxyf-grpc-ipv6
Open

[codex] Use IPv6 loopback for managed macOS HTTP proxy#24642
viyatb-oai wants to merge 1 commit into
mainfrom
codex/proxyf-grpc-ipv6

Conversation

@viyatb-oai
Copy link
Copy Markdown
Collaborator

Why

Managed macOS network sessions inject an HTTP proxy endpoint for sandboxed child processes. The endpoint is currently bound to 127.0.0.1, but Python gRPC connects to an IPv4 proxy endpoint using an IPv4-mapped IPv6 socket (::ffff:127.0.0.1). Seatbelt does not recognize that socket representation as localhost, so it denies the proxy connection before any HTTP CONNECT request reaches ProxyF.

This presents as gRPC-based commands hanging or timing out even though ProxyF is active and ordinary HTTP clients can reach an allowed destination through the same proxy.

What changed

  • Bind Codex-managed macOS HTTP proxy listeners on native IPv6 loopback ([::1]) instead of IPv4 loopback.
  • Leave SOCKS listener behavior unchanged, preserving the existing macOS nc/SSH proxy-command path.
  • Extend proxy tests to assert the macOS managed HTTP listener and injected HTTPS_PROXY URL use IPv6 loopback.

This keeps the existing Seatbelt localhost:<proxy-port> boundary intact; it avoids adding a wildcard-port allowance that would permit direct egress to arbitrary remote hosts on the proxy port.

Validation

  • Reproduced the failure under Seatbelt: an IPv4 HTTP proxy endpoint works with requests, while gRPC fails with connect: Operation not permitted; a raw AF_INET6 connection to ::ffff:127.0.0.1 fails the same way.
  • Verified the safe route: placing a native IPv6 loopback listener in front of the same ProxyF endpoint makes the same sandboxed gRPC connection succeed.
  • Ran just fmt.
  • Ran just test -p codex-network-proxy (166 tests passed).
  • Ran just fix -p codex-network-proxy.

@viyatb-oai viyatb-oai requested a review from bolinfest May 27, 2026 05:32
@viyatb-oai viyatb-oai marked this pull request as ready for review May 27, 2026 05:32
@viyatb-oai viyatb-oai requested review from rreichel3-oai and removed request for bolinfest May 27, 2026 05:33
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: 9a69b0bf3b

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +240 to +241
StdTcpListener::bind(SocketAddr::from((std::net::Ipv6Addr::LOCALHOST, 0)))
.context("reserve HTTP proxy listener on IPv6 loopback")?
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.

P1 Badge Preserve IPv6 proxy address when unix sockets are enabled

On macOS with network.allow_unix_sockets or dangerously_allow_all_unix_sockets enabled, this reserves the managed HTTP listener on [::1]:0, but build() then re-applies config::clamp_bind_addrs, whose unix-socket safety path always rewrites loopback binds to 127.0.0.1:<port>. The actual reserved listener is still [::1]:<port>, while apply_to_env advertises http://127.0.0.1:<port>, so those sessions lose the native IPv6 proxy URL this change is meant to provide and gRPC can hit the same Seatbelt denial again. The new macOS assertion only covers the default config, so please keep the clamped managed HTTP address aligned with the IPv6 listener for the unix-socket-enabled case as well.

Useful? React with 👍 / 👎.

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.

1 participant