Summary
CodeWhale's git_show tool passes a model-controlled revision value into Git arguments without validating it or terminating option parsing. In affected configurations, prompt injection through a malicious repository may cause an automatically approved, supposedly read-only tool to write arbitrary files with the invoking user's privileges.
Affected context
The vulnerability occurs in CodeWhale versions that expose the git_show tool with an auto-approved execution path. Risk increases when a repository or other untrusted content can influence model prompts, the model can control the rev parameter, and the invoking process has write access to sensitive user files.
Exploit preconditions
- Attack surface: The CodeWhale
git_showtool and its Git subprocess invocation - Required access: The attacker generally needs to influence repository content or prompts in a way that causes the model to select a crafted revision argument
- Trigger point: Processing the model-supplied
revvalue when constructing thegit showargument vector - Why exploitation is possible: The value is not sufficiently constrained and option parsing is not explicitly terminated, allowing attacker-controlled input to be interpreted as a Git option
- Privilege boundary: Resulting file writes occur with the permissions of the CodeWhale process
Why this happens
The underlying bug is insufficient validation of externally influenced data before it is placed into a command-line argument list. Although the value is intended to identify a Git revision, Git may interpret option-like values as command options when argument parsing is not explicitly bounded. This maps to CWE-73: External Control of File Name or Path, because attacker-influenced input can redirect file output to paths outside the intended read-only operation.
Potential impact
- An attacker may overwrite user-controlled or sensitive files
- SSH authorization or shell configuration may be modified
- Git configuration could be altered to influence subsequent operations
- The invoking user's account or development environment could be compromised
- Repository integrity, automation workflows, or supply-chain processes could be affected
General mitigation guidance
Mitigation generally focuses on treating model-supplied tool parameters as untrusted command input and preserving the intended read-only behavior.
Common defensive patterns include:
- Validate revision parameters against a narrowly defined allowlist or expected revision grammar
- Use explicit end-of-options handling when invoking command-line tools
- Prefer structured library APIs over shell or argument interfaces where practical
- Separate data arguments from command options and reject unexpected option-like values
- Require confirmation for operations with filesystem side effects, even when a tool is described as read-only
- Run the tool with least-privilege filesystem and process permissions
- Apply repository isolation and restrict writes to approved working directories
How teams detect issues like this
Organizations can look for:
- Static analysis findings where model-controlled or repository-controlled values are appended to subprocess argument vectors
- Code review signals involving missing argument validation, absent end-of-options handling, or read-only tools that invoke output-capable commands
- Tests that supply boundary-case revision values and verify that no unintended options or filesystem effects occur
- Policy enforcement requiring explicit approval for tools capable of writing files
- Runtime monitoring for unexpected writes to SSH, shell, Git configuration, or other protected paths
Automated security review tools may help identify unsafe subprocess construction and mismatches between a tool's advertised behavior and its actual capabilities.

