T09 · Insecure Skill Coding Practices
- Location
SKILL.md:47- Finding
Shell Command Injection Through Unsanitized API Parameters
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, line 47
Vulnerability Type: Shell command injection
Risk Level: HighVulnerable Code Snippet:
bash curl -s "https://api.cjiot.cc/api/v1/daily?date={current_date}"The original placeholder represents the current date derived from the request context. Similar API templates use a user-selected date and article identifier at lines 75 and 99.
Technical Analysis
The Skill directs the Agent to construct and execute a shell command containing a substituted date value. Although the document states that dates must use the
YYYY-MM-DDformat, it does not define an enforceable validation procedure before invokingexec.If raw or insufficiently validated user input replaces the placeholder, an attacker can supply quote-breaking shell syntax. Because the value is placed inside double quotes, input containing a double quote followed by shell separators could terminate the URL argument and introduce an additional command.
The same underlying concern applies to the article-detail template at line 99 because the document does not specify a strict numeric or UUID allowlist for
article_id. The document's later recommendation to avoid concatenating user input is descriptive only and does not enforce safe execution.Attack Path
- An attacker asks for news using a crafted date or article reference containing shell metacharacters.
- The Agent extracts the attacker-controlled value without strict allowlist validation.
- The value is substituted into the documented
curlcommand template. - The Agent invokes the resulting string through the declared
execcapability. - The shell interprets the injected separators and executes the attacker's additional command with the Agent process's privileges.
Exploitation depends on the hosting Agent performing direct textual substitution and shell execution rather than independently validating and safely encod ...[truncated 482 chars]
- Remediation
View remediation
Remediation Suggestions
- Replace shell-based
curlexecution with a structured HTTPS client that separates the URL, path, and query parameters. - Validate dates with a strict calendar parser after enforcing the exact
YYYY-MM-DDsyntax. Reject invalid dates rather than attempting to normalize them. - Define and enforce an allowlist for article identifiers, such as digits only or a precisely specified UUID format.
- Apply URL encoding to every query and path parameter.
- If a command-line client is unavoidable, invoke it through an argument-array API without a shell. Never build a command by concatenating user-derived strings.
- Allowlist the destination scheme, hostname, port, and API paths.
- Add negative tests covering quotes, command separators, substitutions, newlines, traversal sequences, and malformed percent encoding.
- Replace shell-based
