Skip to content

Security review only (do not merge): #537 Commons replies through lookout subscriptions - #585

Closed
lydakis wants to merge 1 commit into
security-review/537-basefrom
security-review/537
Closed

lydakis wants to merge 1 commit into
security-review/537-basefrom
security-review/537

Conversation

@lydakis

@lydakis lydakis commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

Do not merge. This PR exists only so Codex runs a security review over what #537 landed (tracked in #531). Its open-time review covered 5ca89b7, but later commits went unreviewed. The base is the commit before #537 merged (30845ba^) and the head is the merge commit 30845ba. Once findings are fixed on main or filed, this PR gets closed and both security-review/537* branches are deleted.

What to look at:

  • The lookout runs outside the sandbox and reads ~/.agents/commons, which any agent writes. It turns posts into source notes that start other agents' turns. Check that a crafted thread or post can't name another agent, forge told, or escape the from/topic fields into the prompt.
  • Held events are kept in STORE.sources/.held/BOT.json.
  • A one-time upgrade::once migration writes subscriptions into each poster's STORE.lookout/BOT.json.

… take topics and a digest (#537)

The commons is a lookout source of Sonny's own. Posting or replying subscribes the poster (bound to its bot ID), and the agent can unsubscribe. Any source can carry topics (NAME:TOPIC) and a digest; the commons digest is [sonny] commons_digest, 1h by default. Attach notes are gone: paid invite holders are woken by tell() and left out of the source note. Untold events and the in-flight batch are held in STORE.sources/.held/BOT.json (owner-only), written off the event loop; a replayed batch the daemon already took still starts the digest. Agents that posted earlier are subscribed once by upgrade::once, which stays retryable on any read or listing failure.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGEfzPDBTQPwZUKy2bJ
@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:10:08.294172Z 30845ba PR opened
🔒 Security Review ✅ Completed 2026-11-01T06:11:04.186750Z 30845ba 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: 30845baff3

ℹ️ 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 on lines +626 to +627
if let Some(topic) = &event.topic {
what.push_str(&format!(":{topic}"));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Quote untrusted topics before inserting them into source notes

When a source supplies a topic containing an embedded newline, this interpolation inserts it verbatim into the model prompt, outside the JSON quoting used for the event's text and author. Event::parse rejects colons in topics but permits newlines, and the commons reader also accepts arbitrary .jsonl filenames without applying valid_name, so a crafted topic or commons filename can inject additional prompt lines. This defeats the note's intended quoted-as-data boundary. JSON-quote topics when rendering them, and validate commons thread names when reading files rather than relying solely on validation in the posting tool.

Useful? React with 👍 / 👎.

Comment thread sonny/src/commons.rs
Comment on lines +1218 to +1219
if std::fs::write(&partial, Value::Object(read).to_string()).is_ok() {
let _ = std::fs::rename(&partial, &path);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Persist pending notifications before advancing the commons cursor

If the lookout stops after this rename but before the subscriber's held events are written, the corresponding commons notifications are permanently lost. news advances read.json before returning the events; own subsequently sends them through an in-memory channel, and subscribers persist them only on a later tick through another asynchronous writer. On restart, the advanced cursor skips those posts even though no durable pending notification exists. Persist an outbox before advancing the cursor, or acknowledge cursor progress only after the notifications have been durably recorded.

Useful? React with 👍 / 👎.

lydakis pushed a commit that referenced this pull request 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 closed this Nov 1, 2026
lydakis added a commit that referenced this pull request Nov 1, 2026
…, note topics (#587)

* Read zen focus files only when plain, small and not a link

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

* Keep the agent's home read-only for bots whose folder holds it

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

* Keep line breaks and stray commons names out of a note's topic

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

---------

Co-authored-by: Claude <[email protected]>
lydakis added a commit that referenced this pull request Nov 1, 2026
… it (#592)

The commons source advanced read.json before the events it read reached
any subscriber's held file, so a crash in between lost those posts
(#589, from the #585 review). news() now returns the lines and the
cursor it would write; the source sends them, asks the lookout whether
every subscriber holds them on disk, and marks them read only on yes.
The lookout writes what it holds at once for the question and answers
when the writer is done; the writer keeps failed writes and tries them
again, answering no while any is unwritten. Read again after a crash,
an event a subscriber already holds is not held twice.

Crash-injection tests abort a child process at four steps (read, in
memory, on disk before the cursor, after the cursor) and check that a
restarted lookout holds each post exactly once.


Claude-Session: https://claude.ai/code/session_013jkdGG8Kwbo2wyYcT9yURQ

Co-authored-by: Claude <[email protected]>
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.

1 participant