T09 · Insecure Skill Coding Practices
Error
- Location
- SKILL.md:15
- Finding
- Shell Command Injection Through Unsafely Interpolated Prompt<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, line 15 **Vulnerability Type**: Shell command injection **Risk Level**: High ### Vulnerable Code ```bash bash pty:true workdir:<target_dir> background:true command:"codex exec --full-auto '<PROMPT>'" ``` ### Technical Analysis The workflow instructs the orchestrator to interpolate `<PROMPT>` directly into a shell command enclosed by single quotes. No escaping, validation, or structured argument handling is specified. If prompt content is obtained from an untrusted or partially trusted source, an embedded single quote can terminate the intended quoted argument. Subsequent shell metacharacters can then be interpreted as command syntax rather than prompt text. This permits arbitrary command injection under the account running the orchestrator. The use of `--full-auto` further increases the potential consequences because the launched Codex process is configured for autonomous operation, although exploitation of the shell interpolation flaw occurs before Codex processes the prompt. ### Attack Path 1. An attacker supplies or influences task text that will be substituted for `<PROMPT>`. 2. The malicious text includes a single quote that closes the surrounding shell quote. 3. The text appends shell syntax and an attacker-selected command. 4. The orchestrator constructs and launches the resulting command through `bash`. 5. The shell interprets the appended content as executable syntax. 6. The injected command runs with the filesystem access, environment variables, and operating-system privileges of the user running the orchestration skill. ### Impact Assessment Successful exploitation can provide arbitrary command execution with the invoking user's privileges. Depending on that account's permissions and environment, an attacker could read or modify accessible project files, destroy data, access credentials or tokens exposed through files or environment variables, alter source code, and invoke a ...[truncated 214 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Do not concatenate prompt content into a shell command string. - Invoke Codex through a structured process API that accepts an executable and argument array, ensuring the prompt is passed as one literal argument without shell interpretation. - Alternatively, provide the prompt through standard input or a securely created file with restrictive permissions. - If shell execution is unavoidable, apply a proven shell-escaping routine to every dynamic argument rather than relying on manual quoting. - Validate and constrain the target working directory separately, preferably by resolving it to an approved absolute path. - Add tests covering prompts containing single quotes, command separators, substitutions, newlines, and other shell metacharacters. - Consider avoiding `--full-auto` for untrusted tasks or running the process in a sandbox with minimal filesystem, network, credential, and operating-system permissions. ]]>
