T09 · Insecure Skill Coding Practices
- Location
SKILL.md:19- Finding
Shell Command Injection Through Unsafe User-Content Interpolation
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 19 and 24–31
Vulnerability Type: Shell command injection
Risk Level: Highbash # Ensure directory exists mkdir -p ~/.memo # Generate ISO 8601 timestamp (Local Time) TIMESTAMP=$(date +"%Y-%m-%d %H:%M:%S") # Write to file (Variables populated by Agent) # {{category}} will be the English label identified (e.g., Tech, Work) printf "\n---\n### Timestamp: $TIMESTAMP\nLabel: {{category}}\n\n{{content}}\n" >> ~/.memo/{{category}}.mdTechnical Analysis
The Skill directs the Agent to interpolate raw, user-controlled
contentinto a shell command executed through theexectool. The content is placed inside a double-quoted shell argument, which does not prevent shell evaluation of command substitution expressions such as$(command)or backticks.Consequently, memo content containing a command substitution can be evaluated by the shell before
printfwrites the resulting text. Generated category values are also inserted into the command and destination path without explicit validation, although the instructions nominally limit them to a fixed set.Attack Path
- An attacker invokes the Skill using the documented trigger.
- The attacker supplies memo content containing shell syntax, such as a command substitution expression.
- The Agent inserts the raw content into the documented
printfcommand. - The Agent invokes that command through
exec. - The shell evaluates the injected command substitution before executing
printf. - The injected command runs with the same operating-system privileges and environment access as the Agent process.
Impact Assessment
Successful exploitation permits arbitrary shell command execution under the Agent's account. The attacker could read or modify files accessible to that account, steal credentials or tokens available in files or environment variables, initiate network connections, tamp ...[truncated 188 chars]
- Remediation
View remediation
Remediation Suggestions
- Do not construct shell source code by interpolating user-controlled memo content.
- Prefer a dedicated filesystem-writing API that does not invoke a shell.
- If
execis unavoidable, supply the content through standard input or a safely bound positional parameter to a fixed script rather than embedding it into the command string. - Map the classification result to an immutable allowlist containing only
Tech,Work,Life,Inspiration, andOthers. Reject every other value. - Construct the destination path from the validated allowlist value and verify that the resolved path remains under
~/.memo. - Open the destination file in append mode through a language-level file API and write the timestamp, validated label, and original content as data.
- Add tests using content containing
$(...), backticks, quotes, newlines, redirection operators, semicolons, and traversal strings to confirm that such input is stored literally and never interpreted by a shell.
