T09 · Insecure Skill Coding Practices
- Location
TOOLS.md:31- Finding
Shell Command Injection Through User-Controlled Email and Attachment Values
- Content
View full analysis
' ATTACHMENT_PATH='' && echo "Cosmonyx companies export attached." > /tmp/companies_body.txt && cd "/scripts" && python3 send-email.py /tmp/companies_body.txt ``` The same unsafe construction is repeated in the full command on line 37: ```bash export SMTP_HOST=in-v3.mailjet.com SMTP_USERNAME=... SMTP_PASSWORD=... SMTP_PORT=587 SMTP_DEFAULT_EMAIL=... SMTP_DEFAULT_NAME=IdentityGram EMAIL_TO='' ATTACHMENT_PATH='' && echo "Cosmonyx companies export attached." > /tmp/companies_body.txt && cd "/scripts" && python3 send-email.py /tmp/companies_body.txt ``` ### Technical Analysis The instructions require an agent to replace `` with a user-provided email address and `` with an attachment path, then execute the resulting string through a shell. Single quotes do not make this safe when the interpolated value itself can contain a single quote. A malicious value can terminate the quoted assignment and append arbitrary shell operators and commands. `SKILL.md`, lines 169–172, directs the agent to set these values and execute the documented one-line command. Although the normal attachment path is generated internally, the recipient is explicitly supplied by the user. The command therefore creates a direct path from untrusted input to shell execution. ### Attack Path 1. An attacker asks the Skill to email an export. 2. When prompted for an address, the attacker supplies a value such as: ```text x'; id > /tmp/comonyx-command-output; # ``` 3. The agent substitutes that value into the documented command: ```bash export EMAIL_TO='x'; id > /tmp/comonyx-command-output; #' ATTACHMENT_PATH='...' ``` 4. The shell closes the assignment at the injected quote and executes `id`. ...[truncated 686 chars]- Remediation
View remediation
