T09 · Insecure Skill Coding Practices
- Location
SKILL.md:228- Finding
Shell Command Injection Through User-Controlled API Fields
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 228–237
Vulnerability Type: Shell command injection caused by unsafe command construction
Risk Level: HighThe following English-normalized code excerpt preserves the vulnerable command structure documented in the source:
bash curl -s -X POST 'https://s.xingke888.com/api/sales/supplement' -H 'Authorization: Bearer ACTUAL_TOKEN' -H 'Content-Type: application/json' -d '{"product_name":"Tomato","type":"sold_out"}'The accompanying instructions require all arguments to use single quotes and require the complete command to be executed as one line.
Technical Analysis
The skill directs the agent to interpolate API request data into a shell command. Fields such as
product_nameandnotescan originate directly from natural-language user input. These values are inserted into JSON contained within a single-quoted shell argument.If an input contains a single quote, it can terminate the shell argument. An attacker can then append shell syntax and arbitrary commands. JSON encoding alone does not make a value safe for interpolation into a shell command because JSON escaping and shell escaping are separate security boundaries.
The requirement that commands be single-line and that arguments use single quotes does not prevent quote termination. It can instead encourage the agent to build exactly the vulnerable command form.
Attack Path
- An attacker submits a product name, note, or another API field containing a single quote followed by shell syntax.
- The agent recognizes the request as a supported write operation and asks for confirmation.
- After confirmation, the agent inserts the attacker-controlled value into the JSON passed through
curl -d. - The injected quote terminates the original single-quoted argument.
- Appended shell commands execute through the
exectool with the agent process's privileges. - The attacker can use the in ...[truncated 724 chars]
- Remediation
View remediation
Remediation Suggestions
- Replace shell-based
curlconstruction with a structured HTTP tool or language SDK that accepts the URL, headers, and JSON body as separate typed parameters. - Never concatenate or interpolate natural-language input into a shell command.
- Serialize request bodies with a trusted JSON serializer rather than manually constructing JSON text.
- If shell execution is unavoidable, invoke processes without a shell and supply each argument through an argument array.
- Apply strict schema validation to every field, including product names, quantities, dates, prices, identifiers, and notes.
- Reject unexpected control characters and enforce reasonable field-length limits as defense in depth.
- Keep write-operation confirmation, but do not treat confirmation as a substitute for safe command construction.
- Add adversarial tests covering single quotes, command separators, substitutions, newlines, and malformed JSON values.
- Replace shell-based
