Skip to content

fix(box): refuse mutations of box directory ancestors - #123

Merged
kevin-orellana merged 2 commits into
strands-agents:mainfrom
ferdingler:fdingler/refuse-box-ancestor-mutations
Oct 21, 2026
Merged

kevin-orellana merged 2 commits into
strands-agents:mainfrom
ferdingler:fdingler/refuse-box-ancestor-mutations

Conversation

@ferdingler

@ferdingler ferdingler commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Box rejects changes to its own directory, but the same check lets changes to a parent directory through. That leaves a gap in the protection of Box's internal files.

I added the missing refusal for parent directories. The change keeps reads of those directories and changes to unrelated siblings working.

Related Issues

Type of Change

Bug fix

Testing

I checked the fix on macOS and Linux: all six targeted tests pass, and the two ancestor tests fail without the fix. Builds and formatting pass with no new lint warnings; full package and integration suites have not run.

  • I ran the relevant suites (just check, or cargo test --workspace --all-features)
  • If I touched Rust, I ran cargo fmt --all and cargo clippy --workspace --all-targets --all-features -- -D warnings

Checklist

  • I have read the CONTRIBUTING document
  • I have reviewed and understand every line of code in this PR, including any generated by AI tools, and I can explain why it works
  • My change is focused and reasonably small; I have split unrelated work into separate PRs
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • My changes generate no new warnings

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

## Problem

The private-state floor refuses the box directory and its descendants, but accepts mutations of its parent directories. The parent_mutation_is_refused and grandparent_mutation_is_refused regressions fail on the baseline.

## Solution

Apply the existing ancestor comparison to the private-state floor for mutations. No interface changes. The six private_tree_mutation_tests cover parent and grandparent refusal, protected-root and descendant refusal, and accepted sibling mutations and non-mutating ancestor access.

## Tests

All six private_tree_mutation_tests pass on macOS arm64 and Linux arm64. All-feature builds and formatting pass on both. The Linux no-default-features build also passes. Clippy adds no warnings; macOS retains the baseline hosted.rs::tool_spawner warning. Adversarial review found no introduced defect. Full package and integration suites and end-to-end file access were not run.
@ferdingler
ferdingler marked this pull request as ready for review October 20, 2026 22:38
Comment thread crates/box/src/run/broker/reach.rs Resolved
Comment thread crates/box/src/run/broker/reach.rs Resolved
Comment thread crates/box/src/run/broker/reach.rs Resolved
@github-actions

Copy link
Copy Markdown

Assessment: Comment (approvable after minor follow-ups)

The fix closes a real gap: a mutation whose target is an ancestor of a forbidden root is now refused, reusing the established lies_within pattern already applied to authority sources in the same function. I verified the six new tests pass locally and that the reach.rs hash in signed-receipt.json matches the modified source. Logic is correct and the restriction is appropriately narrow (only the enclosing directory entries themselves, under mutation; reads and sibling writes stay allowed).

Review themes
  • Correctness: Sound. The new clause is gated on mutates, covers both string-prefix and on-disk-identity ancestor spellings, and stays beneath policy (applied last in approve_with_source_access).
  • Operator feedback: The reused floor message describes "open" only, while this branch is about changing an ancestor — see inline note suggesting wording that mirrors AUTHORITY_SOURCE's "open or change".
  • Testing: Strong for the string-prefix case; add a second-spelling (symlink/identity) ancestor-mutation test, since that is the branch the fix leans on. Two of the new tests duplicate existing floor coverage.
  • Safety premise: This touches the deny-floor that underpins why the box is safe. It strengthens protection (additive), but given the premise-freeze scrutiny gate in AGENTS/CONTRIBUTING, it warrants a maintainer's eye and confirmation it's pinned as a premise regression.

Nicely scoped, well-tested bug fix that follows the existing patterns in this module.

@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.

No actionable defects found. Verified that all six new tests passed in the macOS and Linux workflow logs. The signed-test receipt matches this revision. Local tests could not finish because the disk ran out of space.

@kevin-orellana
kevin-orellana merged commit 0f4dba6 into strands-agents:main Oct 21, 2026
24 of 25 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