Skip to content

fix(permissions): deny rules now take precedence over allowed_tools - #323

Open
sridhar-3009 wants to merge 1 commit into
HKUDS:mainfrom
sridhar-3009:fix/313-allowed-tools-bypasses-deny-rules
Open

fix(permissions): deny rules now take precedence over allowed_tools#323
sridhar-3009 wants to merge 1 commit into
HKUDS:mainfrom
sridhar-3009:fix/313-allowed-tools-bypasses-deny-rules

Conversation

@sridhar-3009

Copy link
Copy Markdown

Summary

Closes #313

PermissionChecker.evaluate() short-circuited to allowed=True when a
tool appeared in allowed_tools before evaluating either
path_rules deny entries or denied_commands patterns. This meant:

  • A path deny rule like */etc/* had no effect for any tool listed in
    allowed_tools.
  • A denied command pattern (e.g. rm -rf /) was also bypassed.

The fix moves the allowed_tools allow-check to after both deny
blocks, preserving the intended deny-wins semantics.

Before:

denied_tools → [early return False]
allowed_tools → [early return True]  ← bypassed path/command deny below
path deny rules
denied_commands

After:

denied_tools → [early return False]
path deny rules → [early return False if matched]
denied_commands → [early return False if matched]
allowed_tools → [early return True]

Test plan

  • Configure allowed_tools: ["bash"] + a path deny rule for */etc/*. Verify that bash with a file path under /etc/ is still denied.
  • Configure allowed_tools: ["bash"] + denied_commands: ["rm -rf *"]. Verify the command is denied even though bash is allowed.
  • Verify existing allow-list behaviour (tool in allowed_tools, no conflicting deny rule) still returns allowed=True.

Previously, if a tool appeared in allowed_tools, the permission check
returned True immediately — before evaluating path deny-rules or
denied_commands patterns. This meant a user could not restrict a
tool-path combination (e.g. allow bash everywhere but deny writes to
/etc/*) when the tool was also in the explicit allow list.

Move the allowed_tools short-circuit to after both the path deny-rules
and denied_commands checks, so deny always wins when a rule and an
allow-list entry conflict.

Fixes HKUDS#313
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.

[Bug]: allowed_tools bypasses denied_commands and path deny-rules (deny should take precedence)

1 participant