Skip to content

Add -deny flag to deny read access to specific paths#86

Open
youta1119 wants to merge 4 commits intoWarashi:mainfrom
youta1119:feature/support-deny-read-option
Open

Add -deny flag to deny read access to specific paths#86
youta1119 wants to merge 4 commits intoWarashi:mainfrom
youta1119:feature/support-deny-read-option

Conversation

@youta1119
Copy link
Copy Markdown

Summary

Closes #85

  • Add -deny <path> flag (repeatable) to deny read access to specific paths
  • Support deny key in config presets with the same eval-symlinks option as allow
  • Warn when a denied path does not exist at sandbox startup
  • Refactor AllowPath to PathSpec to reflect its use for both allow and deny entries

Platform behavior

macOS: Uses deny file-read-data in the sandbox-exec profile. The process receives a permission denied error when attempting to read a denied path.

Linux: Landlock LSM uses an allowlist model — it can grant access to specific paths but cannot explicitly deny reads. Therefore, when -deny is specified, cage falls back to bubblewrap (bwrap). Denied directories are hidden with a tmpfs mount; denied files are masked with /dev/null.

youta1119 and others added 4 commits March 24, 2026 09:27
Previously, both `subpath` and `literal` rules were emitted for every
allowed path. Now we emit only `subpath` for directories and `literal`
for files, which avoids redundant rules.

Also skip non-existent paths, consistent with the Linux behavior.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Closes Warashi#85

Add a `-deny <path>` flag (repeatable) to deny read access to specific
paths. On macOS, uses `deny file-read-data` in the sandbox-exec profile.
On Linux, falls back to bubblewrap (bwrap) since Landlock uses an
allowlist model and cannot deny reads.

The `deny` key is also supported in config presets, with the same
`eval-symlinks` option as `allow`. A warning is emitted when a denied
path does not exist at sandbox startup.

Also refactors AllowPath to PathSpec to better reflect its use for both
allow and deny entries.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The -deny flag on Linux requires bubblewrap (bwrap). Install it in CI
so that the e2e tests can run on Linux.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

Feature Request: Support explicit deny read option

1 participant