Executive Summary
Our research found that a Claude Code Bash deny rule blocked a direct file-writing command, but the same operation succeeded when an approved search command launched it as a pager. The issue is the limit of the deny rule: it matched the command Claude Code submitted, but did not prevent a child process from performing the denied operation.
In the tested default permission mode, Claude Code displayed the full command and required user approval. This was therefore not silent execution or a privilege escalation. It shows that users cannot rely on a Bash deny rule alone to guarantee that an operation will never run.
Who Should Read This?
This research is for teams using Claude Code in development workflows and for the security leaders responsible for setting and assessing its permissions. It is especially relevant when those permissions are expected to prevent specific actions.
Does it Impact My Organization?
If your organization relies on Claude Code deny rules to prevent certain actions, this research may affect how you assess those controls. Our test showed that a denied operation could still run indirectly through an approved command. In the configuration we tested, Claude Code displayed the full command and required user approval before it ran.
Background
Claude Code allows users to configure allow and deny rules for tools such as Bash through its settings files: settings.json or settings.local.json. The Bash tool lets Claude Code run shell commands in the user’s environment – for example, to search and read files, launch programs, or create, modify, and delete files. A user might allow read-oriented operations while explicitly denying commands that modify the filesystem.
Some of us (not you, of course) might expect that adding a command to a deny rule means Claude Code cannot execute it. Sounds straightforward, right? But what happens when another utility launches that denied command itself?
During our research, we found an indirect execution path that the deny rule did not block. The indirect command ran and performed the same operation after the user approved the full Bash command. This is the focus of our research.
The grep That Wasn’t Really grep
We started with a basic command that Claude Code commonly runs: grep.
type grep
Instead of pointing to a system binary such as /usr/bin/grep, Claude Code returned a shell function that acts as a wrapper around the bundled ugrep.
Going through the wrapper, we can see that Claude Code actually uses ugrep, a faster open-source alternative to grep.
The wrapper begins with a fallback mechanism that checks for certain flags passed to grep: –pager, –filter, –view, –format-open, –config, and –save-config.
That means that if grep is executed as part of a Claude Code session, it will use ugrep behind the scenes. But if it’s executed with one of the flags above, it will fall back to the original grep command.
The explicit filtering shows that these options were intentionally kept away from the bundled ugrep path.
And why is that, you may ask? That’s the same question we asked ourselves.
Why the Fallback Matters
Let’s focus on the –pager flag:
Many command-line tools use pagers to display long output, for example:
man ls
git log
ugrep --pager "password" ./logs
The pager can often be customized:
ugrep --pager='less -S' "password" ./logs
The important detail is that a pager is a command, not merely the name of a viewer.
For example:
When the above pager is launched, it creates proof.txt instead of opening a viewer.
This behavior is expected. It is not, by itself, a vulnerability, and it does not grant additional privileges. The child process runs with the same permissions as the process that launched it.
The interesting part begins when a higher-level system – Claude Code, for example – treats the utility as read-oriented even though one of its arguments can still launch another command.
This resembles the broader “Living Off The Land” pattern, in which a legitimate utility can be used as an indirect execution path. Here, the utility is behaving as designed. The limitation is that the deny rule did not recognize the command launched indirectly through the pager.
If the pager remains reachable, a user-approved search command may still perform a write operation even when the direct write command appears in the deny list.
The wrapper we examined prevents those flags from reaching the bundled ugrep. Fair enough. But do we really need to go through it?
Skipping the Wrapper
Continuing to inspect the wrapper revealed how Claude Code invokes the bundled search implementation, for instance:
What is special about this invocation?
ARGV0=ugrep "$_cc_bin"
Normally, a process receives the name used to launch it as argv[0]. For example:
grep -i hello file.txt
produces an argument vector similar to:
["grep", "-i", "hello", "file.txt"]
Here, $_cc_bin points to the Claude Code executable, while ARGV0=ugrep makes the launched process receive “ugrep” as its argv[0].
In other words, the operating system still executes:
/path/to/claude
but the process identifies itself as:
ugrep
This matters because the Claude Code executable bundles several internal utilities and uses argv[0] to decide which one to run. By launching it with argv[0] set to ugrep, we can invoke its internal ugrep mode directly – without going through Claude Code’s normal wrapper.
This lets us supply –pager without triggering the fallback to the system grep.
The question was whether this path could perform a write operation even though the direct write command appeared in Claude Code’s deny list. Let’s find out.
Putting the Chain Together
Claude Code was configured with the following deny rule:
A direct attempt to create a file was denied as expected:
The indirect path used Claude Code’s executable as ugrep and supplied the denied operation as its pager:
ARGV0=ugrep made the Claude binary behave like ugrep. It then treated touch /home/pentera/proof.txt as its pager and launched it as a child process.
The search returned exit code 1 because it found no match. However, the child touch command had already executed successfully and created proof.txt.
The deny rule blocked a direct touch command, but the same operation succeeded when it was launched indirectly through –pager. Under the default permission mode used in this test, Claude Code displayed the complete command and required user approval before running it.
Note: Tested on Claude Code 2.1.234. Later builds bundle a newer ugrep version that launches the pager only when output goes to a terminal.
Anthropic’s Response and the Documentation
Anthropic classified the report as Informative and explained that the permission prompt, rather than the deny rules, is the intended enforcement boundary:
“The enforcement boundary in Claude Code’s permission model is the permission prompt.”
In our test, defaultMode was set to “default”. Claude Code displayed the complete command, including the –pager argument, and required the user’s approval before running it.
Anthropic described deny rules as:
“Best-effort pattern filters layered on top of the permission prompt, not a security boundary in themselves.”
However, Claude Code’s documentation states that deny rules:
“Prevent Claude Code from using the specified tool.”
In its detailed Bash section, the documentation provides an important clarification. It explains that Bash rules match the command text Claude writes and that a deny rule “isn’t a security boundary around the program.”
This explanation is more precise, but the broader wording can still reasonably suggest a stronger guarantee. In practice, deny rules block recognized command patterns, but did not block the child process launched through –pager in our test.
Impact
Users may configure deny rules believing that Claude Code cannot perform the denied operations. However, the same operation may still be executed indirectly when launched by another utility.
An attacker who can influence Claude Code’s actions could abuse such a path to perform an operation the user believed was blocked. The operation still runs with the same permissions as Claude Code, and under the default permission mode, the complete command requires user approval.
Remediation
The main remediation is to make the behavior and limitations of deny rules clear. They should be understood as best-effort filters, not as a security boundary.
Users should review the complete command before approving it. When strict isolation is required, they should use narrowly scoped allow rules together with operating-system-level sandboxing.
Responsible Disclosure Timeline
May 14, 2026: Report submitted to Anthropic.
May 14, 2026: Anthropic acknowledged the report and classified it as Informative.
Anthropic has since expanded its permissions documentation with a section explaining what a Bash rule does not match. It now states that a rule matches the command text Claude Code writes, and that a deny rule is not a security boundary around the program. The page gives examples of commands a rule blocks directly but does not block when the same program is invoked in another form.
Conclusion
Reading documentation is important, but fully understanding how a feature works and what it is intended to guarantee is just as important.
Claude Code’s allow and deny rules are useful features, but they should not be relied upon as security boundaries.
Users who require hard isolation should rely on narrowly scoped allow rules together with operating-system-level sandboxing.
The practical takeaway is simple: Treat deny rules as convenience filters, not isolation controls.
Acknowledgements
Research by:
- Nir Chako, Senior Security Researcher, Pentera
- Dvir Levy, Research Team Leader, Pentera





