T09 · Insecure Skill Coding Practices
- Location
SKILL.md:59- Finding
Shell Command Injection Through User-Controlled JSON Values
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 59–62 and 93–101; additional affected examples appear inreferences/examples.md, lines 14–17 and 93–96
Vulnerability Type: Shell command injection caused by unsafe interpolation into single-quoted CLI arguments
Risk Level: HighVulnerable Code
From
SKILL.md, lines 59–62:bash aliyun dataworks-public prompt-agent-session --profile default --region cn-shanghai \ --params '{"SessionId":"<session-id>","Prompt":[{"Type":"text","Text":"your question"}]}' \ --user-agent AlibabaCloud-Agent-Skills/alibabacloud-dataworks-data-agent/<session-id>From
SKILL.md, lines 93–101:bash # With dataset context aliyun dataworks-public prompt-agent-session --profile default --region cn-shanghai \ --params '{"SessionId":"<id>","Prompt":[{"Type":"text","Text":"query"}],"Meta":{"Context":"{\"datasetUuid\":\"xxx\"}"}}' \ --user-agent AlibabaCloud-Agent-Skills/alibabacloud-dataworks-data-agent/<session-id> # With file attachment aliyun dataworks-public prompt-agent-session --profile default --region cn-shanghai \ --params '{"SessionId":"<id>","Prompt":[{"Type":"text","Text":"analyze"},{"Type":"file","Name":"data.csv","Uri":"file:///path/to/data.csv"}]}' \ --user-agent AlibabaCloud-Agent-Skills/alibabacloud-dataworks-data-agent/<session-id>From
references/examples.md, lines 14–17:bash # 2. Send prompt aliyun dataworks-public prompt-agent-session --profile default --region cn-shanghai \ --params '{"SessionId":"<session-id>","Prompt":[{"Type":"text","Text":"Analyze data quality of orders table for the last 7 days"}]}' \ --user-agent AlibabaCloud-Agent-Skills/alibabacloud-dataworks-data-agent/<session-id>From
references/examples.md, lines 93–96:bash aliyun dataworks-public prompt-agent-session --profile default --region cn-shanghai \ --params '{"SessionId":"<session-id>","Prompt":[{"Type":"text","Text":"Analyze the sales data trends in this file"},{"Type ...[truncated 2251 chars]- Remediation
View remediation
Remediation Suggestions
- Do not construct shell command strings through interpolation.
- Invoke
aliyunthrough an argument-array API that bypasses shell parsing, such as a subprocess interface with shell execution explicitly disabled. - Build request objects and serialize them with a trusted JSON library. Pass the resulting JSON string as one literal process argument.
- Treat prompt text, session identifiers, dataset identifiers, attachment names, file URIs, profile names, and regions as untrusted input.
- Apply strict allowlist validation where practical:
- Validate session identifiers against the service's documented identifier format.
- Restrict regions and profiles to expected character sets and configured values.
- Normalize and validate attachment paths before use.
- Reject prohibited sensitive directories after canonical path resolution.
- If shell execution is unavoidable, apply robust platform-appropriate shell quoting after JSON serialization rather than relying on handwritten quoting.
- Update every command example in
SKILL.mdandreferences/examples.mdto demonstrate safe argument construction. - Add tests containing single quotes, command separators, substitutions, newlines, and malformed JSON to verify that values remain inert process arguments.
