T09 · Insecure Skill Coding Practices
- Location
SKILL.md:60- Finding
Shell Command Injection Through User-Controlled Search Arguments
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 60-67
Vulnerability Type: Command injection through unsafe shell-string construction
Risk Level: HighVulnerable Code
markdown Use the helper script `scripts/search_skills.py`. The script searches SkillHub and ClawHub simultaneously and automatically calculates compatibility scores: ```bash python ~/.workbuddy/skills/skill-advisor/scripts/search_skills.py "<user requirement>" --limit 20 --keywords "<kw1>,<kw2>,<kw3>"text The source document places the raw user requirement and derived keywords directly inside a shell command. The English placeholders above correspond to the original user-controlled requirement and keyword placeholders. ### Technical Analysis User-controlled requirements and keywords are interpolated into a command string enclosed only by double quotes. Double-quote wrapping is not sufficient shell escaping. An attacker can supply embedded quotes, command substitutions, redirection operators, or other shell metacharacters that terminate the intended argument and introduce additional commands. The risk arises if the agent follows this instruction by submitting the assembled text to a shell, such as through `sh -c`, `bash -c`, or an equivalent command-execution tool. The document does not require strict argument validation or structured process invocation. The referenced `scripts/search_skills.py` file is absent from the audited project, so it cannot provide a verifiable secondary validation layer. ### Attack Path 1. An attacker submits a skill-search request containing a shell payload, such as an embedded closing quote followed by a command separator. 2. The agent treats the complete request as the `<user requirement>` value. 3. The agent interpolates that value into the documented command. 4. The injected quote terminates the intended argument. 5. The shell interprets the remaining attac ...[truncated 702 chars]- Remediation
View remediation
Remediation Suggestions
-
Never build a shell command by concatenating or interpolating user-controlled text.
-
Invoke the Python interpreter with a structured argument array, for example:
python subprocess.run( [ python_executable, script_path, user_requirement, "--limit", "20", "--keywords", ",".join(keywords), ], shell=False, check=True, ) -
Keep
shell=Falseand prohibit use ofsh -c,bash -c, PowerShell command strings, or equivalent wrappers. -
Validate keyword count, character set, and maximum length before invocation.
-
Treat generated keywords as untrusted because they originate from user input.
-
Bundle and audit the referenced helper script so its validation and network behavior can be reviewed.
-
Preserve the declared
shell: noboundary by implementing remote search through a constrained HTTP client instead of shell execution.
-
