T09 · Insecure Skill Coding Practices
- Location
SKILL.md:31- Finding
Potential Command Injection Through Unquoted User-Controlled Search Keyword
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, line 31
Vulnerability Type: OS command injection
Risk Level: HighVulnerable Code
bash python query_search_products.py {keyword}The Skill defines
keywordas a required search term supplied by the user and instructs the agent to substitute it directly into a shell command without quoting, validation, or argument separation.Technical Analysis
If the documented command is implemented through textual substitution and executed by a shell, shell metacharacters in
keywordcan change the command's structure. An attacker could supply separators, command substitutions, redirections, or additional command-line arguments rather than a normal product-search term.The referenced
query_search_products.pyfile is absent from the audited package. Consequently, the exact execution mechanism cannot be verified. Exploitability depends on the agent or runtime passing the constructed string through a shell. If the runtime instead invokes the script with a safely separated argument array andshell=False, shell injection would not occur.Attack Path
- An attacker submits a product-search keyword containing shell-control syntax.
- The agent replaces
{keyword}with the attacker-controlled text. - The resulting command string is passed to a shell without safe quoting or argument separation.
- The shell interprets the injected syntax as commands or redirections.
- The injected operation executes with the privileges and environmental access of the agent process.
Impact Assessment
Successful exploitation could permit arbitrary command execution under the agent's operating-system account. Depending on that account's privileges and environment, an attacker could read accessible local files and credentials, modify or delete files, launch network requests, tamper with subsequent task output, or execute additional local programs.
The issue does not itself demonstrate privilege escal ...[truncated 151 chars]
- Remediation
View remediation
Remediation Suggestions
- Do not build a shell command by concatenating or textually substituting user input.
- Invoke the Python interpreter with a structured argument array and disable shell processing. For example:
python import subprocess subprocess.run( ["python", "query_search_products.py", keyword], check=True, shell=False, )- Validate
keywordaccording to the application's search requirements, including a reasonable length limit and rejection of control characters. Validation should supplement, not replace, safe process invocation. - If shell execution is unavoidable, apply platform-appropriate escaping through a proven API. Argument-array execution remains preferable.
- Update
SKILL.mdto state explicitly that{keyword}must be passed as one process argument and must never be interpolated into a shell command. - Add the referenced script and dependency declarations to the package so their implementation, network behavior, input handling, and output parsing can be audited.
- Add tests using search terms containing spaces, quotes, semicolons, command-substitution syntax, redirection characters, and leading hyphens to confirm they remain inert data.
