Repository navigation
Fixes from the owed security reviews: zen reads, agent home read-only, note topics - #587
Merged
Merged
Conversation
Sandboxed agents may write ~/.agent/sonny/zen so `sonny zen` works from their shell, and Sonny reads every focus on its UI loop. A focus replaced by a FIFO, or a link to /dev/zero, would hold the window (and any other window that asks). focus_in now opens with O_NOFOLLOW | O_NONBLOCK, reads only a regular file, and at most 16 KiB. Found by the Codex code review on the security-review-only PR #578 (#531). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGCrVNEpqFFEqPCMbC2
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
A workspace-write bot whose folder contains ~/.agent (Sonny opened in HOME) could rewrite the scheduler's job definitions, which run outside the sandbox, or the settings that say how every bot is sandboxed. The CLI now starts the daemon with ~/.agent as a protected path, as Codex keeps ~/.codex: read-only in any root that holds it, writable only where a bot is given a folder in it by name (Sonny's zen folder). Bots in any other folder already could not write there, so nothing they do changes. Found by the Codex code review on the security-review-only PR #579 (#531). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGCrVNEpqFFEqPCMbC2
A source's topic goes into the agent's note unquoted, after the source's name, and Event::parse let line breaks through, so an event could add lines of its own outside the quoted text. A topic now holds no control characters, and the commons reads only threads whose file names it could have made (valid_name), as its listing already did. Found by the Codex code review on the security-review-only PR #585 (#531). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGCrVNEpqFFEqPCMbC2
This was referenced Nov 1, 2026
This was referenced Nov 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes three findings from the after-the-fact reviews tracked in #531.
1. Zen focus files are read only when plain, small and not a link (Sonny)
zen::focus_innow opens the file withO_NOFOLLOW | O_NONBLOCK | O_CLOEXEC. It reads the file only if it is a regular file, and reads at most 16 KiB (MAX_FOCUS). Anything else counts as no focus.Why: sandboxed agents may write
~/.agent/sonny/zen, so thatsonny zenworks from their shell. Sonny reads foci on its UI loop (zen_taken_up) and in the commons. A bot could swap its focus file for a FIFO or a symlink to/dev/zero. That would freeze its own window and any other window that reads it. Found by the Codex code review on #578 (P2, r4434602784).2.
~/.agentstays read-only for bots whose folder holds it (agent CLI)The CLI now starts the daemon with
--protect-path ~/.agent, as Codex keeps~/.codex. The folder is read-only in any writable root that contains it. A bot can still write a folder inside it that it is given by name, such as Sonny's zen folder, because the deepest root decides.Why: when Sonny is opened in HOME, a workspace-write bot's folder holds
~/.agent. That bot could rewrite~/.agent/triggers/jobs, which the scheduler runs outside the sandbox, so it could keep running code unsandboxed. It could also rewriteconfig.toml, which sets every bot's sandbox.PROTECTEDalready covered~/.agentsand~/.codexin that case, but not our own home. Bots in any other folder already could not write there, so nothing changes for them. Found by the Codex code review on #579 (P1, r4434605462). This uses the existing--protect-pathflag, so there is no daemon code change.3. A note's topic holds no line breaks, and the commons reads only valid thread names (Sonny)
A source event's
topicgoes into the agent's note unquoted, andEvent::parselet newlines through. An event could therefore add prompt lines of its own outside its quoted text. A topic with a control character is now dropped, as a topic with a colon already was. The commons source and the posters migration now read only.jsonlfiles whose names passvalid_name, as the thread listing already did. Found by the Codex code review on #585 (P1, r4434606867).Tests
zen::tests::only_a_plain_small_focus_file_is_read: a symlink, a symlink to/dev/zero, a FIFO and a file over the cap all read as no focus. A normal focus and a file exactly at the cap still read.sandbox::tests::a_protected_home_stays_read_only_but_for_a_folder_given_in_it: with HOME as the workspace,triggers/jobs,config.tomlandenvcannot be written, while a file in HOME and the given zen folder can.cargo clippy --workspace --all-targets -D warningsis clean. The sandbox, agent-client, lookout and commons tests pass.sonny/FEATURES.md: updated the zen row.#588 is a do-not-merge PR that gets this diff's sandbox change a security review.
🤖 Generated with Claude Code