T09 · Insecure Skill Coding Practices
- Location
SKILL.md:16- Finding
Shell Command Injection Through the Documented Execution Template
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 16–18
Vulnerability Type: Shell command injection caused by unsafe interpolation of user-controlled values
Risk Level: HighVulnerable Code
markdown 2. Format the request data and pass it to the `scripts/replay.py` execution script. - Command execution example: `python3 scripts/replay.py --url "{URL}" --method "{METHOD}" --data "{PAYLOAD}" --headers "{JSON_HEADERS}"`Technical Analysis
The Skill instructs the Agent to place the user-provided URL, HTTP method, payload, and headers directly into a shell-style command. Double quotation marks do not safely neutralize arbitrary shell input. A value containing a quotation mark followed by shell operators, command substitution, or other metacharacters can terminate the intended argument and introduce an additional command.
The Python script itself uses
argparseand does not invoke a shell. The vulnerability arises when the Agent follows the documented template by constructing a command string and executing it through a shell. Exploitability therefore depends on the command-execution tool using shell parsing, but the documentation does not require a safe argument-array invocation or validation of the interpolated values.Attack Path
- An attacker asks the Agent to validate a PoC and supplies a crafted URL, payload, or header value containing a closing quotation mark and shell syntax.
- The Agent substitutes the attacker-controlled value into the command template from
SKILL.md. - The Agent passes the resulting command string to a shell-based execution facility.
- The shell interprets the injected syntax as a separate command rather than as part of the HTTP request argument.
- The injected command executes with the operating-system privileges and filesystem access assigned to the Agent process.
Impact Assessment
Successful exploitation can provide arbitrary local command e ...[truncated 435 chars]
- Remediation
View remediation
Remediation Suggestions
-
Do not construct a shell command by interpolating request data into a command string.
-
Invoke the script through an argument array with shell processing disabled, equivalent to:
python subprocess.run( [ "python3", "scripts/replay.py", "--url", url, "--method", method, "--data", payload, "--headers", json.dumps(headers), ], shell=False, check=True, ) -
Update
SKILL.mdto explicitly prohibit shell interpolation and require structured tool arguments. -
Prefer passing the complete request definition through standard input or a securely created JSON file instead of command-line arguments. This also reduces exposure of payloads and authentication headers in process listings.
-
Validate the HTTP method against an allowlist and validate that headers are a JSON object before execution.
-
Apply least-privilege sandboxing to the replay process, including restricted filesystem and network access.
-
Add regression tests using quotation marks, command substitutions, newlines, and shell metacharacters to confirm that all supplied values remain literal arguments.
-
