Skip to content

Sonny: browser and desktop run only a copy no agent can swap - #654

Merged
lydakis merged 3 commits into
mainfrom
claude/project-thread-xdi5gl
Nov 2, 2026
Merged

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

Conversation

@lydakis

@lydakis lydakis commented Nov 2, 2026 •

Copy link
Copy Markdown
Owner

Closes #614 and does what the external review asked for: one resolver for trusted native programs, shared by browser and desktop.

Before

Both tools ran agent-browser or agent-desktop from PATH, outside the sandbox.

  • browser refused only a program inside a folder the calling agent writes.
  • desktop checked nothing.
  • Neither tool looked at other agents' folders, or at a swap made after the check.

Now (sonny/src/trusted.rs)

  • Finding the program: native() finds the program on PATH as before: the first folder named from the root, then the native binary beside npm's launcher. This replaces the two copies of found() that browser.rs and desktop.rs each had.
  • When it is admitted: Pins::program() admits the program before its first call, and again whenever it or its copy changes. A change means a different device, inode, size, mtime or ctime on any of its files.
  • What admitting checks and does:
    • It refuses while the program, or the folder its copy goes in, sits in a folder some agent of the store writes. That covers each agent's workspace, its writable folders, and $TMPDIR and /tmp, which a workspace-write sandbox writes.
    • Otherwise it copies the program into ~/.agent/sonny/programs/NAME/, together with the package's other native programs for this platform. That includes agent-desktop's macOS helper, which agent-desktop starts by name from its own folder.
    • It stamps the original again after copying, so a swap during the copy is refused rather than run.
  • What runs: the tools run only the copy.
  • Whose folders count: the agents come from bots plus inspect, over the tool host's own connection, so calls from a linked machine are checked against this store too. An agent with no sandbox isn't counted, because it already runs as the person.
  • Choice: George chose the copy over checks alone. On macOS the copy is what gets granted Accessibility and Screen Recording. agent-desktop isn't signed by a developer, so an upgrade asks for the grant again either way.

Tests

  • trusted.rs unit tests:
    • the copy runs;
    • a swap after admission changes nothing that runs, and admitting again asks again;
    • a change to the copy gets it copied again;
    • an original in the caller's folder is refused, in another agent's folder too, and through a symlink to it;
    • the folder the copy goes in, if an agent writes it, is refused;
    • only this platform's native programs are copied.
  • End-to-end test_an_agent_desktop_any_agent_could_swap_is_never_run:
    • refused for the agent whose workspace holds the program;
    • refused for an agent with no sandbox, naming the one that could swap the program;
    • nothing runs.
  • The existing desktop and browser end-to-end tests pass. I ran the browser one with agent-browser installed outside /tmp. From inside /tmp it is now refused for a workspace-write agent, which is correct.
  • cargo clippy -p sonny --all-targets -D warnings is clean. cargo test -p sonny: 998 pass. The one failure here, a_bot_is_given_sonnys_tools_beside_its_own_once, comes from agent-browser being installed in this container (seen before, and it passes in CI).

The browser and desktop tools ran agent-browser and agent-desktop from
PATH outside the sandbox. The browser refused a program in a folder the
calling agent writes; the desktop checked nothing, and neither checked the
other agents' folders or a swap after the check (#614, and an external
review).

Now one resolver, sonny/src/trusted.rs, finds each program's native
binary as before, and admits it before its first call and again whenever
it or its copy changes: refused while it, or the folder its copy goes in,
is in a folder some agent of the store writes (its workspace, its
writable folders, and the temporary folders a workspace-write sandbox
writes), else copied with the package's other native programs for this
platform into ~/.agent/sonny/programs/NAME/. The tools run only that
copy. An agent with no sandbox is not counted: it runs as the person.

George chose the copy over checks alone. On macOS the copy is what is
granted Accessibility and Screen Recording.

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 Nov 2, 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-11-02T03:49:45.161710Z 5b0ebd8 New commits
🔒 Security Review ✅ Completed 2026-11-02T03:37:23.320739Z 14931f7 PR opened
ℹ️ 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: 14931f746a

ℹ️ 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/trusted.rs Resolved
From review: the copy was resolved once per call, before an acting call
waited for its approval, so a copy swapped while it waited would run.
Each command now resolves it as it starts; a swapped copy has new stamps,
so it is admitted again, against the agents as they are then, and refused
when one writes its folder.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGDM2LnoDcXYpJdFY7Y
@lydakis
lydakis merged commit 5ad7f8a into main Nov 2, 2026
10 checks passed
@lydakis
lydakis deleted the claude/project-thread-xdi5gl branch November 2, 2026 04:10
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.

Browser: pin agent-browser outside every agent's writable folders, not just the caller's

2 participants