Skip to content

Linux sandbox: seccomp denies setsockopt on AF_UNIX socketpair, crashing all Chromium-family browsers at startup (SIGTRAP) #47452

Open

Description

@julianjones08-ctrl

What version of Codex CLI is running?

codex-cli 0.155.1

What platform is your computer?

Linux 7.2.5-3-omarchy x86_64 (Omarchy, Arch-based)

What issue are you seeing?

The restricted Linux network seccomp filter denies setsockopt(2) unconditionally. Chromium's Crashpad calls setsockopt(SOL_SOCKET, SO_PASSCRED) on a local AF_UNIX socketpair during crash-handler startup, treats the EPERM as fatal, and calls IMMEDIATE_CRASH().

The result is that every Chromium-family browser aborts with SIGTRAP about 1 ms into startup inside the sandbox. This makes Playwright/Puppeteer and any headless-Chrome work impossible in workspace-write, and it is a hard crash rather than a recoverable error — each attempt also leaves a real core dump behind via systemd-coredump.

The socket is a purely local socketpair(AF_UNIX, SOCK_STREAM) used for Crashpad's internal IPC. No network is involved.

Observed browser output:

[2:2:0923/003022.366636:ERROR:third_party/crashpad/crashpad/util/linux/socket.cc:45] setsockopt: Operation not permitted (1)

Kernel log for the same event:

traps: chrome[65035] trap int3 ip:5c3cc822252b sp:7ffccd8c2a40 error:0 in chrome[...]

What steps can reproduce the bug?

Minimal reproduction — no browser needed:

// sotest.c
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <sys/socket.h>
int main(void) {
  int s[2];
  if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, s) != 0) {
    printf("socketpair FAILED: %s\n", strerror(errno));
    return 1;
  }
  printf("socketpair OK\n");
  int one = 1;
  if (setsockopt(s[0], SOL_SOCKET, SO_PASSCRED, &one, sizeof(one)) != 0)
    printf("setsockopt SO_PASSCRED FAILED: %s (%d)\n", strerror(errno), errno);
  else
    printf("setsockopt SO_PASSCRED OK\n");
  return 0;
}
$ gcc -o sotest sotest.c

$ ./sotest
socketpair OK
setsockopt SO_PASSCRED OK

$ codex sandbox -- ./sotest
socketpair OK
setsockopt SO_PASSCRED FAILED: Operation not permitted (1)

End-to-end with a browser:

$ chromium --headless --no-sandbox --disable-gpu --user-data-dir=$(mktemp -d) --dump-dom about:blank
<html><head></head><body></body></html>          # exit 0

$ codex sandbox -- chromium --headless --no-sandbox --disable-gpu --user-data-dir=$(mktemp -d) --dump-dom about:blank
[...:ERROR:third_party/crashpad/crashpad/util/linux/socket.cc:45] setsockopt: Operation not permitted (1)
                                                  # exit 133 (128 + SIGTRAP)

Confirmed on chromium 152.0.7977.82, google-chrome 153.0.8010.47, and brave 1.95.101. The affected process reports:

NoNewPrivs:      1
Seccomp:         2
Seccomp_filters: 1
CapBnd:          0000000000000000

What is the expected behavior?

setsockopt on a local AF_UNIX socket should succeed, and headless Chromium should start normally inside workspace-write.

setsockopt(2) cannot by itself create a socket, establish a connection, or transmit data — network isolation is already enforced by the denials on socket, connect, bind and sendto. Denying setsockopt does not add containment, but it does break local IPC, because seccomp sees only the file descriptor number and cannot tell an AF_UNIX socketpair from a network socket.

Additional information

This is the same class of bug as #33793 (sendto denied unconditionally, breaking send() on connected AF_UNIX sockets) and is adjacent to #39140 and #16910, but it is a different syscall — setsockopt is not mentioned in any of those issues, and the dest_addr-based fix proposed in #33793 would not address it.

Unlike the asyncio hang in #33793, the failure mode here is a hard abort of the whole browser process, so it surfaces as an unexplained crash rather than a stall.

Activity

  1. added
    bug
    CLI
    sandbox
    on Sep 23, 2026
  2. julianjones08-ctrl commented on Sep 23, 2026

    @julianjones08-ctrl
    Author

    Additional data point: enabling network access does not lift this denial, so the workaround that looks most obvious does not work.

    Tested with the reproducer from the issue body, codex-cli 0.155.1:

    Sandbox setting setsockopt(SO_PASSCRED) chromium --headless ... --dump-dom about:blank
    workspace-write (default) EPERM exit 133 (SIGTRAP)
    workspace-write + sandbox_workspace_write.network_access = true EPERM exit 133 (SIGTRAP)
    sandbox_mode = "danger-full-access" OK exit 0, renders normally
    $ codex sandbox -c sandbox_workspace_write.network_access=true -- ./sotest
    socketpair OK
    setsockopt SO_PASSCRED[0] FAILED: Operation not permitted (1)
    setsockopt SO_PASSCRED[1] FAILED: Operation not permitted (1)
    
    $ codex sandbox -c sandbox_mode=danger-full-access -- ./sotest
    socketpair OK
    setsockopt SO_PASSCRED[0] OK
    setsockopt SO_PASSCRED[1] OK

    The practical consequence is that there is currently no scoped workaround. Running a browser under Codex on Linux requires disabling the sandbox entirely, rather than just relaxing the network policy — which is a much larger concession than the task needs.

    It may also be worth checking whether setsockopt should be gated by the network policy at all, given that it cannot create a socket, connect, or transmit on its own.

  3. el-pandor commented on Oct 13, 2026

    @el-pandor

    Additional evidence consistent with this issue, observed on Omarchy (Arch-based Linux):

    Codex desktop 26.1007.21434 (build 13901); the bundled runtime currently reports codex-cli 0.162.0-alpha.17.2. Chromium package 152.0.7977.82-1. These versions were collected after the incident; the exact runtime version active at the crash was not independently captured.

    Playwright launched Chromium headlessly with --no-sandbox and a disposable profile. Startup logged:

    third_party/crashpad/crashpad/util/linux/socket.cc:45] setsockopt: Operation not permitted (1)
    

    Seven locally inspected coredump records across two days show SIGTRAP at the same unresolved top-frame offset, chromium + 0x10dff9f1. The kernel recorded an int3 trap. Retrying the same test outside the Codex execution sandbox successfully launched Chromium and reached a page assertion; this does not establish that the entire test passed.

    This is strong evidence of a sandbox-triggered Crashpad startup failure. We have not identified the exact sandbox rule responsible on this machine.

    No dumps or raw logs are attached.

  4. amahjoor commented on Nov 8, 2026

    @amahjoor

    Additional root-cause evidence: fixing only setsockopt does not fully resolve this startup failure.

    Environment: Omarchy / Linux 7.2.8-9-omarchy x86_64, codex-cli 0.164.0, Chromium 155.0.8059.84-1. The current main source still has the unconditional getsockopt, setsockopt, and shutdown denials in Restricted mode:

    deny_syscall(&mut rules, libc::SYS_shutdown);
    deny_syscall(&mut rules, libc::SYS_sendto);
    deny_syscall(&mut rules, libc::SYS_sendmmsg);
    // NOTE: allowing recvfrom allows some tools like: `cargo clippy`
    // to run with their socketpair + child processes for sub-proc
    // management.
    // deny_syscall(&mut rules, libc::SYS_recvfrom);
    deny_syscall(&mut rules, libc::SYS_recvmmsg);
    deny_syscall(&mut rules, libc::SYS_getsockopt);
    deny_syscall(&mut rules, libc::SYS_setsockopt);

    I tested small candidate changes using the actual install_network_seccomp_filter_on_current_thread function extracted from that revision, compiled with the workspace's seccompiler 0.5.0 and libc 0.2.186. Only unrelated context/error types were replaced with small harness types. Each helper child installs the filter and execs the probe. The parent runs outside an existing sandbox because seccomp filters stack.

    This is isolated network-filter validation, not a complete Codex build or a test of bubblewrap/filesystem enforcement, managed-network routing, or other architectures.

    The Chromium startup sequence exposed these barriers:

    Filter change Observed result
    Unmodified policy The original core preserves setsockopt: Operation not permitted at Crashpad socket.cc:45. A fresh local socket probe reproduces EPERM.
    Allow only setsockopt(SOL_SOCKET, SO_PASSCRED) Chromium still exits with SIGTRAP. Crashpad's exception_handler_server.cc:361 reports getsockopt: Operation not permitted.
    Allow both getsockopt and setsockopt for SOL_SOCKET/SO_PASSCRED Chromium gets past the credential setup, then exits with SIGABRT at sandbox_host_linux.cc:41: shutdown: Operation not permitted.
    Also allow shutdown(SHUT_RD) and shutdown(SHUT_WR) Chromium reaches profile initialization, then exits 21 because bind() of its temporary SingletonSocket returns EPERM. It does not load the blank page.

    The browser probes used a fresh disposable profile, --headless --no-sandbox --disable-gpu --disable-extensions --disable-background-networking --dump-dom about:blank. Core file output was disabled, and temporary profiles were removed. No normal browser profile was used.

    Crashpad's handler reads SO_PASSCRED before deciding whether to set it, so both getter and setter matter:

    https://github.com/chromium/crashpad/blob/main/handler/linux/exception_handler_server.cc

    Chromium then half-closes the read/write directions of an AF_UNIX/SOCK_SEQPACKET pair during SandboxHostLinux::Init:

    https://github.com/chromium/chromium/blob/155.0.8059.84/content/browser/sandbox_host_linux.cc

    For a narrow credential-option correction, the seccomp rule can reject a call when level != SOL_SOCKET OR optname != SO_PASSCRED. Those must be two alternative deny rules; putting both comparisons in the same rule would incorrectly allow other options at SOL_SOCKET and the same numeric option at other levels. The exception is option-specific, not descriptor-family-specific: classic seccomp cannot inspect the descriptor's socket family.

    Six targeted before/after checks passed for the candidate with both credential operations and read/write half-close enabled:

    • The unmodified filter reproduces the credential failure.
    • The candidate enables credential passing and half-close on SOCK_STREAM and SOCK_SEQPACKET pairs. The receiver verifies the kernel-provided PID/UID/GID.
    • Both filters still reject AF_INET, AF_INET6, and AF_VSOCK socket creation, unrelated socket options, and mismatched option levels with EPERM.
    • Both filters still reject connect, bind, and unrelated socket options on an IP socket deliberately inherited from the unfiltered parent.

    I also prepared two regression cases in linux-sandbox's integration suite covering credential IPC and continued denials. The Python probe bodies ran against the compiled filter; the complete Rust integration suite has not been built or run.

    The remaining SingletonSocket bind failure is important: these narrow corrections remove the early fatal failures but do not establish a complete headless-browser fix. A complete solution needs an explicit policy for local profile sockets while preserving restrictions on inherited network descriptors and host-service access.

    Prepared with Codex; diagnostic code and results were checked locally. No core dumps or private application logs are attached.

  5. Kinosaur commented on Nov 25, 2026

    @Kinosaur

    I encountered the reported symptom too: a headless Chromium launch from Playwright ended with SIGTRAP during Crashpad startup.

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

    CLILinuxbugsandbox

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions