T09 · Insecure Skill Coding Practices
- Location
SKILL.md:24- Finding
Command and Python Code Injection Through Unsafe Value Interpolation
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md:24-56
Vulnerability Type: Command injection and Python source injection
Risk Level: HighThe Skill instructs the agent to substitute user-controlled email and topic values directly into shell commands. It also inserts the topic and an API-provided task identifier directly into a Python program executed through
python3 -c.bash curl -s -X POST https://prose-kit.com/v1/register \ -H "Content-Type: application/json" \ -d '{"email": "{用户的邮箱}"}'bash curl -s -X POST https://prose-kit.com/v1/generate \ -H "Authorization: Bearer $PROSE_KIT_API_KEY" \ -H "Content-Type: application/json" \ -d '{"topic": "{用户的主题}", "with_scoring": false}'bash python3 -c " import json, time, urllib.request, os task_id = '{task_id}' api_key = os.environ['PROSE_KIT_API_KEY'] topic = '{topic}'Technical Analysis
The documented workflow relies on textual substitution rather than passing values through a non-executable data channel.
In the
curlexamples, an attacker can include shell metacharacters and quote characters in the email or topic. A single quote can terminate the JSON argument, after which additional shell syntax may be interpreted by the shell.The polling script is additionally vulnerable because both
{topic}and{task_id}are embedded inside single-quoted Python string literals within a double-quoted shell argument. Crafted values can terminate either the Python literal or the surrounding shell command. The topic is directly controlled by the user, while the task identifier is controlled by the external API response.JSON escaping alone would not fully address the Python command issue because values must also be protected from the shell and Python parser. Untrusted data should never be inserted into generated executable source.
Attack Path
- An attacker supplies a writing topic or registration email co ...[truncated 1119 chars]
- Remediation
View remediation
Remediation Suggestions
- Do not construct shell commands or Python source code through textual replacement.
- Implement the workflow as a fixed script and pass the email, topic, and task identifier through command-line arguments or environment variables.
- Construct request bodies with
json.dumps()rather than manually assembling JSON:python payload = json.dumps({ "topic": topic, "with_scoring": with_scoring, }).encode("utf-8") - Use
subprocess.run()with an argument array andshell=Falseif an external command is required. - Prefer a Python HTTP client or
urllib.requestso that no shell is involved. - Validate API task identifiers against a restrictive expected format, such as an allowlist of ASCII letters, digits, hyphens, and underscores.
- Apply reasonable length limits to email and topic values.
- Treat server responses as untrusted even when received over HTTPS.
- Avoid placing the API key in command-line arguments, logs, generated files, or error messages.
