Skip to content

Sandbox: Unix sockets reached only as a bot's settings name them - #508

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

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

Conversation

@lydakis

@lydakis lydakis commented Oct 31, 2026 •

Copy link
Copy Markdown
Owner

A program listening on a Unix socket does whatever its clients ask, outside the sandbox. A browser's daemon launches a browser, and Docker runs a container. Today a sandboxed command can connect to any socket it can see. This PR follows Claude Code's sandbox and Codex's managed network, which block Unix sockets by default and allow them per path.

Daemon

  • New bot setting unix_sockets (--unix-socket PATH, repeatable). Each entry is an absolute path to a socket or to a folder of sockets.
    • At most 64 entries, 32 KiB as JSON. The create reply's admission bound covers them.
    • Each is stored through agent_client::files::real: the part of the path that exists is resolved, dangling links are followed, and the rest is kept as written. This used to be sandbox::real; it moved so Sonny resolves paths the same way.
    • It is accepted only with a sandbox, and a bot made by another bot keeps only the entries its creator has. configure's sandbox op takes it too.
  • Seatbelt, network on or off: a sandboxed bot reaches only the sockets its unix_sockets names, plus its own capability socket. Sockets in its own folders aren't allowed by default. A hard link there to any socket, the daemon's included, needs no right to the socket and would reach it.
  • Protocol 30.

Sonny

  • A [sonny.permissions.NAME] row takes unix_sockets, with ~ for home.
  • The row is passed to the daemon, and a bot's row is read back from it.
  • A read-only row refuses the key.

Not in this PR: Linux. Bubblewrap's read-only root does not stop a connection, because connect() to a socket ignores read-only mounts. I checked this with bwrap 0.9 and --unshare-net. So a sandboxed Linux command reaches every host socket today, the systemd user bus included. The Linux mechanism is still being chosen and will follow in its own PR. The docs say Linux does not restrict sockets yet.

Tests:

  • cargo clippy --workspace --all-targets -D warnings is clean.
  • cargo test --workspace passes.
  • The tests.test_approvals, tests.test_served and tests.test_cli Python modules pass locally.
  • New tests:
    • unix_sockets_are_reached_only_as_named (Seatbelt profile)
    • a_sandboxed_command_reaches_only_the_sockets_it_names (macOS end to end, network on and off)
    • a_row_s_sockets_are_the_daemon_s_and_tell_it_from_auto (Sonny rows, including a link to a socket that doesn't exist yet)
    • The admission bound test, now with 64 escaped socket paths
    • The config parse test

🤖 Generated with Claude Code

A program listening on a Unix socket runs what it is asked outside the
sandbox, as a browser's daemon launches a browser or Docker runs a
container. As Claude Code's sandbox blocks them by default, Seatbelt now
lets a workspace-write bot's commands reach only the sockets in its own
and writable folders, and those its new unix_sockets setting names; a
read-only bot's only those named. Sonny's permission rows take
unix_sockets too. Linux still reaches every socket it can see; that
follows.

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-31T08:09:30.287704Z b23bae3 New commits
🔒 Security Review ✅ Completed 2026-10-31T08:12:13.751424Z b23bae3 New commits

Security findings

Advisory findings (1)

ℹ️ 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: fc607651eb

ℹ️ 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 src/server/mod.rs Resolved
Comment thread src/store/db.rs Resolved
…re they exist

A create reply's bound now covers its unix_sockets, which take at most
32 KiB as JSON as writable folders do. A socket not made yet is stored
with what of its path exists resolved, so a link above it, as macOS's
/tmp is, still matches Seatbelt's real path; Sonny's rows resolve them
the same way.

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

@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: ed0bdbfae8

ℹ️ 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 sonny/src/approvals.rs Resolved

@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 Security Review · Automatically triggered

Here are some automated security review suggestions for this pull request.

Reviewed commit: ed0bdbfae8

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Comment thread src/sandbox.rs Resolved
The daemon's real-path resolver, which follows a dangling link to its
target, moves to agent-client, so Sonny reads a row's sockets back
exactly as the daemon stored them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGDM2LnoDcXYpJdFY7Y
A hard link in a bot's folder to any socket, the daemon's among them,
needs no right to the socket and would reach it by a name there. So, as
Claude Code's sandbox and Codex's managed network do, a sandboxed bot's
commands reach only the Unix sockets its unix_sockets names. A macOS test
connects from inside Seatbelt to the daemon's socket in the workspace,
another there, one outside, one named and one in a named folder.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGDM2LnoDcXYpJdFY7Y
@lydakis lydakis changed the title Sandbox: Unix sockets reached only in the bot's folders and those named Sandbox: Unix sockets reached only as a bot's settings name them Oct 31, 2026
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