Skip to content

fix: emit allowRead ro-binds before allowWrite re-binds in denyRead handler#269

Open
yehsuf wants to merge 1 commit into
anthropic-experimental:mainfrom
yehsuf:fix/bwrap-mount-ordering
Open

fix: emit allowRead ro-binds before allowWrite re-binds in denyRead handler#269
yehsuf wants to merge 1 commit into
anthropic-experimental:mainfrom
yehsuf:fix/bwrap-mount-ordering

Conversation

@yehsuf

@yehsuf yehsuf commented May 12, 2026

Copy link
Copy Markdown

Summary

Fixes a mount-ordering bug in generateFilesystemArgs() where allowWrite paths become read-only when an allowRead ancestor exists under the same denyRead region.

What changed

In src/sandbox/linux-sandbox-utils.ts, within the denyRead directory processing loop, swapped the order of the two re-mount loops:

Before:

  1. Re-bind allowWrite paths (--bind)
  2. Re-allow allowRead paths (--ro-bind)

After:

  1. Re-allow allowRead paths (--ro-bind)
  2. Re-bind allowWrite paths (--bind)

bwrap processes mounts in argument order. A parent-level --ro-bind hides child sub-mounts emitted earlier. By emitting read ro-binds first, write binds layer on top and remain writable.

Test plan

  • New test: denyRead + allowRead parent + allowWrite child — verifies write mount appears after read mount
  • Generated bwrap args place --bind after --ro-bind for overlapping paths

Fixes #263

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.

Linux bwrap: allowWrite paths become read-only when allowRead parent overlaps under a denyRead region

1 participant