[Bug]: quoted find predicates ("-delete", '-exec') bypass the mutating-find guard and stay auto-ALLOWed
Prerequisites
- I have searched the existing issues and discussions and this is not a duplicate.
- This is a bug, not a usage question.
Description
BashCommandParser._is_mutating_find_command() (src/agentscope/tool/_builtin/_bash_parser.py, _is_mutating_find_command, line 248 on e101864) detects mutating find predicates by scanning tree-sitter child nodes whose node type is word:
for child in cmd_node.children:
if child.type == "word":
text = child.text.decode("utf8")
if text in FIND_MUTATING_PREDICATES:
return TrueIn the tree-sitter-bash grammar, however, quoted arguments are string / raw_string nodes, not word nodes. The shell still de-quotes and passes them to find as predicates, so any quoted predicate is invisible to the guard.
As a result is_read_only_command() returns True for these commands, and the read-only fast path in Bash.check_permissions returns ALLOW in every permission mode before the dangerous-command, dangerous-path and dangerous-removal checks run — the same bypass-immunity break as #2470, but through a different mechanism (node-type quoting instead of separator splitting). #2471's separator fix would not catch it: the command is a single find invocation with no separator.
Note the sibling git grep -O<cmd> check in the same file deliberately uses shlex.split so quoted option values are caught (covered by tests/permission_bash_parser_test.py); the find check is the only one still matching raw node types.
Error / Reproduce
No exception is raised; the commands are silently classified as read-only and auto-allowed.
from agentscope.tool._builtin._bash_parser import BashCommandParser
p = BashCommandParser()
p.is_read_only_command('find . "-delete"') # True — must be False
p.is_read_only_command("find . '-exec' rm {} \\;") # True — must be False (arbitrary command execution)
p.is_read_only_command("find . '-ok' rm {} \\;") # True — must be False (interactive mutation)
p.is_read_only_command('find . -name "-delete"') # True — correct, must stay TrueOn main @ e101864 (Python 3.12.14, Windows and Linux) all four return True. Quoted predicate values such as -name '-delete', -path './-fprint' and -regex '.*-exec.*' are covered by the existing test suite and must keep returning True, so a fix needs to distinguish a quoted predicate from a quoted value.
Environment
- agentscope
main@e101864(2026-09-30) - Python 3.12.14
- Windows 10 (19045) locally; behavior is platform-independent (pure parser logic)
Source: agentscope-ai/agentscope