Skip to content

Support project-scoped loopback listener allowlists without enabling allow_local_binding #35768

Open

Description

@TyceHerrman

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 = false default 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

  1. added
    enhancement
    CLI
    app
    sandbox
    config
    on Jul 28, 2026
  2. borek504 commented on Sep 9, 2026

    @borek504

    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:

    • ChatGPT Desktop 26.825.51511, build 7377.
    • Bundled codex-cli 0.151.0-alpha.7.2.
    • macOS; interpreter: /Library/Developer/CommandLineTools/usr/bin/python3.
    • Named profile cig03_loopback, network enabled, managed proxy active, and the sole allowed domain is the literal 127.0.0.1.

    The command process reported:

    CODEX_PERMISSION_PROFILE=cig03_loopback
    CODEX_SANDBOX=seatbelt
    CODEX_NETWORK_PROXY_ACTIVE=1
    CODEX_NETWORK_ALLOW_LOCAL_BINDING=0
    

    After validating the diagnostic script's syntax, one standard-library Python process (PID 15173) created an AF_INET/SOCK_STREAM socket and made exactly one bind(("127.0.0.1", 0)) call:

    bind started: 2026-09-09T20:04:07.593517Z
    PermissionError: [Errno 1] Operation not permitted
    error reported: 2026-09-09T20:04:07.593624Z
    

    macOS Console, opened manually outside the command sandbox, captured this matching kernel message:

    2026-09-09 22:04:07.593604+0200
    Sandbox: Python(15173) deny(1) network-bind local:*:0
    

    The PID matches and the kernel timestamp falls within the call interval. The requested address was explicitly 127.0.0.1; the kernel's local:*:0 rendering should not be interpreted as proof that the script requested a wildcard address. The socket was closed in finally (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_binding is 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.1 listener 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.

  3. borek504 commented on Sep 15, 2026

    @borek504

    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_STREAM socket, exactly one bind(("127.0.0.1", 0)), no listen(), no connect(), 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.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLIappconfigenhancementsandbox

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions