Skip to content

Linux sandbox: support safe sandbox-local AF_UNIX sockets (e.g., sccache) #16910

Open

Description

@rebroad

Summary

Please consider supporting safe sandbox-local socket IPC so tools like sccache can work under Linux sandboxing.

Today, strict sandboxing blocks socket operations, which prevents sccache from functioning as RUSTC_WRAPPER.

Goal

Enable local IPC needed by developer tools without reintroducing broad host/network exposure.

Proposed safe model

  1. Keep --unshare-net enabled (no external network namespace sharing).
  2. Allow AF_UNIX socket creation/connection for sandboxed processes.
  3. Deny AF_INET/AF_INET6 socket creation in this mode.
  4. Use private sandbox temp/runtime dirs (for example private /tmp tmpfs) so UNIX sockets are sandbox-local, not host-shared.

This allows local daemon-style tools (sccache) to work while keeping network and host-socket exposure constrained.

Why this is useful

  • sccache client/server uses local sockets for wrapper↔daemon communication.
  • In locked-down sandboxes, builds currently require disabling RUSTC_WRAPPER, losing cache speedups.
  • A sandbox-local UDS model preserves performance benefits with tighter boundaries.

Concrete example

A supported pattern could be:

  • SCCACHE_SERVER_UDS=/tmp/sccache/sccache.sock
  • SCCACHE_DIR=/tmp/sccache/cache

when /tmp is private to the sandbox.

Clarification request

If there is already a recommended configuration for sandbox-local AF_UNIX IPC that works with sccache, please document it.

Activity

  1. added
    bug
    CLI
    sandbox
    on Apr 6, 2026
  2. changed the title [-]Sandbox hardening: avoid exposing host /tmp UNIX sockets via writable /tmp mount[/-] [+]Sandbox hardening: safer default for host /tmp exposure in workspace-write[/+] on Apr 6, 2026
  3. reopened this on Apr 6, 2026
  4. changed the title [-]Sandbox hardening: safer default for host /tmp exposure in workspace-write[/-] [+]Linux sandbox: support safe sandbox-local AF_UNIX sockets (e.g., sccache)[/+] on Apr 6, 2026
  5. added
    enhancement
    and removed
    bug
    CLI
    on Apr 6, 2026
  6. futile commented on Apr 14, 2026

    @futile

    Same issue, can't use sccache inside the sandbox, even when adding the cache directory as a writeable root.

    I shared my log through /feedback: thread ID 019d8e32-b97c-7da1-ad24-6126b874a132

  7. marmeladema commented on Jul 31, 2026

    @marmeladema

    I was annoyed by this problem too so I took the liberty to implement a file based IPC layer for sccache: https://github.com/marmeladema/sccache/tree/feature/fifo-ipc

    In order to use it you need to manually start the server outside of the sandbox like the following:

    export SCCACHE_SERVER_FIFO="$HOME/.cache/sccache/server.fifo"
    ${HOME}/.cargo/bin/sccache --start-server

    Then configure codex to allow sccache cache directory as writable:

    [sandbox_workspace_write]
    writable_roots = [
      "/home/elie/.cache/sccache",
    ]

    Note that Landlock added support for pathname-based socket connection rules with LANDLOCK_ACCESS_FS_RESOLVE_UNIX in ABI 9 which I believe has been shipped as part of Linux kernel 7.1.x series so it's only a matter of time before it trickles down to codex itself.

  8. ProTip commented on Sep 7, 2026

    @ProTip

    I believe this also prevents the default dotnet restore from working as MSBuild uses multiple nodes by default that communicate through a socket it creates under /tmp..

  9. diogovalada commented on Sep 27, 2026

    @diogovalada

    Ran into this with CUDA on Linux (Codex 0.157.0, NVIDIA driver 580.173.02, network proxy enabled).

    After exposing the NVIDIA devices inside the inner bwrap sandbox, CUDA initialization still failed. The trace showed it creating and binding an abstract Unix socket named cuda-uvmfd-.... Allowing Unix sockets with dangerously_allow_all_unix_sockets = true got initialization and a small device-memory allocation/copy test working.

    So GPU access needs local IPC as well as device access. A pathname allowlist wouldn't cover this abstract socket. #45534 gives us a working workaround, but is there a way to allow this sandbox-local IPC without the broad Unix-socket grant? This also seems relevant to #3141.

  10. Liskarm commented on Oct 9, 2026

    @Liskarm

    Adding a Unity Licensing Client use case for scoped sandbox-local IPC. These observations were collected through agent-assisted diagnostics in dot's own managed Linux cloud computer on October 9, 2026, not a user-managed local Codex installation.

    Environment and evidence boundaries

    • Debian 13, Linux 6.18.44, x86_64.
    • Installed Codex package metadata reports 0.159.2; this does not identify every component of the deployed managed-host build.
    • The visible launcher uses managed proxy-routed networking and the seccomp stage.
    • Relevant observed policy fields: allowLocalBinding=true, allowUnixSockets=[], dangerouslyAllowAllUnixSockets=false.
    • Unity CLI 1.0.0-beta.13, Unity Licensing Client 1.19.0-rc.3.

    Minimal reproduction inside the managed shell

    import socket
    
    for name, family, kind in [
        ("AF_UNIX/STREAM", socket.AF_UNIX, socket.SOCK_STREAM),
        ("AF_UNIX/DGRAM", socket.AF_UNIX, socket.SOCK_DGRAM),
        ("AF_INET/STREAM", socket.AF_INET, socket.SOCK_STREAM),
        ("AF_INET6/STREAM", socket.AF_INET6, socket.SOCK_STREAM),
    ]:
        try:
            with socket.socket(family, kind):
                print(name, "created")
        except OSError as error:
            print(name, "errno=", error.errno, error.strerror)

    Both AF_UNIX cases fail with EPERM (errno 1) during socket creation, before any bind/connect path is supplied. AF_INET and AF_INET6 creation succeeds. A separate C probe reproduces the AF_UNIX failure. Loopback TCP, AF_UNIX socketpair, FIFOs and ordinary pipes also work.

    Application impact

    Direct Unity Licensing Client startup fails to create both its request and notification named-pipe servers. Sanitized stack sequence:

    System.Net.Sockets.SocketException (13): Permission denied
    Socket..ctor
    NamedPipeServerStream.SharedServer..ctor / Get
    NamedPipeServerStream.Create
    MultiClientPipeServer / NotificationsPipeServer
    errorType: IpcError
    

    The client remained alive after these errors and was terminated by the diagnostic's 25-second timeout; this was not a spontaneous exit. Client --help and empty-profile --showEntitlements succeed.

    Unity's documented UNITY_NO_AUTH_BROKER=1 compatibility option did not remove the separate licensing-layer failure. Fresh-profile authentication-status checks only showed "signed out"; they do not prove authenticated broker startup works. No login or activation was attempted in these diagnostics.

    This behavior is consistent with the default restriction described in #45534 and the 0.159.2 ProxyRouted filter. The empty Unix-socket allowlist means this is not evidence of an ignored explicitly allowed host-socket path as in #39140.

    Could this Unity licensing case be included in the scope of #16910? The need is a supported, narrowly scoped IPC mechanism for cooperating processes inside the same managed sandbox, retaining host-socket isolation and existing filesystem/network controls. If such a supported provision exists for dot's managed cloud computer, guidance would be appreciated; otherwise, clarifying the supported limitation would help. A blanket Unix-socket grant is broader than needed.

    No credentials, account or conversation identifiers, private project data, full launcher command line, or proxy routing details are included in this report.

  11. utkarshgupta137 commented on Oct 9, 2026

    @utkarshgupta137

    The following worked for me:

    [features]
    
    [features.network_proxy]
    enabled = true
    
    [permissions]
    
    [permissions.workspace]
    extends = ":workspace"
    
    [permissions.workspace.filesystem]
    "~/.cache/sccache" = "write"
    "~/.local/run/sccache/sccache.sock" = "write"
    
    [permissions.workspace.network]
    enabled = true
    
    [permissions.workspace.network.domains]
    
    [permissions.workspace.network.unix_sockets]
    "~/.local/run/sccache/sccache.sock" = "allow"
  12. rebroad commented on Oct 26, 2026

    @rebroad
    Author

    I hit the same restriction using sccache as a compiler wrapper in a sandbox that allows cache access but denies local IPC. I’ve opened a draft upstream sccache PR for an opt-in SCCACHE_IN_PROCESS=1 mode, which runs the compile pipeline directly in each wrapper process without contacting the daemon: mozilla/sccache#2955. The branch is rebroad/sccache pr/in-process-sandbox-cache.

    The draft is a request for comments while I validate behavior across platforms. In-process mode keeps statistics process-local and disables distributed compilation.

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

    enhancementsandbox

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions