Skip to content

feat: deny unlink/rename inside write-allowed paths - #572

Open
tsumon wants to merge 1 commit into
anthropics:mainfrom
tsumon:fix/deny-unlink-inside-write-roots
Open

tsumon wants to merge 1 commit into
anthropics:mainfrom
tsumon:fix/deny-unlink-inside-write-roots

Conversation

@tsumon

@tsumon tsumon commented Sep 19, 2026

Copy link
Copy Markdown

Closes #545.

Write-allowed paths currently re-allow file-write-unlink / file-write-create so rm works in the project. There is no way to keep a subtree writable (.git has to stay that way for git) while blocking delete/rename. rm -rf .git then strips objects/refs/HEAD and leaves a directory that still looks like a repo.

Change

  • filesystem.denyUnlink: optional path list.
  • macOS: emit the existing move-blocking (deny file-write-unlink file-write-create …) block at the end of the profile so it wins over the write-root unlink re-allow. Specific unlink denies are not overridden by a later (allow file-write*).
  • Linux/Windows: reject a non-empty list at config parse. bwrap cannot deny unlink independently of write; a silent no-op would be worse than the gap.

Tests

bun test test/config-validation.test.ts test/sandbox/macos-seatbelt.test.ts --test-name-pattern denyUnlink

4 passed (macOS seatbelt runtime cases stay describe.if(isMacOS) and skip on this host).

Add filesystem.denyUnlink so a writable tree (e.g. .git) can still be
edited without allowing rm/rename. macOS seatbelt emits the existing
unlink+create deny last so it wins over the write-root re-allow.
Linux/Windows reject a non-empty list at config parse.

Closes anthropics#545

This branch has not been deployed

No deployments
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.

filesystem: allow unlink/rename to be denied inside write-allowed paths

1 participant