Repository navigation
Description
What variant of Codex are you using?
Codex Desktop and CLI on macOS.
What feature would you like to see?
Add a first-class permission for narrowly allowing loopback listeners by address and port within a named permission profile.
For example, an illustrative configuration might be:
[permissions.workspace-tests.network]
enabled = true
allow_local_binding = false
[[permissions.workspace-tests.network.listeners]]
addresses = ["127.0.0.1", "::1"]
ports = "ephemeral"This would let tests create local HTTP servers using an OS-assigned port without broadly enabling local binding or access to other local/private-network services.
The setting should:
- Be usable from a trusted project's
.codex/config.toml. - Apply only when that project's permission profile is selected.
- Permit
bind()only on the declared loopback addresses and ports. - Not allow non-loopback listeners.
- Not grant additional outbound access to local or private-network targets.
- Be supported consistently by CLI and Desktop execution.
- Keep the global
allow_local_binding = falsedefault intact.
Motivation
Some unit tests create an in-process loopback server:
import socket
server = socket.socket()
server.bind(("127.0.0.1", 0))
print(server.getsockname())With allow_local_binding = false, this fails with:
PermissionError: [Errno 1] Operation not permitted
Setting allow_local_binding = true permits the tests, but is broader than necessary. The current macOS policy permits wildcard local binds when enabled and also uses the setting for a DNS carve-out (current Seatbelt implementation, PR #17370).
A typed listener allowlist would provide a portable, auditable least-privilege alternative.
Related issues
- #23973 concerns Desktop ignoring
allow_local_binding = true. - #33227 concerns outbound connections to explicitly allowlisted loopback targets.
- #24742 proposes raw user-provided macOS Seatbelt rules. That could offer a platform-specific escape hatch, but not a validated, cross-platform listener permission.
Activity
borek504 commentedon Sep 9, 2026
Additional reproduction with a matching macOS kernel denial, collected on 2026-09-09. This supports the need for the narrow listener permission requested here.
Environment:
codex-cli 0.151.0-alpha.7.2./Library/Developer/CommandLineTools/usr/bin/python3.cig03_loopback, network enabled, managed proxy active, and the sole allowed domain is the literal127.0.0.1.The command process reported:
After validating the diagnostic script's syntax, one standard-library Python process (PID 15173) created an
AF_INET/SOCK_STREAMsocket and made exactly onebind(("127.0.0.1", 0))call:macOS Console, opened manually outside the command sandbox, captured this matching kernel message:
The PID matches and the kernel timestamp falls within the call interval. The requested address was explicitly
127.0.0.1; the kernel'slocal:*:0rendering should not be interpreted as proof that the script requested a wildcard address. The socket was closed infinally(fileno()=-1). No project modules were imported, and no listen/connect, permission escalation, or configuration change occurred in this probe.The public source tagged rust-v0.151.0-alpha.7.2 conditionally adds the IP bind permission when
allow_local_bindingis true, together with broader loopback permissions and a conditional DNS allowance. This is consistent with the observed refusal, but the log alone does not identify which Desktop policy layer supplied the denial.Is there a supported way, or a tracked implementation/PR, to permit only an ephemeral
127.0.0.1listener and the necessary loopback client traffic, while retaining filesystem isolation and denying public/LAN traffic and unrelated local services? If this requires the new capability proposed in this issue, clarification of that limitation and the intended implementation path would be very helpful.borek504 commentedon Sep 15, 2026
I published a sanitized standalone reproducer/evidence package for the 2026-09-09 observation described above:
https://github.com/borek504/codex-macos-loopback-repro
The repository intentionally keeps the probe minimal: one Python
AF_INET/SOCK_STREAMsocket, exactly onebind(("127.0.0.1", 0)), nolisten(), noconnect(), no traffic, no configuration change, and no permission escalation. It also separates the observed evidence from interpretation and documents what the result does not prove.I removed private project details, local user/host paths, support-case identifiers, secrets, and unrelated logs so maintainers can inspect or rerun the case without depending on my private environment.
If there is a supported least-privilege path for this exact case, or a commit/PR that changes the relevant behavior, I can use this repo to record a version-to-version comparison without broadening sandbox/network permissions.