Skip to content

fix(box): state the full FSEvents reach in the file-watching warning - #484

Merged
pgrayy merged 3 commits into
strands-agents:mainfrom
pgrayy:fix-file-watching-disclosure-reach
Nov 17, 2026
Merged

pgrayy merged 3 commits into
strands-agents:mainfrom
pgrayy:fix-file-watching-disclosure-reach

Conversation

@pgrayy

@pgrayy pgrayy commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Summary

The file-watching = true warning names denied-name and event-metadata disclosure. The same FSEvents grant reaches three more things:

  • the host-wide event count, which reflects activity by other users and boxes;
  • each volume's history identifier;
  • for a root process, deletion of any volume's event history.

This fixes the warning and the user docs to state all three. The deletion is stated as the one exception to "file-content and write restrictions still apply", so the line no longer contradicts itself for root.

Whether Box should accept this reach for root, or refuse file-watching at euid 0, is a maintainer decision. This PR does not touch docs/design/decisions.md. That choice will come separately through /kd.

Changes

  • crates/box/src/run/contain/boundary.rs: widen file_watching_disclosure. It is the one owner of the line, so the startup and process-start output stay in sync.
  • docs/user/config.md: the file-watching section and its example output.
  • docs/user/security.md, docs/design/architecture.md, docs/design/containment.md: the same cost, in each page's own form.
  • docs/user/config.md, docs/user/mcp.md, docs/user/getting-started.md: rename the "metadata limitation" links, since the section now covers a deletion too.
  • crates/containment/README.md, crates/box/README.md, and the doc comments on allow_file_watching and ProcessSpec::file_watching: the same cost.

New warning:

strands-box: [tool.dev] file watching: macOS FSEvents may disclose denied names and event metadata, including outside the workspace and from past events, as well as the host-wide event count and each volume's history identifier; file-content and write restrictions still apply, except that a root process can delete any volume's event history

Evidence

Measured on macOS 26.7.3, arm64, with a throwaway APFS image. The box held only a metadata (stat) grant on the image's volume.

user file-watching bootstrap_look_up purge .fseventsd log files
503 absent 1100 0 kept
503 true 0 0 kept
0 absent 1100 0 kept
0 true 0 1 all deleted
0 outside a box (control) 0 1 all deleted

fseventsd defines seven routines, messages 66000 to 66006. Only 66005, FSEventsPurgeEventsForDeviceUpToEventId, changes host state.

Seatbelt can filter messages to a mach service by message number. WebKit's com.apple.WebProcess.sb does this for com.apple.system.notification_center. But sandbox_apply refuses any apply-message-filter without the private entitlement com.apple.private.security.message-filter. Box can't hold that entitlement, so it can't grant watching and refuse only the purge.

Testing

  • cargo test -p strands-box --all-features --lib file_watching_follows_only_the_selected_process: pass.
  • cargo test -p strands-box --all-features --test file_watching (4 tests, real box with live FSEvents): pass.
  • cargo test -p strands-box --test site_manifest --locked --all-features: pass.
  • cargo fmt -p strands-box -- --check: clean.

… file-watching warning

The file-watching startup warning named denied-name and metadata disclosure
but not three further reaches the same FSEvents grant carries: a host-wide
count of filesystem activity (readable across other users and boxes), each
volume's history-database identifier, and the root-only routine that deletes
a volume's recorded event history.

Widen file_watching_disclosure to name all three, and update the config
reference, the decision record, and the containment design doc to match. The
warning keeps its single owner, so the startup and process-start lines stay in
sync.

Verified on macOS by measurement. In a box with file-watching = true and no
content grant on the target volume, a root workload purged the volume's
recorded history (history replay dropped to empty and every on-disk log file
was removed), while a non-root workload was refused by the service. Seatbelt
carries no per-message filter for a mach service, so the connection is
all-or-nothing and the service's own root check is the only gate on the purge.
Comment thread docs/design/decisions.md Resolved
Comment thread crates/box/src/run/contain/boundary.rs Resolved
@github-actions

Copy link
Copy Markdown

Assessment: Request Changes

It is correct to make the warning wider. But the root history purge is a write outside every grant, not a disclosure. The PR records it as an accepted cost without a maintainer decision, and the new line still says that write restrictions apply.

Review Categories
  • Correctness of the disclosure: For a root box, the warning's tail clause now contradicts the reach it names.
  • Premises and decisions: The file-attributes precedent covers only widening within the workload's own grants. Accepting this reach is a /kd decision for the user, not a docs edit.
  • Doc coverage: Not every page that states the file-watching cost is updated. This includes architecture.md, which doc-updates.md requires for a stderr-disclosure change.

Checked and held: The warning text keeps one owner (file_watching_disclosure, used by the startup lines and command/run.rs). The config.md example matches the code. No box.toml key, record version, or Cargo.lock change. Linux is unaffected. The non-root case is described correctly ("as root" is conditional).

The measurement work behind this, especially the non-root refusal check, is clear and useful.

…strictions

Address review on the file-watching warning:

- The warning named the root history deletion, then said write restrictions
  still apply. State the deletion as the one exception to those restrictions.
- Revert the decisions.md edit. Accepting this reach is a maintainer decision.
- Carry the same wording to every page that states the cost: config.md,
  security.md, architecture.md, and containment.md.
- Rename the "metadata limitation" links, since the section now covers a
  deletion too.
@pgrayy pgrayy changed the title fix(box): disclose the host counter, volume id, and root purge in the file-watching warning fix(box): state the full FSEvents reach in the file-watching warning Nov 17, 2026
@pgrayy

pgrayy commented Nov 17, 2026

Copy link
Copy Markdown
Member Author

Thanks for the review. a41812e addresses all three points:

  • The warning states the root deletion as an exception to the write restrictions.
  • decisions.md is reverted. The root question goes to a maintainer through /kd.
  • Every page that states the cost is updated, including architecture.md and security.md. The "metadata limitation" links now read "limitations", since the section also covers a deletion.

One correction to my first description: Seatbelt can filter messages to a mach service, as WebKit's com.apple.WebProcess.sb does. It needs the private entitlement com.apple.private.security.message-filter, so Box can't use it. The description now says so.

@github-actions

Copy link
Copy Markdown

Assessment: Approve (for a41812e)

a41812e resolves both blocking findings from the earlier review. The warning now states the root deletion as the exception to write restrictions. decisions.md is no longer in the diff, and the root accept-or-refuse choice is deferred to /kd. One non-blocking item remains: four places that state the file-watching cost are not updated (see the file-level comment on docs/user/config.md).

What I checked
  • Cases for the new line:
    • Non-root box: correct. The measurement shows that the service refuses the purge.
    • Root box: correct. The deletion is now an explicit exception.
    • Unstarted stdio MCP server: correct. The same file_watching_disclosure owns that line.
    • Linux: no line, which is correct.
  • Rules that held:
    • The warning text has one owner.
    • The config.md example matches the code.
    • doc-updates.md requires architecture.md for a stderr-disclosure change, and it is now updated.
    • No decision entry is edited without a user decision.
    • No box.toml key, record version, or Cargo.lock change.
    • History is preserved: a41812e is a new commit on 6bfc2d1.
  • Ran: cargo fmt -p strands-box -- --check passes. cargo test -p strands-box --all-features --lib file_watching passes on Linux (2 tests) after building strands-box-contain-trampoline. I did not run the macOS --test file_watching suite.

The measurement table and the analysis of the apply-message-filter entitlement make the "disclose, don't filter" choice easy to follow.

@pgrayy

pgrayy commented Nov 17, 2026

Copy link
Copy Markdown
Member Author

/strands review In your approval of a41812e you said four places that state the file-watching cost are not updated, and pointed to a file-level comment on docs/user/config.md. That comment was not posted. Please name the four places, with file and line.

@github-actions

Copy link
Copy Markdown

You're right. My file-level comment on docs/user/config.md was not posted, and the earlier one on that file was not posted either. Sorry for pointing you to a comment that does not exist. Here are the four places, checked at a41812e:

Suggestion (non-blocking): These four places still state only the name and metadata disclosure. They omit the host-wide event count, the volume history identifier, and the root deletion.

  1. crates/containment/README.md:114-116 ("macOS Profile"): "FSEvents can disclose denied names and event metadata, including outside the granted paths and from past events. The caller must disclose that cost when selecting it. Direct filesystem and other service rules do not change." This text sets the disclosure duty for callers of ContainmentConfig::allow_file_watching, so the cost it names should match file_watching_disclosure.
  2. crates/containment/src/config.rs:177, the rustdoc on allow_file_watching: "Permit macOS FSEvents, which can disclose denied names and event metadata."
  3. crates/box/README.md:131-132: "It can disclose denied names and event metadata, so Box prints that limitation at startup."
  4. docs/user/config.md:538-539, the note after the [agent.filesystem] list table: "permits an event stream that can disclose denied names and activity despite these direct-access restrictions."

There is also one internal doc comment with the same gap, if you want to update it too: crates/box/src/record/config/process.rs:25, "Permit macOS FSEvents, including possible disclosure of denied names and event metadata."

Suggestion: Add the clause the other pages now use to each one: "…, the host-wide event count, and each volume's history identifier; a root process can also delete any volume's event history." For item 1, also change "Direct filesystem and other service rules do not change" so that it does not read as "no write reach is added".

My approval stands. None of these blocks the merge.

The review named four more places that stated only name and metadata
disclosure, plus one internal doc comment. Add the host-wide event count, the
volume history identifier, and the root deletion to each:

- crates/containment/README.md, which sets the caller's disclosure duty. Also
  say that the deletion is the one change to filesystem rules.
- crates/containment/src/config.rs, on allow_file_watching. The private
  field's doc now points to that method instead of repeating the cost.
- crates/box/README.md
- docs/user/config.md, after the filesystem list table
- crates/box/src/record/config/process.rs
@github-actions

Copy link
Copy Markdown

Assessment: Approve (for a7c2fa5)

a7c2fa5 covers all four places from my last comment, plus process.rs. Every statement of the file-watching cost now matches file_watching_disclosure. The one exception is docs/design/decisions.md, which is correctly left for the /kd decision. I have no open findings.

What I checked
  • New text:
    • crates/containment/README.md now states the root deletion inside the caller's disclosure duty. "Apart from that deletion, filesystem and other service rules do not change" is accurate.
    • The allow_file_watching rustdoc, crates/box/README.md, config.md:540, and process.rs state the same reach.
    • The private file_watching field now points to allow_file_watching, so the cost is written in one place in that crate.
  • Search: I grepped crates/ and docs/ for "event metadata", "denied names", and "metadata limitation". The only stale match left is decisions.md, and that is intended.
  • History: a7c2fa5 is a new commit on a41812e, with no force-push.
  • Ran:
    • cargo fmt -p strands-box -p strands-box-containment -- --check passes.
    • cargo test -p strands-box --all-features --lib file_watching passes on Linux (2 tests) after building the trusted binaries.
    • I did not run the macOS --test file_watching suite.

@pgrayy
pgrayy enabled auto-merge (squash) November 17, 2026 17:36

@kevin-orellana kevin-orellana left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed a7c2fa5. No blocking findings in the warning and documentation changes. Acceptance of root file-watching behavior remains a separate maintainer decision.

@pgrayy
pgrayy merged commit 8b5232b into strands-agents:main Nov 17, 2026
28 of 30 checks passed
@pgrayy
pgrayy deleted the fix-file-watching-disclosure-reach branch November 17, 2026 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area - Agent Containment bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants