T09 · Insecure Skill Coding Practices
- Location
SKILL.md:168- Finding
Shell Command Injection Through Unvalidated User-Controlled Placeholders
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md:168-184, with additional affected command templates atSKILL.md:190-197andSKILL.md:361-369
Vulnerability Type: Shell command injection
Risk Level: HighVulnerable Code
bash # Add trusted IPs to whitelist (can be executed multiple times) aliyun waf-openapi add-address \ --region {region} \ --InstanceId {instance_id} \ --AddressList '["{trusted_ip_1}","{trusted_ip_2}"]' \ --AddressType "ipv4" \ --user-agent "AlibabaCloud-Agent-Skills/alibabacloud-waf-bot-management"Other affected templates include:
bash aliyun waf-openapi create-defense-template \ --region {region} \ --InstanceId {instance_id} \ --TemplateName "{scenario_name}_Bot_Protection" \ --DefenseScene "antibot" \ --user-agent "AlibabaCloud-Agent-Skills/alibabacloud-waf-bot-management"bash aliyun waf-openapi create-defense-rule \ --region {region} \ --InstanceId {instance_id} \ --TemplateId {template_id} \ --DefenseScene "antibot" \ --RuleName "{new_rule_name}" \ --RuleContent '{...}' \ --user-agent "AlibabaCloud-Agent-Skills/alibabacloud-waf-bot-management"Technical Analysis
The skill collects values such as regions, instance identifiers, scenario names, trusted IP addresses, and rule names, then interpolates them directly into command strings intended for shell execution. It does not define allowlist validation, escaping requirements, or an argument-array execution mechanism.
Shell quoting does not make these templates uniformly safe:
- Values placed inside double quotes can still trigger shell expansion, including command substitution using
$(). - A single quote embedded in a trusted-IP value can terminate the single-quoted JSON argument and introduce additional shell syntax.
- Fields such as
{region},{instance_id}, and{template_id}are not consistently quoted. - JSON is assem ...[truncated 1612 chars]
- Values placed inside double quotes can still trigger shell expansion, including command substitution using
- Remediation
View remediation
Remediation Suggestions
- Execute the CLI through a structured argument array without invoking a shell. Each placeholder must be passed as one discrete argument.
- Apply strict allowlist validation before command construction:
- Validate regions against supported Alibaba Cloud region identifiers.
- Validate instance, template, resource, and rule IDs against their documented formats.
- Parse trusted addresses with an IPv4, IPv6, or CIDR library and reject all other input.
- Restrict names to a conservative character set and length, such as ASCII letters, digits, underscores, and hyphens.
- Restrict actions and statuses to explicit enumerations.
- Construct
AddressList,ResourceList, andRuleContentwith a JSON serializer rather than string concatenation. - Reject control characters, command-substitution syntax, newlines, and unexpected quotes as defense in depth.
- Present the normalized command arguments and planned cloud mutations to the user before execution.
- Require explicit confirmation for every write operation, particularly address-book changes, resource binding, and template enablement.
- Add negative tests covering single quotes, double quotes, semicolons, newlines,
$(), backticks, and malformed JSON.
