T09 · Insecure Skill Coding Practices
- Location
SKILL.md:41- Finding
Shell Command Injection Through User-Controlled Short URL
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 41-43
Vulnerability Type: OS command injection
Risk Level: HighVulnerable code snippet:
bash curl -sIL "https://t.cn/xxx" 2>&1 | grep -i "^location:" | tail -1Technical Analysis
The workflow instructs the agent to process a user-supplied Weibo short URL by substituting it into a shell command. It does not require structured URL parsing, strict hostname validation, path validation, or shell-safe argument handling before execution.
Enclosing an interpolated value in double quotes does not neutralize shell command substitutions such as
$(...)or backticks. If the agent replaces the example URL with the user's input verbatim and invokes a shell, shell metacharacters embedded in that value may be evaluated beforecurlexecutes.The issue arises from passing untrusted input through a shell command rather than using an HTTP client or process API that supplies the URL as a discrete argument without shell interpretation.
Attack Path
- An attacker sends a purported
t.cnURL containing shell command-substitution syntax. - The skill recognizes the input as a short Weibo link and enters the link-expansion step.
- The agent substitutes the untrusted value into the documented
curlcommand. - The command is executed through a shell.
- The shell evaluates the injected substitution before invoking
curl. - The attacker's command runs with the same operating-system privileges and filesystem access as the agent process.
Impact Assessment
Successful exploitation could provide arbitrary command execution under the agent's local account. Depending on that account's permissions, an attacker could read or modify Obsidian files, access locally available configuration and API credentials, alter user data, initiate outbound connections, or execute additional local programs.
The vulnerability does not itself demonstrate pri ...[truncated 171 chars]
- An attacker sends a purported
- Remediation
View remediation
Remediation Suggestions
- Do not interpolate user-supplied URLs into shell command strings.
- Prefer a structured HTTP client or URL-expansion tool that does not invoke a shell.
- If a process must be launched, pass arguments as an array and disable shell execution, such as using a subprocess API without
shell=True. - Parse the input with a standards-compliant URL parser before making the request.
- Allow only the
httpsscheme and the exact hostnamet.cn. - Reject user information, unexpected ports, fragments, control characters, whitespace, and paths that do not match the expected short-link format.
- Validate every redirect target and impose a small redirect limit.
- Reject redirects to loopback, link-local, private, reserved, or otherwise prohibited network addresses.
- Add tests using command-substitution syntax, backticks, newlines, quotes, and shell metacharacters to confirm that input is never interpreted by a shell.
