Skip to content

feat: emit [SandboxDebug] fs_deny line for each Seatbelt file-* denial#224

Open
anonx3247 wants to merge 7 commits into
anthropic-experimental:mainfrom
Isara-Laboratories:feat/emit-fs-deny-debug-lines
Open

feat: emit [SandboxDebug] fs_deny line for each Seatbelt file-* denial#224
anonx3247 wants to merge 7 commits into
anthropic-experimental:mainfrom
Isara-Laboratories:feat/emit-fs-deny-debug-lines

Conversation

@anonx3247

Copy link
Copy Markdown

Summary

  • startMacOSSandboxLogMonitor already captures all Seatbelt violations (fs + network) from the macOS system log, but the callback only stored them in SandboxViolationStore — consumers reading srt's stderr (e.g. with SRT_DEBUG=1) never saw fs denials
  • Network blocks were already surfaced via logForDebugging in the proxy code; this PR brings fs denials to parity
  • One-line change: after callback(violation), calls logForDebugging(\fs_deny: ${violationDetails}`)so each file-* denial appears as a[SandboxDebug] fs_deny: ...` line on stderr

The [SandboxDebug] prefix and SRT_DEBUG guard are unchanged — fs denials are gated the same way all other debug output is.

Test plan

  • Run srt with SRT_DEBUG=1 under a restrictive profile and confirm [SandboxDebug] fs_deny: lines appear on stderr for blocked file reads
  • Confirm no [SandboxDebug] fs_deny: lines appear without SRT_DEBUG=1
  • Confirm network block lines are unaffected

🤖 Generated with Claude Code

anonx3247 and others added 7 commits April 15, 2026 17:47
Adds an opt-in allowAllDomains boolean to NetworkConfigSchema that flips
the proxy filter fallback from deny-all to allow-all. Unmatched hosts are
permitted unless they appear in deniedDomains, mirroring the filesystem
read pattern. Existing configs are unaffected (defaults to false).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Enables `npm install github:anonx3247/sandbox-runtime` to resolve
`main` / `bin` without a build step on consumer machines. Removes
`dist` from .gitignore and checks in the compiled TypeScript output
plus the vendored seccomp sources that prepublishOnly copies.

Fork tracks upstream 0.0.48 plus allowAllDomains (5f3ef74).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Without the executable bit, npm install github:anonx3247/sandbox-runtime
creates a symlink at node_modules/.bin/srt that shutil.which can't resolve.
tsc doesn't preserve +x on emitted files, so we have to set it post-build.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
When invoked as `srt -- cmd arg1 arg2 ...`, the CLI built the command
string by joining argv with a single space and then handed the result
to `spawn(cmd, { shell: true })`. Bash then re-parsed that string,
which corrupted any argument containing shell metacharacters
(parentheses, single/double quotes, backticks, `$`, `|`, `;`, etc.).

In practice this broke any caller that forwarded arbitrary user text
as a positional argument — for example, `srt -- claude -p "note (a)
with 'quotes'"` would fail with a bash syntax error rather than
running claude with that prompt.

The fix routes argv through `shellquote.quote`, which is the same
library already used elsewhere in this codebase to produce shell-safe
command strings. Each argv element is individually quoted so bash
re-parses it back to the original value.

The `-c` flag retains its current "no escaping" semantics by design —
that mode is for callers who want shell interpretation.

Regression tests cover parentheses, single quotes, backticks, literal
`$VAR`, and a combined realistic prompt argument.
Companion to the previous commit. The fork commits dist/ so that
`npm install github:anonx3247/sandbox-runtime` picks up changes
without a build step.
startMacOSSandboxLogMonitor already captures all sandbox violations from
the macOS system log, but the callback only stored them in
SandboxViolationStore — consumers reading srt's stderr (like cave with
SRT_DEBUG=1) never saw fs denials, only network blocks logged separately
by the proxy code.

After this change, each violation that reaches the callback also calls
logForDebugging with a `fs_deny: <violationDetails>` message.  The
[SandboxDebug] prefix and SRT_DEBUG guard are unchanged — fs denials are
gated the same way all other debug output is.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The sandbox log monitor (startMacOSSandboxLogMonitor) was never started
by the CLI because enableLogMonitor defaulted to false and was never
passed. Gate it on process.env.SRT_DEBUG so it activates alongside all
other debug output — callers that set SRT_DEBUG=1 (e.g. cave) now also
get [SandboxDebug] fs_deny: lines for Seatbelt file-* denials.

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.

1 participant