Fix #274: ToolContext no longer defaults to bypassPermissions#305
Open
ericleepi314 wants to merge 2 commits into
Open
Fix #274: ToolContext no longer defaults to bypassPermissions#305ericleepi314 wants to merge 2 commits into
ericleepi314 wants to merge 2 commits into
Conversation
…ns (#274) The implicit bypassPermissions default silently disabled the workspace-root allowlist for every caller that didn't pass an explicit permission_context (SDK embedders, tests, the TUI fallback context). - ToolContext.permission_context now defaults to mode="default" - TS parity: read-only tools auto-allow in has_permissions_to_use_tool (the port was missing the checkReadPermissionForTool -> allow path, so flipping the default would have ask->denied every Read/Glob/Grep) - Write/Edit check_permissions no longer swallow the allowlist ToolPermissionError into passthrough; the inner permission flow re-raises it so out-of-workspace writes fail hard instead of soft-denying through the ask path - security_review's shell-preprocessing context passes an explicit bypass (it intentionally matched the old implicit default) - tests that relied on the implicit bypass now pass an explicit bypass context or a real PermissionAskReply handler; two stale tuple-shape handlers updated to the live protocol Closes #274, closes #168 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…n gating (#274) Review follow-ups: the read-only auto-allow only applies when the tool's own check_permissions expressed no opinion, so a read-only tool's ask survives (TS shape: the read-only allow lives inside checkPermissions). WebFetch now returns allow for preapproved hosts and a real ask otherwise — without this, the auto-allow turned the old no-op check_permissions into a silent allow for arbitrary URLs. check_rule_based_permissions mirrors the allowlist re-raise, and the CheckPermissionsTool protocol declares is_read_only. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This was referenced Jun 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #274
Closes #168 (duplicate)
Summary
ToolContext.permission_contextdefaulted tobypassPermissions, silently disabling the workspace-root allowlist for every caller that didn't pass an explicit context (SDK embedders, tests, the TUI fallback context). The two parity tests guarding the allowlist were red on main because of it.Core changes
mode="default"(src/tool_system/context.py)has_permissions_to_use_tool_inner: the port was missing thecheckReadPermissionForTool → allowpath, so the new default would have ask→denied every Read/Glob/Grep in handler-less contexts. Gated on the tool's owncheck_permissionsreturning passthrough — a read-only tool's own ask survives. Deny/ask rules still run first.check_permissionsno longer swallowToolPermissionErrorinto passthrough; the permission flow re-raises it so out-of-workspace writes raise instead of soft-denying through the ask path. Production dispatch callers wrap inexcept Exception→ error tool result (audited: query loop, REPL, headless, hooks paths).check_permissionsinto a silent allow for arbitrary URLs (found in critic review).security_review.pyshell preprocessing keeps its intentional bypass, now explicit.Call-site audit (per the issue's fix sketch)
setup_permissions— unaffected.PermissionAskReplyhandlers; two stale tuple-shape handlers (dead code under the old default) updated to the live protocol.Behavior matrix (verified)
callToolPermissionErrordontAsk)Test plan
test_write_outside_workspace_blocked/test_read_outside_workspace_blockednow pass🤖 Generated with Claude Code