T09 · Insecure Skill Coding Practices
- Location
SKILL.md:56- Finding
Shell Command Injection Through Unsafely Interpolated Note Input
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md:56-57andSKILL.md:92-93
Vulnerability Type: Shell command injection
Risk Level: HighVulnerable Code
bash grep -rn --include='*.md' -i 'SEARCH_TERM' $NOTES/bash echo -e "\n## New section\n\nContent to add" >> $NOTES/PATH_TO_NOTE.mdTechnical Analysis
The documented shell templates place user-derived search terms and note content directly into shell command syntax. They do not define validation or a safe mechanism for passing these values as command arguments or standard input.
If an agent replaces
SEARCH_TERMdirectly inside the single-quoted argument, an input containing a single quote can terminate the intended argument and introduce shell operators and commands. Likewise, note content placed directly inside the double-quotedechoargument can contain command substitutions such as$()or backticks, which the shell evaluates before invokingecho.The vulnerability arises because shell quoting embedded in a command template is not a substitute for context-aware argument handling. User-controlled values must not be concatenated into executable shell syntax.
Attack Path
- An attacker asks the skill to search for a deliberately crafted search term or append deliberately crafted content.
- The agent substitutes the supplied value into the documented shell template.
- For search, the payload closes the single-quoted string and adds a shell operator followed by an attacker-selected command.
- For append, a command-substitution expression embedded in content is evaluated by the shell while constructing the
echoargument. - The injected command runs with the same operating-system privileges and environment access as the agent process.
Impact Assessment
Successful exploitation can execute arbitrary local commands with the privileges of the agent runtime. This may permit reading or modifying files accessible ...[truncated 250 chars]
- Remediation
View remediation
Remediation Suggestions
- Do not construct shell commands by inserting user-controlled strings into command text.
- Prefer a filesystem or process-execution API that accepts an argument array without invoking a shell.
- If shell execution is unavoidable, pass the search term as a positional parameter and use an end-of-options marker, such as
grep ... -- "$term" "$NOTES/". - Send note content through safely bound standard input rather than embedding it in an
echocommand. - Use
printf '%s\n' "$content"instead ofecho -e, while ensuring thatcontentis supplied as data rather than inserted into generated shell source. - Treat all titles, tags, search terms, paths, and note bodies as untrusted input.
- Add tests containing single quotes, semicolons, newlines,
$(), backticks, redirection operators, and shell metacharacters to verify that they are handled only as literal data.
