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
Restricted Linux sandbox breaks connected Unix socket sends and asyncio wakeups #33793
The restricted Linux network seccomp filter unconditionally denies sendto(2). On Linux, send(2) is implemented as sendto(..., dest_addr = NULL), so this also breaks writes to already-connected Unix-domain sockets.
One visible consequence is that Python asyncio cross-thread wakeups stop working inside the default Codex workspace sandbox. loop.call_soon_threadsafe() writes to asyncio's AF_UNIX wakeup socket; the write receives EPERM, asyncio suppresses that OSError, and the event loop remains asleep.
Reproduction
On current main (315195492c), build Codex and run:
This also causes Daft's native runner to hang on a simple collect() operation.
Isolation
The same program succeeds outside the Codex sandbox.
It succeeds with the same bubblewrap filesystem isolation and a full-network Codex profile.
It succeeds with plain bubblewrap plus --unshare-net.
It fails only when Codex's restricted network seccomp filter is installed.
Root cause and possible fix
In codex-rs/linux-sandbox/src/landlock.rs, restricted mode unconditionally denies SYS_sendto.
A narrowly scoped fix is to deny sendto only when its fifth argument (dest_addr) is non-null. This permits send() on an already-connected socket, including AF_UNIX socketpairs used for local IPC, while continuing to deny sends to explicit destinations such as unconnected Unix datagram socket paths.
I have a tested patch with regression coverage for both sides of this boundary:
connected AF_UNIX socket send() succeeds;
sendto() with an explicit destination still returns EPERM.
The codex-linux-sandbox test suite passes (120/120), and both the minimal asyncio reproducer and the original Daft collect() scenario pass with the patched binary.
Additional reproduction through Bun subprocess stdin
I hit the same SYS_sendto denial through Bun's subprocess API. This affects tools that pass input to child processes, not only Python asyncio.
Environment
Codex CLI: 0.151.0
Bun: 1.3.6
OS: WSL2, Linux 6.6.114.1-microsoft-standard-WSL2, x86_64
Sandbox: managed workspace-write profile with restricted network access
Inside the sandbox, /proc/self/status reports:
NoNewPrivs: 1
Seccomp: 2
Seccomp_filters: 1
Use case
The failure occurred while configuring open-pstack. Its external model runner uses Bun to start Claude Code in print mode and send the prompt through stdin:
Bun represents this stdin connection as a FileSink. The flush performed by FileSink.end() uses send(), which Linux implements as:
sendto(fd, buffer, length, flags, NULL, 0)
Codex rejects the call with EPERM. Claude receives EOF without any prompt bytes and exits with:
Input must be provided either through stdin or as a prompt argument when using --print
The original runner did not await stdin.end(), so it hid the EPERM rejection. Awaiting it reports the sandbox failure but cannot make the write succeed.
Node's child_process stdin pipe also works because it uses the ordinary pipe and write(2) path.
This supports the fix proposed in this issue: permit sendto when dest_addr == NULL and addrlen == 0. That keeps explicit-destination sendto() calls blocked while restoring connected Unix-socket writes used by Bun, Python asyncio,
and other local IPC implementations.
socket.socketpair(AF_UNIX, SOCK_STREAM) succeeds, but send() on the
connected socket returns PermissionError: [Errno 1] Operation not permitted.
Consequently, asyncio.to_thread() cannot wake the selector during executor
shutdown and asyncio.run() hangs in epoll_wait.
Both hung processes were eventually aborted and recorded by systemd-coredump as
SIGABRT. Their main thread was in epoll_wait; the executor worker was parked
in concurrent.futures.thread._worker.
Entire tests/test_briefing.py: 29 passed in 0.59s.
No new coredump was created.
Expected boundary
Allow sendto(..., dest_addr = NULL) for already-connected sockets, including
AF_UNIX socketpairs, while continuing to reject sendto() with an explicit
destination. This preserves external-network isolation while restoring local
IPC and asyncio cross-thread wakeups.
Reproducer
Run codex-sandbox-af-unix-regression.py inside and outside the restricted
Linux sandbox. It must finish in under two seconds and print PASS.
Additional affected program: rustup --version aborts in wait-timeout
Confirmed on 2026-11-02. This is another consequence of the connected Unix-socket send restriction: a read-only Rust toolchain version check aborts with SIGABRT, rather than hanging.
Environment
Codex CLI: 0.166.0 (codex --version on the affected machine)
Dependency identified in the panic: wait-timeout 0.2.1
Affected command and original stderr
The command was run by Codex's shell tool inside the restricted sandbox, with an installed default stable toolchain:
"$HOME/.cargo/bin/rustup" --version
Relevant excerpt from the captured output:
rustup 1.29.2 (d8c92c676 2026-10-21)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
thread 'main' (49) panicked at /cargo/registry/src/index.crates.io-1949cf8c6b5b557f/wait-timeout-0.2.1/src/unix.rs:233:17:
bad error on write fd: Operation not permitted (os error 1)
thread 'main' (49) panicked at /rustc/58cf8f9c35b355199727627d07ae34a4e2846d67/library/core/src/panicking.rs:225:5:
panic in a function that cannot unwind
thread caused non-unwinding panic. aborting.
Python subprocess.run() recorded return code -6.
systemd-coredump metadata and GDB backtrace excerpt
The other eight threads were parked in Tokio worker / I/O waits. No OOM event was found in the kernel journal around the crash. Some libc frames lack debug symbols.
Control outside the sandbox
The same binary and command were rerun with per-command require_escalated at 19:17:42 +03:00, without changing the Rust installation:
rustup 1.29.2 (d8c92c676 2026-10-21)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: the currently active `rustc` version is `rustc 1.99.1 (58cf8f9c3 2026-10-13)`
Exit code: 0.
Independent local-IPC check inside the restricted sandbox
AF_UNIX socketpair send: errno=1 Operation not permitted
AF_UNIX socketpair write: OK (1 byte)
This matches the restriction described in this issue. The Rust-specific failure is that wait-timeout panics on the denied notification write inside its SIGCHLD handler; the non-unwinding panic then aborts the process. No syscall trace of the original rustup process was captured; the evidence here is its stderr, core backtrace, sandbox metadata, outside-sandbox control, and independent socket test.
Only relevant, sanitized log excerpts are included; no raw core dump or environment dump is attached.
Prepared by GPT-6 via Codex; posted at the user's request.
We observed a related local IPC compatibility problem on Codex CLI 0.169.0, Linux x86_64, kernel 7.0.0-44-generic, workspace-write with restricted networking. In our existing Python transport tests, creation of a process-owned AF_UNIX SOCK_SEQPACKET socketpair succeeds, but sending a packet returns EPERM. Socket type validation with getsockopt(SOL_SOCKET, SO_TYPE) also appears to fail before peer credential validation (SO_PEERCRED). We did not obtain an exact syscall trace, so the attribution of the latter failure is not conclusive. The command child reports NoNewPrivs=1, Seccomp=2, Seccomp_filters=1.
Reviewing the exact rust-v0.169.0 and rust-v0.172.0 tagged Linux seccomp source, the Restricted branch denies sendto, getsockopt and setsockopt. Related reports: #39140, #47452, #57231.
Could maintainers confirm whether there is an officially supported Linux local-IPC permission profile or release that supports these operations for authenticated local Unix-domain communication while preserving filesystem isolation and external-network denial? In particular, does any supported profile cover process-owned socketpairs and pathname-bound AF_UNIX SOCK_SEQPACKET endpoints with kernel peer-credential checks? We would appreciate the supported version/configuration, applicable security guarantees, and recommended acceptance procedure. We are not requesting disabling the sandbox or broadly enabling networking.
Activity
everySympathy commentedon Jul 17, 2026
A tested patch is available here:
I attempted to open a draft PR against
openai/codex:main, but GitHub rejected both the GraphQL and REST creation paths for this external account:The branch is ready if a maintainer would like to invite the contribution or pull the commit directly.
Artem-B commentedon Aug 30, 2026
Additional reproduction through Bun subprocess stdin
I hit the same
SYS_sendtodenial through Bun's subprocess API. This affects tools that pass input to child processes, not only Pythonasyncio.Environment
0.151.01.3.66.6.114.1-microsoft-standard-WSL2, x86_64workspace-writeprofile with restricted network accessInside the sandbox,
/proc/self/statusreports:Use case
The failure occurred while configuring open-pstack. Its external model runner uses Bun to start Claude Code in print mode and send the prompt through stdin:
Bun represents this stdin connection as a
FileSink. The flush performed byFileSink.end()usessend(), which Linux implements as:Codex rejects the call with
EPERM. Claude receives EOF without any prompt bytes and exits with:The original runner did not await
stdin.end(), so it hid theEPERMrejection. Awaiting it reports the sandbox failure but cannot make the write succeed.Minimal Bun reproduction
Save this as
repro.ts:Run it from a Codex shell under the restricted Linux sandbox:
Actual result:
Run the same command in a normal terminal or with
danger-full-access.Expected result:
A direct syscall control produces the same result:
python3 -c 'import socket; a,b=socket.socketpair(); print(a.send(b"x"))'Inside the restricted sandbox:
Outside the sandbox:
Isolation and workaround
Both of these alternatives work inside the same restricted sandbox:
write(2)instead ofsend(2).Node's
child_processstdin pipe also works because it uses the ordinary pipe andwrite(2)path.This supports the fix proposed in this issue: permit
sendtowhendest_addr == NULLandaddrlen == 0. That keeps explicit-destinationsendto()calls blocked while restoring connected Unix-socket writes used by Bun, Pythonasyncio,and other local IPC implementations.
GustavoDRL commentedon Sep 9, 2026
Codex Linux sandbox: AF_UNIX regression confirmation
Upstream issues: #33793 and #24933
Environment
Actual result inside the sandbox
socket.socketpair(AF_UNIX, SOCK_STREAM)succeeds, butsend()on theconnected socket returns
PermissionError: [Errno 1] Operation not permitted.Consequently,
asyncio.to_thread()cannot wake the selector during executorshutdown and
asyncio.run()hangs inepoll_wait.A real pytest invocation hit the same path twice:
tests/test_briefing.py::TestNadaInterrompePorRotina::test_dia_tranquilo_nao_pede_nadaBoth hung processes were eventually aborted and recorded by systemd-coredump as
SIGABRT. Their main thread was in
epoll_wait; the executor worker was parkedin
concurrent.futures.thread._worker.Control result outside the sandbox
asyncio.to_thread(lambda: 42): returns 42 immediately.tests/test_briefing.py: 29 passed in 0.59s.Expected boundary
Allow
sendto(..., dest_addr = NULL)for already-connected sockets, includingAF_UNIX socketpairs, while continuing to reject
sendto()with an explicitdestination. This preserves external-network isolation while restoring local
IPC and asyncio cross-thread wakeups.
Reproducer
Run
codex-sandbox-af-unix-regression.pyinside and outside the restrictedLinux sandbox. It must finish in under two seconds and print
PASS.benmccann commentedon Sep 20, 2026
@etraut-openai would you be able to land everySympathy@582a47d ? Codex is constantly hitting sandbox issues when coding in Python today
pershin-daniil commentedon Nov 2, 2026
Additional affected program:
rustup --versionaborts inwait-timeoutConfirmed on 2026-11-02. This is another consequence of the connected Unix-socket send restriction: a read-only Rust toolchain version check aborts with
SIGABRT, rather than hanging.Environment
0.166.0(codex --versionon the affected machine)7.2.8-9-omarchy2.44+r50+g1848099f063e-1workspace-write, restricted network1.29.2 (d8c92c676 2026-10-21)1.99.1 (58cf8f9c3 2026-10-13)wait-timeout 0.2.1Affected command and original stderr
The command was run by Codex's shell tool inside the restricted sandbox, with an installed default stable toolchain:
"$HOME/.cargo/bin/rustup" --versionRelevant excerpt from the captured output:
Python
subprocess.run()recorded return code-6.systemd-coredump metadata and GDB backtrace excerpt
Selected metadata (home path normalized):
GDB backtrace excerpt; addresses omitted:
The other eight threads were parked in Tokio worker / I/O waits. No OOM event was found in the kernel journal around the crash. Some libc frames lack debug symbols.
Control outside the sandbox
The same binary and command were rerun with per-command
require_escalatedat 19:17:42 +03:00, without changing the Rust installation:Exit code:
0.Independent local-IPC check inside the restricted sandbox
Observed output:
This matches the restriction described in this issue. The Rust-specific failure is that
wait-timeoutpanics on the denied notification write inside its SIGCHLD handler; the non-unwinding panic then aborts the process. No syscall trace of the original rustup process was captured; the evidence here is its stderr, core backtrace, sandbox metadata, outside-sandbox control, and independent socket test.Only relevant, sanitized log excerpts are included; no raw core dump or environment dump is attached.
Prepared by GPT-6 via Codex; posted at the user's request.
rkboot7850-bit commentedon Nov 30, 2026
We observed a related local IPC compatibility problem on Codex CLI 0.169.0, Linux x86_64, kernel 7.0.0-44-generic, workspace-write with restricted networking. In our existing Python transport tests, creation of a process-owned AF_UNIX SOCK_SEQPACKET socketpair succeeds, but sending a packet returns EPERM. Socket type validation with getsockopt(SOL_SOCKET, SO_TYPE) also appears to fail before peer credential validation (SO_PEERCRED). We did not obtain an exact syscall trace, so the attribution of the latter failure is not conclusive. The command child reports NoNewPrivs=1, Seccomp=2, Seccomp_filters=1.
Reviewing the exact rust-v0.169.0 and rust-v0.172.0 tagged Linux seccomp source, the Restricted branch denies sendto, getsockopt and setsockopt. Related reports: #39140, #47452, #57231.
Could maintainers confirm whether there is an officially supported Linux local-IPC permission profile or release that supports these operations for authenticated local Unix-domain communication while preserving filesystem isolation and external-network denial? In particular, does any supported profile cover process-owned socketpairs and pathname-bound AF_UNIX SOCK_SEQPACKET endpoints with kernel peer-credential checks? We would appreciate the supported version/configuration, applicable security guarantees, and recommended acceptance procedure. We are not requesting disabling the sandbox or broadly enabling networking.