Skip to content

Fixes from the owed security reviews: zen reads, agent home read-only, note topics - #587

Merged
lydakis merged 3 commits into
mainfrom
claude/project-thread-hue6af
Nov 1, 2026
Merged

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

Conversation

@lydakis

@lydakis lydakis commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

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_in now opens the file with O_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 that sonny zen works 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. ~/.agent stays 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 rewrite config.toml, which sets every bot's sandbox. PROTECTED already covered ~/.agents and ~/.codex in 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-path flag, 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 topic goes into the agent's note unquoted, and Event::parse let 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 .jsonl files whose names pass valid_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.toml and env cannot be written, while a file in HOME and the given zen folder can.
  • The lookout parse test now checks that a topic with a newline is dropped.
  • cargo clippy --workspace --all-targets -D warnings is 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

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
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 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-01T06:28:05.993500Z db4f890 New commits
🔒 Security Review ✅ Completed 2026-11-01T06:20:14.091278Z abb4482 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.

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
@lydakis lydakis changed the title Sonny: read zen focus files only when plain, small and not a link Fixes from the owed security reviews: zen focus reads, agent home read-only Nov 1, 2026
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
@lydakis lydakis changed the title Fixes from the owed security reviews: zen focus reads, agent home read-only Fixes from the owed security reviews: zen reads, agent home read-only, note topics Nov 1, 2026
@lydakis
lydakis merged commit fcdf727 into main Nov 1, 2026
10 checks passed
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