Skip to content

Sandbox: Linux refuses Unix sockets too, and hands commands the daemon - #514

Merged
lydakis merged 2 commits into
mainfrom
claude/project-thread-xdi5gl
Oct 31, 2026
Merged

lydakis merged 2 commits into
mainfrom
claude/project-thread-xdi5gl

Conversation

@lydakis

@lydakis lydakis commented Oct 31, 2026 •

Copy link
Copy Markdown
Owner

Follows #508 on Linux, where a read-only bind mount doesn't stop connect().

What changes

  • seccomp filter. bubblewrap now loads one with --seccomp, compiled with seccompiler the way Codex's Linux sandbox and Firecracker compile theirs.
    • It refuses socket(AF_UNIX) with EPERM unless the bot's unix_sockets names any socket. A filter can't see paths, so naming any opens them all, as Claude Code's allowAllUnixSockets does.
    • It refuses io_uring_setup, because the filter can't see the calls io_uring makes. On x86_64 it refuses the x32 variants too.
    • It ends any command that makes calls of another architecture.
    • socketpair stays allowed.
  • Connection handoff (broker pattern).
    • The daemon gives each command one end of a SEQPACKET socket pair and names it in AGENT_SOCKET_FD.
    • Each byte the command writes there is answered over SCM_RIGHTS with a connection to the bot's own socket, or with none when that socket is gone.
    • Connections are handed blocking, the same as a connection the command made itself.
    • agent_client::Client::connect and the CLI's greeted_until connect this way when AGENT_SOCKET names that socket. Otherwise they fall back to a direct connect.
  • Docs: the sandbox section of docs/RUST_PROTOTYPE.md, the Sonny README and FEATURES.

No protocol bump: nothing on the wire changed, and AGENT_SOCKET_FD is environment only.

Tests

  • a_sandboxed_command_cannot_reach_the_daemon_socket, network on and off, now checks three things:
    • The daemon's socket and a socket in the workspace are both refused.
    • A command reaches its own socket only through the handed descriptor, and the listener reads what it sent.
    • Naming a socket reaches it.
  • The test_approvals probe reaches the bot's own socket through the handed descriptor.
  • Local runs: cargo test --workspace, clippy with -D warnings, fmt, and the full Python suite under bubblewrap 0.9. All green except test_wait, which failed once under --jobs 6 and passed when rerun on its own.

Revert: reverting this PR restores #508's Linux behaviour, where the sandbox doesn't block sockets on Linux.

On Linux a read-only mount doesn't stop connect(), so bubblewrap now
loads a seccomp filter (compiled with seccompiler, as Codex and
Firecracker compile theirs) that refuses socket(AF_UNIX) unless the
bot's unix_sockets names any, refuses io_uring, and ends calls of
another architecture. Socket pairs stay allowed.

A command still reaches its bot's own socket: the daemon hands it
connections over an inherited socket pair named by AGENT_SOCKET_FD,
as a broker does, and the clients connect that way when AGENT_SOCKET
names that socket.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGDM2LnoDcXYpJdFY7Y
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-31T10:02:45.614751Z dcc7970 New commits
🔒 Security Review ✅ Completed 2026-10-31T10:04:46.230277Z dcc7970 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f923b91242

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread client/src/socket.rs Resolved
Comment thread src/sandbox.rs Resolved
A pair of Unix datagram sockets (or raw ones, which Linux makes
datagrams) sends to any socket's path, so the filter refuses them
when the bot names no sockets; stream and packet pairs stay allowed.

The handed descriptor reaches only processes that keep it, as make's
jobserver descriptors do. The client checks it is still the daemon's
packet socket before writing to it, and when a launcher closed it
inside a sandbox, says which descriptor went missing and that
Python's subprocess keeps it with pass_fds.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGDM2LnoDcXYpJdFY7Y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants