T09 · Insecure Skill Coding Practices
- Location
scripts/convert.py:51- Finding
Arbitrary Python Code Execution Through an Unsanitized Output Path
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This skill has a legitimate sketch-to-DXF purpose, but its converter can execute injected Python through a crafted output filename and installs an unpinned package at runtime.
Review before installing. The skill should not be used until the converter stops building executable Python from filenames, restricts output paths to a controlled DXF output directory, and moves `ezdxf` to a pinned, reviewed dependency installed outside normal runtime.
scripts/convert.py:51Arbitrary Python Code Execution Through an Unsanitized Output Path
scripts/convert.py:24Runtime Installation of an Unpinned Third-Party Dependency
The skill claims to process hand-drawn photos automatically, but the documented behavior only converts manually supplied coordinates into DXF. This mismatch can mislead the orchestrator or user into sending images and trusting automated extraction that does not exist, causing unsafe delegation, incorrect outputs, and potential abuse of broader triggers under false pretenses.
The skill description claims photo/hand-drawn sketch recognition, but the code only accepts explicit coordinate pairs and writes a closed polyline. This is a security-relevant deception/misrepresentation issue because users and orchestrators may grant the skill access or trust under false assumptions about its capabilities, reducing scrutiny of what it actually does. In agent ecosystems, capability mismatch can hide unrelated behavior and undermine safe tool routing.
The skill invokes shell commands to run a Python script but declares no explicit tool scope or allowed-tools restrictions. In an agent environment, undocumented shell capability weakens least-privilege guarantees and can let the skill execute beyond what users or reviewers expect, especially when paired with dynamic environment setup.
Broad trigger phrases like general requests to 'help draw CAD' can cause the skill to activate in contexts beyond narrow sketch-to-DXF conversion. Overbroad routing increases the chance that a shell-capable skill is selected for unrelated tasks, exposing users to unintended command execution paths or incorrect automation.
The activation condition matches any hand-drawn image mentioning CAD, DXF, or drawings, which is too ambiguous for a shell-using skill. In context, this makes the skill more dangerous because it may be invoked on loosely related content while presenting capabilities it does not actually implement.
The module docstring title and examples, along with later user-facing output strings, are presented only in Chinese. For a general-purpose conversion script, this imposes a specific language on users without opt-in or a stated region-specific justification, which matches the locale-policy violation criteria.
Installing dependencies from pip at runtime is an unnecessary capability for this skill and exposes the environment to supply-chain compromise, unreviewed code execution, and network-based nondeterminism. Because the stated task is local DXF generation from provided points, fetching packages during execution is broader than required and violates least privilege. The mismatch between minimal functional needs and network/package-management behavior makes this more suspicious in skill context.
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
if not os.path.exists(venv_python):
print("[sketch2cad] 首次使用,创建虚拟环境并安装依赖...")
os.makedirs(VENV_DIR, exist_ok=True)
subprocess.run([sys.executable, "-m", "venv", VENV_DIR], check=True)
subprocess.run([venv_python, "-m", "pip", "install", "ezdxf", "-q"], check=True)
print("[sketch2cad] 环境准备完成")
The script performs an automatic pip install ezdxf at runtime, which introduces a supply-chain and policy risk by fetching and executing package installation logic during normal skill execution. While there is no direct shell injection here, runtime dependency installation is unjustified for a simple coordinate-to-DXF converter and can allow unexpected code execution through compromised packages, indexes, or network tampering. In an agent skill, this is more dangerous because it grants outbound package-fetching capability unrelated to the user task.
print("[sketch2cad] 首次使用,创建虚拟环境并安装依赖...")
os.makedirs(VENV_DIR, exist_ok=True)
subprocess.run([sys.executable, "-m", "venv", VENV_DIR], check=True)
subprocess.run([venv_python, "-m", "pip", "install", "ezdxf", "-q"], check=True)
print("[sketch2cad] 环境准备完成")
return venv_python
The script builds Python source code using unsafely interpolated user-controlled values, including output_path, and then executes it via python -c. Although subprocess.run is invoked without a shell, the dangerous boundary is the generated Python code itself: a crafted filename containing quotes/newlines can break out of the string literal and execute arbitrary Python code in the spawned interpreter. In this skill context, user input is expected and the command runs automatically, making this significantly more dangerous than a normal subprocess wrapper.
print("[sketch2cad] DXF已生成: {output_path}")
'''
result = subprocess.run(
[venv_python, "-c", code],
capture_output=True,
text=True
The documentation states that the script will automatically create a virtual environment and install dependencies, adding execution-side effects unrelated to simple file conversion. Automatic setup increases attack surface by introducing package installation and potentially network access during runtime, which is riskier than a fixed local conversion tool.
No suspicious patterns detected.