T09 · Insecure Skill Coding Practices
- Location
SKILL.md:21- Finding
Shell Command Injection Through Unsafe Search Query Interpolation
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 21–24
Vulnerability Type: Shell command injection caused by unsafe interpolation into a shell command
Risk Level: HighVulnerable Code
bash # Syntax - Safe encoding protects against injection curl -G "https://orionads.net/api/v1/search" \ --data-urlencode "q=<query> product price buy"Equivalent unsafe patterns are also documented at
SKILL.md:53–56for general search.Technical Analysis
The documentation instructs an agent to substitute a user-controlled query into a double-quoted shell argument. Although
curl --data-urlencodesafely URL-encodes the resulting argument for HTTP transport, it does not protect the command during shell parsing.If raw user input is inserted into the command text before execution, shell expansions contained in that input—such as
$(command)or backtick command substitution—are evaluated locally beforecurlruns. Consequently, the statement that URL encoding protects this construction against shell injection is incorrect.Exploitation depends on an implementation generating shell command text by replacing the documented placeholder with untrusted input. Implementations that launch
curldirectly with a properly separated argument array are not affected.Attack Path
- An attacker supplies a product or general-search query containing a shell substitution expression.
- An agent replaces
<query>in the documented command with the untrusted value. - The agent submits the resulting command text to a shell.
- The shell evaluates command substitutions and related expansions before starting
curl. - The injected local command executes with the operating-system privileges of the agent process.
- Only after that execution does
curlURL-encode and transmit the resulting search argument.
Impact Assessment
Successful exploitation permits arbitrary local command execu ...[truncated 415 chars]
- Remediation
View remediation
Remediation Suggestions
- Do not generate shell source by substituting user-controlled text into command templates.
- Launch
curlthrough a process API that accepts an argument array, ensuring the complete query is passed as one argument without invoking a shell. - If a shell cannot be avoided, provide the query through a positional parameter or environment variable established outside dynamically generated shell text, and expand it only as a quoted value.
- Validate query length and reject control characters as defense-in-depth, while recognizing that validation is not a substitute for avoiding shell interpretation.
- Revise all affected search examples, including the analogous patterns at
SKILL.md:53–56. - Add tests using inputs containing command substitutions, backticks, quotes, semicolons, newlines, and option-like prefixes to verify that no local command is executed.
