Summary
CodeWhale's terminal agent could classify certain commands as read-only and automatically approve them even when their options selected an external program. If attacker-controlled content influenced a tool call, this behavior could allow arbitrary program execution on the developer's host without the expected approval prompt.
Affected context
The issue affected CodeWhale versions before 0.9.0 in the ExecShellTool approval and command-safety paths. Commands such as fd, rg, and git grep could be treated as read-only based on their base utility name, even when options caused them to run another program or open files in an external pager. Risk depended on attacker-controlled content influencing an agent tool call in a developer environment using the default interactive profile.
Exploit preconditions
- Attack surface: CodeWhale's terminal agent and its ExecShellTool command execution path
- Required access: A way to supply or influence content that the agent uses when forming a tool call
- Trigger point: The agent processes a command classified as automatically approved and invokes it
- Why exploitation is possible: Flag-stripped allowlist checks and later safety checks treated certain utilities as safe without accounting for options that launch external programs; automatic approval bypassed the expected prompt
Why this happens
The approval logic relied on identifying a command by its base utility name rather than evaluating the full command's behavior. As a result, commands considered read-only could invoke external programs through specific options. This is a command-injection risk (CWE-78) because command execution was not sufficiently constrained, and an authorization weakness (CWE-863) because the approval decision did not enforce the expected user authorization for the resulting action.
Potential impact
- An attacker may cause arbitrary programs to run on the developer's host
- Sensitive local data could be accessed or exposed
- Files or development artifacts could be modified or deleted
- The host or development workflow could be disrupted
General mitigation guidance
Defensive approaches focus on making approval decisions reflect the actual behavior of a command, not just its base utility name.
- Prefer structured, narrowly scoped tools over passing composed commands to a shell
- Treat commands that can launch external programs as requiring explicit approval
- Use exact command and argument policies that account for option semantics
- Keep automatic approval limited to operations that are demonstrably read-only
- Restrict the agent's host access and run it with least privilege
- Reduce untrusted content's ability to influence tool calls, and preserve user confirmation for sensitive actions
How teams detect issues like this
- Review approval and safety logic for allowlists that strip flags or classify commands solely by executable name
- Use static analysis and code review to identify shell execution paths and options that invoke external programs
- Test policy behavior for commands with subprocess, pager, or execution options, and verify that sensitive actions still require approval
- Enforce policies that prevent unapproved shell execution and require explicit authorization for commands outside a narrowly defined safe set
Automated code review tools may help identify risky command execution and authorization patterns.

