T09 · Insecure Skill Coding Practices
- Location
SKILL.md:85- Finding
Shell Command Injection Through Unsafe Diagram-Code Interpolation
- Content
View full analysis
B" python scripts/generate_drawio_url.py --type xml --code "..." python scripts/generate_drawio_url.py -t csv -c "name,manager\nCEO,\nCTO,CEO" ``` ### Technical Analysis The Skill instructs an agent to pass generated Mermaid, XML, or CSV content directly through a double-quoted shell argument. Diagram content may be based on untrusted user input and can contain shell metacharacters such as double quotes, backticks, or `$()` command substitutions. Double quotes do not prevent shell command substitution. If an agent constructs and executes the documented command through a shell, attacker-controlled content can terminate or alter the intended argument or cause the shell to evaluate embedded substitutions before `generate_drawio_url.py` receives the diagram code. For example, an attacker could request a Mermaid node containing content similar to: ```text A["$(id > /tmp/drawio-injection-result)"] ``` If this content is interpolated into the documented command template, the shell may execute `id > /tmp/drawio-injection-result`. The Python script itself does not invoke a subprocess; the vulnerability arises from the unsafe shell invocation pattern prescribed by the Skill documentation. ### Attack Path 1. An attacker asks the agent to create a diagram containing shell command-substitution syntax in a label, XML attribute, or CSV field. 2. The agent preserves the attacker-controlled text while generating the requested diagram code. 3. Following `SKILL.md`, the agent places the generated code inside the double-quoted `--code` argument. 4. The agent executes the resulting command through a shell. 5. The shell evaluates the injected command substitution before starting Python. 6. The attacke ...[truncated 1072 chars]- Remediation
View remediation
