T09 · Insecure Skill Coding Practices
Error
- Location
- SKILL.md:43
- Finding
- Shell Command Injection Through Unsafely Interpolated Shortcut Names<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 43-56 **Vulnerability Type**: Shell command injection **Risk Level**: High ### Vulnerable Code ```bash shortcuts run "Morning Routine" shortcuts run "Send Email" ``` ```markdown **Parameters:** - `<name>`: Exact name of the shortcut (use quotes if name contains spaces) ``` ### Technical Analysis The skill instructs the agent to place a shortcut name into a shell-command template. It recommends enclosing the value in double quotes but does not require shell-free process execution, validation, or platform-correct escaping. Double quotes alone are not a safe defense when an untrusted value is used to construct a command string. A value containing a closing quote, command substitution, or other shell syntax may alter the resulting command. For example, interpolating a name such as `x"; malicious-command; #` could produce: ```bash shortcuts run "x"; malicious-command; #" ``` If the agent passes this generated string to a shell, the shell runs `malicious-command` separately from the intended `shortcuts` invocation. Command substitution syntax may also be evaluated inside double quotes when the assembled value is interpreted as shell source. The same unsafe usage pattern is repeated in `README.md`, lines 32-45. Exploitability depends on the execution layer constructing and evaluating a shell command string rather than passing the shortcut name as a distinct process argument. ### Attack Path 1. An attacker supplies or requests a shortcut name containing shell syntax, such as `x"; malicious-command; #`. 2. The agent follows the documented template and inserts that value between literal double quotes. 3. The agent or its command-execution tool submits the assembled command through a shell. 4. The injected quote terminates the intended shortcut-name argument. 5. The shell interprets the remaining text as an additional command. 6. The injected command executes with the operating-system priv ...[truncated 816 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. **Avoid shell command construction.** Invoke the executable through a process API that accepts an argument array: ```text executable: shortcuts arguments: ["run", shortcutName] shell: false ``` 2. **Do not rely on double quotes as sanitization.** Never concatenate user-controlled shortcut names into a command string evaluated by `/bin/sh`, `bash`, `zsh`, or an equivalent shell. 3. **Validate against authoritative output.** Run `shortcuts list`, parse the returned shortcut names without shell evaluation, and require the requested name to exactly match an existing entry. 4. **Use explicit operation allowlisting.** Restrict execution to the documented `list`, `view`, `run`, and `sign` subcommands and pass every dynamic value as a separate argument. 5. **Require confirmation for sensitive execution.** Before running or signing a shortcut, display its exact matched name and request confirmation when its behavior is unknown or it can access sensitive resources. 6. **Document the safe invocation requirement.** Update both `SKILL.md` and `README.md` to state that implementations must use shell-free argument passing. If a shell is unavoidable, apply robust platform-specific escaping and reject control characters, command substitutions, quotes, and shell metacharacters. ]]>
