You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
WSL Codex sandbox hangs FastAPI/Starlette TestClient and blocks Vite localhost bind #28517
CLIIssues related to the Codex CLIbugSomething isn't workingsandboxIssues related to permissions or sandboxingwindows-osIssues related to Codex on Windows systems
Actual in Codex sandbox:
Prints "before", then hangs in Starlette/AnyIO TestClient.
Observed stack:
starlette.testclient.py handle_request / enter
anyio.from_thread portal wait
asyncio selector loop waiting
Control:
Running the same repo gate outside Codex sandbox passed:
make test -> backend 1441 passed / 216 skipped; frontend vitest 305 passed
npx playwright test --project=chromium admin-weekly-report-review -> 6
passed when allowed to bind localhost
Impact:
Codex can produce false audit/test failures in WSL because normal local test
gates hang only inside the sandbox. This has happened more than once.
I reduced this to a plain socket repro in the Linux sandbox. The failure is not FastAPI/Vite-specific; restricted network currently blocks creating an IPv4 socket at all, so frameworks that start an in-process loopback listener fail before they can even bind().
The restricted case fails at Python's socket.socket() constructor, not at bind():
_socket.socket.__init__(self, family, type, proto, fileno)
PermissionError: [Errno 1] Operation not permitted
Relevant code path:
codex-rs/linux-sandbox/src/linux_run_main.rs maps NetworkSandboxPolicy::Restricted to BwrapNetworkMode::Isolated unless managed proxy mode is enabled.
BwrapNetworkMode::Isolated adds --unshare-net in codex-rs/linux-sandbox/src/bwrap.rs.
The inner stage applies the permission profile to the already-bwrapped process, and the network seccomp restrictions deny socket creation.
Existing sandbox tests cover blocked outbound attempts like curl, wget, ping, nc 127.0.0.1:80, and /dev/tcp, but I do not see coverage for the allowed-local-listener case (socket() -> bind(127.0.0.1, 0) -> listen()).
That matches both symptoms in the issue:
Starlette/FastAPI TestClient can hang or fail because the test harness may create sockets internally even though it is not trying to reach the public network.
Vite/Playwright cannot start a localhost server because the sandbox rejects socket creation under restricted network.
A good fix direction would be to distinguish outbound network access from local loopback listeners. At minimum, add a regression test for creating/listening on 127.0.0.1:0 under restricted network, then decide whether the seccomp policy should allow AF_INET/AF_INET6 socket creation with later constraints, or whether a dedicated "loopback allowed, external denied" network mode is needed. The current policy is stricter than "network disabled" in the way developer/test tooling usually expects, because it also denies local-only server setup.
CLIIssues related to the Codex CLIbugSomething isn't workingsandboxIssues related to permissions or sandboxingwindows-osIssues related to Codex on Windows systems
Activity
MakenRosa commentedon Jun 17, 2026
I reduced this to a plain socket repro in the Linux sandbox. The failure is not FastAPI/Vite-specific; restricted network currently blocks creating an IPv4 socket at all, so frameworks that start an in-process loopback listener fail before they can even
bind().Repro in WSL after building
codex-linux-sandbox:Then compare outside sandbox, restricted network, and enabled network:
The restricted case fails at Python's
socket.socket()constructor, not atbind():Relevant code path:
codex-rs/linux-sandbox/src/linux_run_main.rsmapsNetworkSandboxPolicy::RestrictedtoBwrapNetworkMode::Isolatedunless managed proxy mode is enabled.BwrapNetworkMode::Isolatedadds--unshare-netincodex-rs/linux-sandbox/src/bwrap.rs.curl,wget,ping,nc 127.0.0.1:80, and/dev/tcp, but I do not see coverage for the allowed-local-listener case (socket() -> bind(127.0.0.1, 0) -> listen()).That matches both symptoms in the issue:
TestClientcan hang or fail because the test harness may create sockets internally even though it is not trying to reach the public network.A good fix direction would be to distinguish outbound network access from local loopback listeners. At minimum, add a regression test for creating/listening on
127.0.0.1:0under restricted network, then decide whether the seccomp policy should allow AF_INET/AF_INET6 socket creation with later constraints, or whether a dedicated "loopback allowed, external denied" network mode is needed. The current policy is stricter than "network disabled" in the way developer/test tooling usually expects, because it also denies local-only server setup.