T09 · Insecure Skill Coding Practices
Error
- Location
- SKILL.md:36
- Finding
- Command Injection Through Conversation-Derived Travel Location<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 36-39 **Vulnerability Type**: Shell command injection **Risk Level**: High ### Vulnerable Code ```bash python3 skills/travel-morning-weather/scripts/update-travel-plan.py \ --start YYYY-MM-DD --end YYYY-MM-DD --location "City, Country" ``` The same unsafe command-construction pattern is also demonstrated in `references/capture-triggers.md`, lines 27-29. ### Technical Analysis The skill instructs the agent to extract a location from conversation content and interpolate it into a shell command. The location is therefore untrusted input under the control of the user or another party whose content is processed by the agent. Wrapping the interpolated value in double quotes is not sufficient shell protection. Shell command substitution remains active inside double quotes, and an embedded double quote can terminate the intended argument. If the generated command is executed through a shell, payloads containing constructs such as `$(...)`, backticks, or a quote followed by shell metacharacters may execute unintended commands. The Python script itself uses `argparse` and does not invoke a shell. The vulnerability arises in the documented agent-to-script invocation method, where conversational data may be incorporated into shell syntax before Python receives the arguments. ### Attack Path 1. An attacker supplies or causes the agent to process a travel statement containing a malicious location, for example a value containing shell command substitution. 2. The skill proactively extracts that value as the location, as directed by its travel-capture instructions. 3. The agent substitutes the untrusted value into the documented `--location "..."` shell command. 4. The command is executed through a shell. 5. The shell evaluates the injected syntax before launching the Python script. 6. The injected command runs with the same operating-system identity and permissions as the agent process. Succes ...[truncated 840 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Do not construct a shell command by interpolating conversation-derived values. 2. Invoke the script with a structured argument array and disable shell processing. For example, the hosting implementation should use an equivalent of: ```python subprocess.run( [ "python3", "skills/travel-morning-weather/scripts/update-travel-plan.py", "--start", start_date, "--end", end_date, "--location", location, ], shell=False, check=True, ) ``` 3. Validate dates strictly with `datetime.strptime()` before invocation. 4. Validate location length and reject control characters such as NUL, carriage return, and newline. 5. If a shell is unavoidable, apply platform-appropriate argument escaping to every dynamic value. Validation alone should not replace safe argument-array execution. 6. Update `SKILL.md`, `references/capture-triggers.md`, and `references/data-format.md` to explicitly prohibit shell interpolation of conversation-derived data. 7. Add tests using locations containing quotes, command substitutions, semicolons, newlines, and leading hyphens to verify that they are passed only as literal argument data. ]]>
