Back to skill

Security audit

drawio-generator

Security checks for vulnerabilities and agentic risk

Overview

The skill has a coherent draw.io link generator, but its documented command-line workflow can turn untrusted diagram text into shell command execution if followed literally.

Review before installing. The skill is not showing deception or persistence, but it should be changed so agents do not build shell commands with user-supplied diagram code. Prefer stdin, a temporary file, or a shell-free argument-array invocation, and consider localizing or neutralizing the output link text.

Vulnerability Patterns
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (1)

T09 · Insecure Skill Coding Practices

Error
Location
SKILL.md:85
Finding
Shell Command Injection Through Unsafe Diagram-Code Interpolation<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:85-89` **Vulnerability Type**: Shell command injection **Risk Level**: High ### Vulnerable Code Snippet ```bash python scripts/generate_drawio_url.py -t mermaid -c "graph TD\n A --> B" python scripts/generate_drawio_url.py --type xml --code "<mxGraphModel>...</mxGraphModel>" 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
<![CDATA[ ## Remediation Suggestions 1. Do not interpolate diagram content into a shell command, even when surrounding it with quotes. 2. Invoke the Python script with an argument-array API that does not use a shell. For example, use Python's `subprocess.run()` with `shell=False` and separate arguments: ```python subprocess.run( [ "python", "scripts/generate_drawio_url.py", "--type", diagram_type, "--code", diagram_code, ], check=True, shell=False, ) ``` 3. Prefer standard input for arbitrary multiline diagram content. Add an option such as `--code-stdin` and read the data with `sys.stdin.read()`. Pass the content using the execution API's standard-input facility rather than a shell pipeline or here-document assembled from user input. 4. Alternatively, write the diagram to a securely created temporary file and pass only its path. Use restrictive permissions, unpredictable filenames, and guaranteed cleanup. 5. Update `SKILL.md` to explicitly prohibit constructing a command string or enabling `shell=True`. 6. Replace the current examples with examples using a shell-free execution interface. If command-line examples must remain, clearly state that they are suitable only for fixed trusted literals and not for generated or user-controlled content. 7. Add tests containing double quotes, backticks, `$()`, semicolons, newlines, and XML/CSV quoting characters to verify that diagram input is treated strictly as data. ]]>
Vulnerability Patterns
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (4)

Lp3

Medium
Category
MCP Least Privilege
Confidence
81% confidence
Finding
The skill instructs the agent to execute a Python script that generates a draw.io URL, which implies code execution and likely outbound network use, but it declares no explicit tool scope or permissions. This can cause the skill to run with broader-than-necessary capabilities or without clear operator review, increasing the chance of unintended network access or misuse when handling untrusted diagram content.

Vague Triggers

Medium
Confidence
96% confidence
Finding
The description uses extremely broad activation criteria such as 'any visual diagram' and 'any other visual representation,' which can cause the skill to trigger for a wide range of loosely related prompts. Overbroad activation increases the attack surface by making it easier for adversarial or irrelevant requests to invoke code-generating behavior and bypass more appropriate, narrower skills or guardrails.

Natural-Language Policy Violations

Medium
Confidence
98% confidence
Finding
The skill hardcodes a Chinese user-facing output string ('[点击查看图表](<URL>)') and instructs the agent to present it directly, regardless of the user's language or preferences. While not a direct code-execution issue, this overrides normal user-context handling and can facilitate prompt-level policy interference by forcing output formatting without opt-in.

Natural-Language Policy Violations

Medium
Confidence
95% confidence
Finding
The script prints the markdown link using Chinese text (`点击查看图表`) as the only user-facing label. This imposes a specific language choice on all users without offering a locale option or documenting that the tool is intended for a Chinese-only context.

Static analysis

No suspicious patterns detected.