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

Open 💬 2 comments Opened Apr 6, 2026 by 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.

View original on GitHub ↗

2 Comments

futile · 4 months ago

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

marmeladema · 28 days ago

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.