T09 · Insecure Skill Coding Practices
- Location
SKILL.md:70- Finding
Potential Shell Command Injection Through Unescaped Message Content and File Paths
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 70–73 and 78–81
Vulnerability Type: Shell command injection caused by unsafe command construction guidance
Risk Level: HighVulnerable code snippets:
bash wxclawbot send --text "消息内容" --jsonbash wxclawbot send --file /path/to/file --text "说明" --jsonTechnical Analysis
The Skill instructs the Agent to insert conversation content, descriptive text, and file paths into shell command templates. It does not require execution through a shell-free argument array, define robust escaping rules, or validate the supplied file path.
If an implementation constructs these commands by directly replacing the placeholders and then passes the resulting string to a shell, attacker-controlled values can terminate the intended quoting context or introduce command substitutions and other shell metacharacters. Payloads containing constructs such as double quotes,
$(...), backticks, semicolons, pipes, or redirections could consequently be interpreted by the shell rather than treated exclusively aswxclawbotarguments.The file-forwarding form introduces an additional injection surface because both the file path and accompanying text can be influenced by input. The issue is conditional on a shell-based implementation performing direct interpolation; execution through a subprocess argument array without a shell would prevent shell metacharacter interpretation.
Attack Path
- An attacker causes crafted text or a crafted file path containing shell syntax to appear in the conversation.
- The user explicitly asks the Agent to forward that content or file to WeChat.
- The Agent follows the documented template and interpolates the untrusted value into a command string.
- A shell-based executor parses the interpolated value as shell syntax.
- The injected command executes before, after, or instead of the intended
wxclawbot sendoperation.
...[truncated 474 chars]
- Remediation
View remediation
Remediation Suggestions
- Invoke
wxclawbotdirectly through a subprocess API that accepts an argument array, with shell processing disabled. For example, pass arguments equivalent to["wxclawbot", "send", "--text", message, "--json"]. - Never build a shell command by concatenating or interpolating conversation content, descriptive text, or file paths.
- Update the Skill instructions to explicitly prohibit shell evaluation mechanisms such as
sh -c,bash -c,eval, or equivalent command-string execution. - If a shell is unavoidable, apply platform-specific argument escaping to every untrusted value and reject control characters. Escaping is a fallback and should not replace shell-free execution.
- Normalize file paths, require explicit user approval for the selected file, and restrict forwarding to approved directories where practical.
- Treat message content and filenames solely as opaque data, including when they contain quotes, substitutions, newlines, redirections, or option-like prefixes.
- Add tests using adversarial inputs such as quotes, command substitutions, semicolons, pipes, newlines, and filenames beginning with hyphens to confirm that no input is interpreted as executable syntax.
- Invoke
