T09 · Insecure Skill Coding Practices
Error
- Location
- SKILL.md:30
- Finding
- Shell Command Injection Through Unescaped Research Query<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 30-45 **Vulnerability Type**: Shell command injection through unsafe interpolation of user-controlled input **Risk Level**: High ### Vulnerable Code ```bash exa.js search --query "[research topic]" --category "research paper" --num-results 10 ``` ```bash exa.js search --query "[topic]" --category "research paper" --num-results 10 --start-date [current-year]-01-01 # Use current year ``` ```bash exa.js search --query "[topic] [specific method or finding]" --category "research paper" --num-results 10 ``` ### Technical Analysis The skill instructs the agent to run shell commands through `exec` and substitute user-provided research topics into quoted command templates. Shell double quotes do not neutralize command substitutions such as `$(command)` or backtick expressions. They also permit some variable and escape processing. If the agent performs literal template substitution and passes the resulting string to a shell, a malicious research topic can cause the shell to evaluate attacker-controlled syntax before invoking `exa.js`. The same pattern occurs in the initial, date-filtered, and refined search commands. For example, a topic containing `$(id)` could result in local execution of `id` when embedded in the documented command. More harmful commands could read or modify any resources accessible to the agent process. ### Attack Path 1. An attacker supplies a research topic containing shell substitution syntax, such as `$(attacker_command)`. 2. The agent follows the skill and inserts the topic into the `--query` placeholder. 3. The agent invokes the generated command using a shell-backed `exec` facility. 4. The shell evaluates the injected substitution even though the query is enclosed in double quotes. 5. The attacker-controlled command executes with the operating-system permissions of the agent. 6. The ordinary Exa search may then continue, potentially concealing the injected execut ...[truncated 765 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Do not construct shell command strings by interpolating research topics. 2. Invoke `exa.js` through a process API that accepts an argument array and disables shell interpretation. For example, pass arguments equivalent to: - `exa.js` - `search` - `--query` - the complete user-provided topic as one argument - `--category` - `research paper` - `--num-results` - `10` 3. Explicitly document that the execution tool must use `shell: false` or an equivalent setting. 4. Treat topics, methods, findings, dates, and result IDs as untrusted data. 5. Validate structured values such as dates, result counts, and paper IDs against strict allowlists or formats. 6. If a shell is unavoidable, apply a proven platform-specific argument-escaping routine to every untrusted value. Do not rely on double quotes alone. 7. Add tests using payloads containing `$()`, backticks, quotes, semicolons, newlines, and redirection operators to verify that they remain literal arguments. ]]>
