T09 · Insecure Skill Coding Practices
- Location
claude_bridge.py:55- Finding
Shell Command Injection Through Unsafely Embedded Prompts
- Content
View full analysis
"{RESULT_DIR / f'{task_id}.txt'}" 2>&1 ``` ### Technical Analysis The application inserts the task prompt directly into a generated Bash script. It escapes only double quotation marks, which is insufficient for content placed inside a double-quoted shell argument. Bash continues to interpret command substitution, backticks, variable expansion, and some backslash sequences inside double quotes. Consequently, prompt content such as `$(command)` or a backtick command is evaluated by Bash before the prompt is passed to the Claude CLI. The generated script is subsequently executed with: ```python result = subprocess.run( ["bash", str(script_file)], capture_output=True, text=True, timeout=timeout ) ``` Using an argument array for the outer `subprocess.run()` call does not mitigate the vulnerability because the generated file is explicitly interpreted by Bash. ### Attack Path 1. An attacker supplies a malicious prompt through the command-line `create` operation or any API that reaches `create_task()`. 2. The prompt contains shell syntax, for example `$(touch /tmp/bridge-pwned)`. 3. `create_task()` embeds that syntax in the double-quoted `claude -p` argument of an executable shell script. 4. The user or application invokes `execute_task_local()` for the generated task. 5. Bash performs command substitution before starting the Claude CLI. 6. The injected command runs with the operating-system privileges of the bridge process. This exploitation path does not depend on persuading the language model to call a tool and therefore bypasses Claude CLI tool-permission controls. ### Impact Assessment Successful exploitation permits arbitrary command execution under the account running the bridge. Dependi ...[truncated 365 chars]- Remediation
View remediation
