T09 · Insecure Skill Coding Practices
Error
- Location
- SKILL.md:59
- Finding
- Potential Command Injection Through Unvalidated WHOIS Input<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 59-64 **Vulnerability Type**: OS command injection through untrusted domain input **Risk Level**: High ### Vulnerable Code Snippet ```markdown ## Service 3: Domain Registrar (manual lookup) 1. Run WHOIS lookup: `whois <domain>` or use `https://who.is/<domain>` 2. Find "Registrar Abuse Contact Email" 3. Send abuse email with phishing URL and description ``` ### Technical Analysis The Skill directs the Agent to substitute a domain derived from a user-provided URL into the shell command `whois <domain>`. It does not require the Agent to parse the URL with a structured URL parser, validate the resulting hostname, reject shell metacharacters, or execute WHOIS without a shell. If the Agent implements this instruction using shell-string interpolation, a crafted domain value containing command separators, substitutions, redirections, or whitespace may be interpreted as shell syntax rather than as a single WHOIS argument. The vulnerability therefore occurs at the boundary between attacker-controlled URL input and command execution. The issue is conditional on the Agent invoking the command through a shell. Using an argument-array process API without a shell would substantially reduce the risk, but the Skill does not impose that requirement. ### Attack Path 1. An attacker asks the Agent to report an allegedly malicious URL. 2. The supplied value contains shell syntax, such as a command separator or command substitution, while being presented as the domain to inspect. 3. The Agent follows the Skill and constructs a command equivalent to `whois <attacker-controlled-domain>`. 4. The Agent passes the interpolated string to a shell. 5. The shell interprets the injected syntax and executes the attacker's additional command. 6. The injected command runs with the operating-system permissions and environment access available to the Agent process. ### Impact Assessment Successful exploitation could e ...[truncated 524 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Parse the submitted value with a well-tested URL parser rather than extracting the domain through string manipulation. 2. Restrict accepted schemes to `http` and `https`. 3. Obtain only the parser's normalized hostname field and reject user-info, malformed ports, control characters, whitespace, and ambiguous host representations. 4. Validate hostnames against a strict DNS-name or IP-literal grammar. Reject shell metacharacters and any value that cannot be represented as exactly one process argument. 5. Invoke WHOIS through a process API that accepts an argument array, for example an executable plus `["--", hostname]`, with shell execution explicitly disabled. 6. Prefer a constrained RDAP or WHOIS library/API that does not invoke a local shell. 7. Apply process timeouts, output-size limits, and network restrictions. 8. Add adversarial tests covering semicolons, pipes, substitutions, redirections, newlines, option-like hostnames, Unicode ambiguity, and malformed URLs. ]]>
