T09 · Insecure Skill Coding Practices
- Location
templates/AGENTS.md:73- Finding
Shell Command Injection Risk in Mandated Diary Append Operations
- Content
View full analysis
Vulnerability Details
File Location:
templates/AGENTS.md:73andtemplates/HEARTBEAT.md:144
Vulnerability Type: Shell command injection through unsafe construction of diary append commands
Risk Level: MediumVulnerable Code
Both templates mandate diary appends through the following operative shell command:
bash echo [diary content] >> [diary file]The instructions specifically require use of the
exectool withecho >> filerather than a structured file-writing operation.Technical Analysis
Diary entries can contain content derived from user conversations, recommendations, place names, travel descriptions, and other externally influenced text. Placing such text directly into an
echocommand creates a shell interpretation boundary.If the Agent constructs the command without rigorous shell escaping, characters such as command substitutions, quotes, semicolons, pipes, or redirection operators can alter the intended command. For example, attacker-controlled text containing a command substitution could be executed by the shell instead of being written literally to the diary.
This is an insecure instruction pattern even though the template does not contain a malicious payload itself. It directs downstream Agents to use a shell for a task that does not require shell interpretation.
Attack Path
- An attacker supplies text likely to be incorporated into a diary entry, such as a recommendation, location, or conversational statement.
- The supplied text contains shell metacharacters or command-substitution syntax.
- Following the template, the Agent embeds the text into an
execcommand usingecho ... >> memory/YYYY-MM-DD.md. - If quoting is absent or incomplete, the shell interprets part of the diary content as syntax.
- The injected command executes with the same operating-system privileges and filesystem access as the Agent runtime.
Exploitation depends on the downstrea ...[truncated 666 chars]
- Remediation
View remediation
Remediation Suggestions
- Replace the mandated
execandechoworkflow with a structured append-file tool that does not invoke a shell. - Alternatively, add a small Python helper that accepts diary content as data and opens the target file in append mode:
python with open(diary_path, "a", encoding="utf-8") as diary: diary.write(content + "\n") - Validate that the diary path resolves beneath the intended memory directory.
- If shell execution is unavoidable, pass content through a non-shell argument channel and use a fixed command with robust positional-argument handling. Do not concatenate content into a shell command.
- Apply the same correction to
templates/HEARTBEAT.md:144. - Add adversarial tests using quotes, command substitutions, semicolons, newlines, pipes, and redirection characters to confirm that all content is stored literally.
- Replace the mandated
