Repository navigation
feat(box): add opt-in policy checks for native file operations on macOS - #112
kevin-orellana merged 5 commits into
Conversation
…acOS ## Problem Direct filesystem calls inside contained workloads bypass Dogwood policy. Filesystem reach grants cannot apply history-based rules to these calls. ## Solution This adds global, explicit native filesystem policy selection on macOS. Selected open, create, unlink, rename, and truncate requests use the existing policy engine and durable history. Containment remains a separate restriction. Enable the Cargo feature `native-filesystem-policy`, then set: ```toml [experimental-features] native-filesystem-policy = true ``` The feature requires macOS 27, its SDK, and a signed executable with Apple's Endpoint Security entitlement. Standard release artifacts exclude it. Missing support refuses startup before workload launch or record changes. The trusted launcher waits until Box registers the workload's process identity. Trusted bootstrap reads stay outside workload policy. Descendants remain tracked across forks and executable changes. Shutdown terminates tracked descendants and bounds callback draining. Disabled records retain version 21. Enabled records require version 22. Older binaries reject unsupported records. Disable the feature using a compatible build before returning to a version-21 binary. This is the core part of strands-agents#107. Per-workload selection and real-agent workloads are separate dependent drafts. The unrelated socket shutdown test fix remains outside these three feature changes. The adapter, trusted launch path, startup refusal, lifecycle cleanup, and signed tests stay together because they establish one enforcement boundary. Splitting these pieces would expose an incomplete safety contract. Limits remain explicit: already-open descriptors and mapped memory are not checked on every read or write. Kernel denials expose an operating-system error; structured details appear in Box diagnostics. This adds no asynchronous history writes or durability option. ## Tests Fresh macOS 27 validation passed: 13 signed integration tests, 16 adapter tests, 133 configuration tests, 11 native unit tests, three startup tests, one launcher handshake test, and 11 policy path tests. The receipt verifier's three tests passed. `trusted_launcher_reads_are_not_workload_requests` fails against the old defective signed binary and passes against this build. `direct_open_truncate_and_grandchild_obey_dogwood` covers direct and descendant denial. `native_history_changes_the_next_decision_without_a_cached_allow` covers history-sensitive decisions. Formatting and clippy passed for the changed Rust packages and standalone signed test package. Clippy used the repository's established allowances. The checked-in receipt records this candidate's full signed suite and source hashes. Continuous integration checks receipt freshness; it does not run Apple's signed enforcement tests. The full workspace suite was not rerun for this split. Earlier strands-agents#107 testing found an intermittent catalog-scaling timing failure. This PR does not claim that the full suite is green. Linux and older macOS runtime tests were not rerun locally.
|
Issue: The security-critical fail-closed paths in the bridge — the Suggestion: This is acceptable for an experimental, feature-gated path, but please file a tracking issue (or reference #113/#114) for these deny-path tests and gate any promotion out of experimental on them, since a silent regression here would fail open. |
|
Issue: The repository's stated pre-push gate (README/ Suggestion: Run the workspace all-features clippy on macOS (where the bridge compiles) and confirm it is clean before merge, so the new code is covered by the same lint bar as the rest of the workspace. |
Review SummaryAssessment: Comment Well-engineered, carefully Review themes
The split rationale (startup + file checks + shutdown as one atomic unit, with #113/#114 deferred) is reasonable despite the overall size. Nice work on the enforcement model and its documentation. |
ferdingler
left a comment
There was a problem hiding this comment.
Looks great overall! Left a minor comment about improving the launch protocol so that supervise.rs owns the entire set of registration steps rather than making the call sites own some of them.
Re-review Summary (updated)Assessment: Comment — only the governance gate remains. The author has addressed every code-level item from my earlier review, verified against the latest revision:
Remaining blocker (not resolvable by the author): the frozen-surface expansion — the 9th Nice turnaround on the fixes, and #117 is a thorough release-gating checklist for the experimental surface. |
|
The review fixes are pushed. The description records the exact tests and current limitations. In response to the missing failure tests, the bridge now has controlled-response tests for overflow, expired deadlines, and shutdown errors. Real kernel overload, process failure, and API-guarantee confirmation remain tracked in #117. These remain requirements before proposing standard release support. I ran the requested workspace Clippy command. It fails on existing containment and vendored Shell warnings. The containment warning reproduces at base The configuration approval note records author approval, not maintainer approval. The repository does not define the suggested The CI trigger now includes the review staging branch. The |
Description
This PR targets
main. The upstream branchfeature/native-filesystem-coremirrors this PR for review of #113 and #114.Keep that branch synchronized with this PR when core changes. After this PR merges, move both dependent PRs to
mainbefore merging them.An agent or tool can open files directly without a Dogwood policy check. Box's sandbox restrictions still apply.
This new feature adds Dogwood checks to native file operations: open, create, remove, rename, and truncate.
It is available in experimental mode. Truncate means shorten a file.
It uses Box's existing policy engine and history.
Enable the
native-filesystem-policyCargo feature when building Box, then add this tobox.toml:The build needs the macOS 27 Software Development Kit (SDK) and Apple's Endpoint Security entitlement.
That entitlement permits Box to receive and answer kernel authorization requests.
Run it on macOS 27 or later. Standard Box releases do not include this feature yet.
See the build and signing guide.
Approval for the configuration change
Kevin Orellana explicitly approved the new
experimental-featuresconfiguration key and saved-record format version 22 during development. He reconfirmed that approval on October 16, 2026.This records author approval. Maintainer approval remains subject to PR review.
Without the feature, saved records remain at version 21. Enabling it uses version 22, which older binaries reject.
FAQ
Can I enable this through TOML alone?
Only with a compatible signed build. The Cargo feature includes the code. The TOML setting enables it.
An absent setting or
falsekeeps it disabled.What happens if my build or operating system cannot support it?
Box refuses to start the workload. It leaves the stored configuration unchanged.
Does this replace sandbox restrictions?
No. The sandbox still limits which paths the workload can access.
Dogwood adds policy decisions, including rules that depend on earlier events. Both checks must allow access.
Does it check every read and write?
No. A file descriptor is a process's handle to an open file.
Later access through that handle can occur without another policy check. This feature does not revoke existing handles or check every filesystem operation.
Does an allow decision prove that the file changed?
No. It means Box allowed the request, not that the operation completed.
The history records that uncertain result as
indeterminate.When Box denies a request, the program receives an operating-system error. Box logs explain the policy denial.
Does this change policy history or reuse earlier decisions?
History still persists on disk across restarts. Each intercepted request gets a fresh policy decision.
Reusing an earlier allow could miss a change in policy history. Repeated checks add processing and storage work.
What happens to child processes?
Box registers each workload before letting it run. Children retain its checks after creating another process or executing another program.
Normal shutdown terminates tracked children, including detached children. Enforcement after a sudden Box crash still needs validation.
Can I return to an older Box binary?
Enabled boxes use stored configuration version 22. Disabled boxes retain version 21.
Older binaries refuse versions they do not support.
Set the feature to
false, then run once with the compatible build before returning to a version-21 binary.That run retains policy history. Per-workload settings and version 23 belong to #113.
Why keep startup, file checks, and shutdown in one PR?
Box must track a workload before it runs and keep checking it until shutdown.
Startup, file checks, and shutdown must merge together.
Separate upstream PRs add per-workload settings and agent tests.
Related Issues
Split from #107. The unrelated socket shutdown test fix remains outside these three feature PRs.
Type of Change
New feature, available in experimental mode.
Testing
The branch includes current
mainand its macOS signing metadata. The signed build and receipt were refreshed after that merge.On October 16, the revised signed build passed 16 native integration tests plus one bridge test target on macOS 27.0.1.
The receipt matches the current production code and relevant test sources.
Commands, results, and remaining limits
cargo test --manifest-path test-native-filesystem/Cargo.toml --locked -- --test-threads=1, withSTRANDS_BOX_SIGNED_TEST_BINARYset: 17 tests passed.cargo test --release --locked -p strands-box --all-features --bin strands-box macos_enforcement: 16 passed.cargo test --release --locked -p strands-box --all-features --bin strands-box record::config::: 133 passed.cargo test --release --locked -p strands-box-containment --all-features launch_gate: one passed.-D warnings.cargo fmt --alland standalone package formatting passed. Changed Box packages passed Clippy with the existing CI allowances.The bridge tests substitute operating-system responses. They do not prove real kernel behavior under overload or process failure.
A negative-device regression test fails against the previous bridge and passes after the conversion fix.
A local callback probe observed 2,048 events from 16 children, with at most one callback active. This does not establish a universal API guarantee.
Remaining kernel tests and explicit descendants-client guarantee confirmation are tracked in #117.
The full workspace test suite and live model runs were not repeated. Earlier testing found an intermittent catalog-scaling timing failure.
Local Linux cross-compilation stopped in the
ringdependency becauseaarch64-linux-gnu-gccis unavailable. Linux CI remains necessary.CI now also runs for PRs targeting
feature/native-filesystem-core. Signed runs remain manual. CI checks the receipt's source hashes.cargo fmt --allandcargo clippy --workspace --all-targets --all-features -- -D warningsFormatting passed. The exact workspace Clippy command ran and failed on existing warnings, including
chunks_exact_to_as_chunksin containment and vendored Shell warnings.The containment failure also reproduces at base commit
bd85785. The flagged Shell source is unchanged from that base.The checkbox remains unchecked. Changed Box packages pass with the repository CI workflow's existing lint allowances.
Checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.