Repository navigation
feat(box): check native file permission changes with policy - #151
Conversation
## Problem Native filesystem policy checks selected file operations but does not yet check Unix permission changes. A selected workload can change permission bits within its filesystem grants without the additional Dogwood decision. ## Solution Kevin requested this deliberate extension of native filesystem checks. Subscribe to permission-change authorization and notification events, then map regular files and directories to existing fs:write / set_permissions requests. Keep the kernel target identity and use the existing checks before and after policy evaluation. Refuse unsupported target types and malformed paths or identities. An existing fs:write forbid can now deny chmod and fchmod from selected workloads. The change adds no configuration key, policy operation, stored record, or protocol field. Each permission change adds a policy evaluation and durable history records. Requested permission bits remain absent from the policy input. ## Tests permission_changes_obey_dogwood_for_files_directories_and_children pins chmod/fchmod allow and deny cases for files, directories, and children. permission_changes_preserve_selection_and_static_grants pins workload selection and static write grants. permission_changes_check_the_existing_object_and_policy_operation pins operation mapping and rejected identities/types. The controlled bridge check fails if the SETMODE subscription is removed or requested mode replaces target mode. The signed macOS 27.0.1 suite passed all 23 native tests and the C bridge test. All 17 adapter unit tests passed. Independent review reran both signed permission tests successfully. The deterministic suite reported GREEN: 121 passed, eight declared Linux-only skips. Formatting and just clippy passed with the repository's existing vendored lint allowances. The no-default-features build passed with one existing containment warning. just check stopped at two box_project startup timeouts, after 785 reported passes and four ignored tests. A focused rerun also timed out. Its child blocked while writing startup text to an undrained stderr pipe before launching the workload. No full workspace pass, hosted Linux result, or live agent validation is claimed.
|
Assessment: Approve (one non-blocking suggestion) Focused, well-scoped change that extends native macOS enforcement to permission changes by reusing the existing Review notes
Nicely layered tests make the enforcement behavior easy to trust. |
CI recorder shutdown repairCommit The test now accepts only the recorded early-close outcomes for an empty observation. It retains the positive control, stop/accept ordering, one incomplete observation, shutdown deadline, peer-closure check, and empty handler/active-stream checks. No product code, timeout, test selection, or permission behavior changed. Validation:
The unchanged PR head had already passed the failed-job retry. This commit addresses the reproduced recurring test race; hosted checks for the new head are being collected separately. Existing native-feature validation and human ownership limits remain as documented above. |
|
Re-review @ The only delta since my last pass is the test-only commit "accept sockets closed before the recorder first read" touching On the test change itself ( Assessment: Approve (unchanged). The earlier non-blocking suggestion on |
Linux Cargo fixture follow-upAfter the recorder repair, the new hosted run exposed an interaction between merged #129 and #136. Synchronized the branch with main without rewriting history. Commit The complete Linux Cargo case passed as the ordinary test user against the cached Linux Box runtime. Removing only the added read grant reproduced the exact hosted refusal. An independent reviewer repeated both controls and passed scoped build, containment-test compilation, warnings-denied lint, formatting, and no-default-features build. This is fixture validation against a cached runtime; the new hosted run supplies current-product coverage. The preceding macOS deterministic job already passed with the recorder fix. New-head hosted checks are now running. |
|
Re-review @ The only delta is the test-only commit "grant explicit reads of the Linux Cargo home" — a one-line change in The change is correct and well-scoped: Assessment: Approve (unchanged). The earlier non-blocking suggestion on |
Final hosted validationHead
The recorder fix preserves the shutdown deadline, and the Cargo fix grants read access only to the already-writable test Cargo home. Neither change relaxes permission refusal assertions. Existing signed-native evidence, human ownership attestation, and release qualification limits remain unchanged. |
Human readable section
Problem: Native file checks cover selected operations, but they do not yet ask policy before changing Unix file permissions.
A filesystem write grant can therefore permit these changes without the additional Dogwood check.
Solution: For selected workloads, check permission changes on regular files and directories through the existing
fs:writeaction andset_permissionsoperation.This includes
chmodandfchmod, which changes permissions through an open file descriptor.A denial prevents the change. A permit remains subject to the sandbox grants and other operating system checks.
Trade-off: Permission changes now add policy evaluations and durable history records.
A policy that forbids these changes can now stop build tools that make generated files executable.
The policy receives the path and operation, but cannot inspect the requested permission bits.
The feature remains experimental and uses the existing workload selection.
Description
Subscribe to Endpoint Security permission-change authorization and notification events.
Decode the target's existing file type and identity, then use the existing path checks before and after policy evaluation.
Refuse unsupported target types and malformed paths or identities.
This deliberately extends native policy checks, as requested by the operator.
It adds no configuration field, policy action, operation enum, stored record, or protocol field.
FAQ
Which Dogwood policy matches this?
The action is
Box::Action::"fs:write". The operation isBox::FsWriteOperation::"set_permissions".A policy can forbid permission changes while other permitted writes continue:
This rule grants nothing. Existing permit rules still determine which other requests succeed.
Does this check every filesystem operation?
No. Attribute changes, timestamps, links, copies, and metadata reads need their own event mappings and compatibility tests.
A missing Dogwood mapping does not establish that the sandbox permits the operation.
This change does not revoke access through an already-open file or address loss of interception after the trusted process dies.
Related Issues
Related to #117. That issue tracks broader failure behavior and remains open.
Type of Change
New feature
Testing
Tested on macOS 27.0.1, ARM64. The code and tests match commit
3f841c0.The signed run used base
250ca537plus this code change; later edits changed documentation only.macos_enforcementfilter. The broader Box unit run reported 609 passes.just clippypassed. Separate native-package formatting and strict clippy passed.cargo build -p strands-box --no-default-featurespassed with one existingcontainment::render_profiledead-code warning.just checkfailed in twobox_projectstartup tests. It reported 785 passes and four ignored tests before stopping. Later suites did not run.The two failed tests are
a_run_on_a_running_box_is_refused_before_it_touches_an_aliasanda_policy_edited_during_a_run_governs_the_next_run_and_not_the_running_one.Both wait for a startup file without reading their child's output pipes.
A focused rerun reproduced the timeout. A stack sample showed the child blocked in
__eprint/writebefore launching the workload.The first test also failed against a build with native interception compiled out.
This isolates that timeout from the added SETMODE handler. The test-harness repair is outside this PR.
The existing committed signed receipt covers an older source snapshot; its freshness check is informational.
The fresh local signed suite and independent rerun supply the permission-change evidence above.
No fresh model-driven agent run or standard release qualification is claimed. Current-head hosted results appear in the CI repair sections below.
just check, orcargo test --workspace --all-features)cargo fmt --allandcargo clippy --workspace --all-targets --all-features -- -D warningsThe strict-clippy checkbox remains unchecked because
CONTRIBUTING.mdprescribesjust clippywith existing vendored lint allowances. That recipe passed.CI recorder shutdown repair
Commit
c3b9394d16869fe84b86b91cebf16d8a4bda2fd0corrects the host-recorder test that failed the macOS deterministic job. The existing test assumed a queued byte had been read beforestop()shut down the accepted socket. macOS can instead refuse the handler's timeout option with error 22, or return end-of-stream before any byte is read. I reproduced the exact CI failure on the fifth focused run of an existing harness with byte-identical recorder source, without the permission-change feature.The test now accepts only the recorded early-close outcomes for an empty observation. It retains the positive control, stop/accept ordering, one incomplete observation, shutdown deadline, peer-closure check, and empty handler/active-stream checks. No product code, timeout, test selection, or permission behavior changed.
Validation:
The unchanged PR head had already passed the failed-job retry. This commit addresses the reproduced recurring test race; the final hosted results and timing-test retry are recorded below. Existing native-feature validation and human ownership limits remain as documented above.
Linux Cargo fixture follow-up
After the recorder repair, the new hosted run exposed an interaction between merged #129 and #136.
CN-W-06writes its test-owned Cargo home but omitted that directory from its read roots. Linux correctly refused that unsupported write-only grant before Cargo ran. The failure was separate from the native permission-change feature.Synchronized the branch with main without rewriting history. Commit
008ec573a865acb3349b179d1aa2d1e27409894cadds the exact Cargo-home path to the fixture's read roots. It changes one line and retains every compilation, execution, read-only-write refusal, ungranted-program refusal, protected-config refusal, and undeclared-output assertion.The complete Linux Cargo case passed as the ordinary test user against the cached Linux Box runtime. Removing only the added read grant reproduced the exact hosted refusal. An independent reviewer repeated both controls and passed scoped build, containment-test compilation, warnings-denied lint, formatting, and no-default-features build. This is fixture validation against a cached runtime; the new hosted run supplies current-product coverage.
Final hosted validation for
008ec573a865acb3349b179d1aa2d1e27409894c: all executed checks passed, including Linux and macOS Rust suites, native macOS tests, lint, both deterministic suites, CodeQL, and CI Gate. Linux recorded 120 passes and nine declared skips; macOS recorded 121 passes and eight declared skips. Both recorded all 129 expected cases.The unrelated catalog timing test failed the first macOS unit attempt at ratio 3.31, then passed the unchanged-head retry at 1.77 against the same limit of 3. No benchmark threshold or test selection changed. This clears the current failure, but does not permanently fix the shared timing instability also seen on #152. Final test and check evidence.
Checklist
Codex prepared this change and reviewed the code. Kevin confirmed the author ownership checklist item.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.