Back to skill

Security audit

千问文生图

Security checks for vulnerabilities and agentic risk

Overview

This image-generation skill is purpose-aligned, but its instructions show unsafe shell-based prompt handling that could let crafted image prompts run local commands.

Review before installing. Use this only with non-sensitive prompts and a limited DashScope API key, and update the instructions or implementation to build requests with a JSON serializer or structured HTTP client rather than interpolating user prompts into shell commands.

Vulnerability Patterns
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (1)

T09 · Insecure Skill Coding Practices

Error
Location
SKILL.md:14
Finding

User-Controlled Prompt Can Enable Shell Command Injection

Content
View full analysis

Vulnerability Details

File Location: SKILL.md:14-34
Additional Location: references/api.md:60-79
Vulnerability Type: Shell command injection through unsafe interpolation into a single-quoted curl request body
Risk Level: High

Vulnerable Code Snippet

bash
curl -X POST 'https://dashscope.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation' \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
  -d '{
    "model": "qwen-image-2.0-pro",
    "input": {
      "messages": [{
        "role": "user",
        "content": [{"text": "你的提示词"}]
      }]
    },
    "parameters": {
      "negative_prompt": "低分辨率,低画质,肢体畸形,手指畸形",
      "prompt_extend": true,
      "watermark": false,
      "size": "2048*2048"
    }
  }'

The documented execution process instructs the agent to construct this JSON request from the user's prompt and execute it using curl:

text
1. Check API Key
2. Construct the request using the user's prompt and parameters
3. Call the API using curl
4. Parse the response
5. Return the image URL

Technical Analysis

The complete JSON request body is enclosed in a shell single-quoted string passed to curl through -d. If an implementation directly replaces the prompt placeholder with user-controlled text, a single quote in that text terminates the shell string.

The attacker can then introduce shell separators such as ; and append an arbitrary command. JSON escaping alone does not prevent this vulnerability because JSON escaping and shell escaping are different security boundaries. A prompt may be valid or safely escaped for JSON while remaining unsafe when concatenated into a shell command.

The same unsafe construction pattern appears in both the primary skill instructions and the detailed API reference. No requirement is provided to use a JSON serializer, avoid shell interpolation, o ...[truncated 1957 chars]

Remediation
View remediation

Remediation Suggestions

  1. Do not concatenate or substitute user-controlled prompts into shell command strings.
  2. Prefer a structured HTTP client that accepts headers and a serialized object separately from command execution.
  3. If curl must be used, serialize the payload to a file or standard input with a trusted JSON serializer and invoke curl using fixed arguments.
  4. For shell-based implementations, use jq with bound arguments:
    bash
    payload="$(jq -n --arg prompt "$USER_PROMPT" '{
      model: "qwen-image-2.0-pro",
      input: {
        messages: [{
          role: "user",
          content: [{text: $prompt}]
        }]
      },
      parameters: {
        prompt_extend: true,
        watermark: false,
        size: "2048*2048"
      }
    }')"
    
    curl --fail-with-body \
      --request POST \
      'https://dashscope.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation' \
      --header 'Content-Type: application/json' \
      --header "Authorization: Bearer ${DASHSCOPE_API_KEY}" \
      --data-binary "$payload"
    
  5. Pass command arguments as an argument array when invoking a subprocess; never enable a shell for this operation.
  6. Validate documented limits, including prompt length, model names, output dimensions, image count, and seed range. Validation should supplement—not replace—safe argument handling.
  7. Update both SKILL.md and references/api.md so every executable example demonstrates safe handling of untrusted prompts.
  8. Run the skill under a least-privileged account, restrict outbound network access where practical, and ensure API credentials have minimal permissions and usage limits.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (5)

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The skill description uses very broad activation phrases such as any request to generate images, draw, or mention Qwen/Alibaba image generation, without clear constraints on when the skill should or should not be invoked. Overbroad routing can cause unintended activation and transmission of user prompts to an external service, increasing privacy and authorization risks.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
96% confidence
Finding

This skill is explicitly designed to POST user prompts to an external image-generation API, so external transmission is real rather than hypothetical. In context this is functional, not inherently malicious, but it still creates a security boundary crossing where sensitive user input and API credentials are involved, making misuse or accidental data leakage possible.

Content

Scanner excerpt · SKILL.md (reported line 15)May include surrounding context.

使用 qwen-image-2.0-pro 模型(效果最佳):

bash
curl -X POST 'https://dashscope.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation' \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
  -d '{

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The documentation instructs sending user-supplied prompts directly to DashScope but does not warn that prompt content will leave the local environment and be processed by a third party. In a skill context, this omission can lead to accidental disclosure of sensitive, personal, or proprietary information because users and integrators may not realize the data-sharing boundary.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
94% confidence
Finding

The curl example performs a real outbound authenticated request to an external image-generation API, transmitting prompt text and authorization credentials to a third-party endpoint. In a skill designed to generate images from user input, this behavior is expected, but it is still security-relevant because sensitive user content or environment-held API keys could be exposed if the integration is used without adequate notice and controls.

Content

Scanner excerpt · references/api.md (reported line 63)May include surrounding context.

| parameters.watermark | boolean | 否 | 添加水印,默认 false | | parameters.seed | integer | 否 | 随机种子,范围 [0, 2147483647] |

完整 curl 示例

bash
curl -X POST 'https://dashscope.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation' \

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

The documentation includes authenticated curl examples that send user prompts and related request data to Alibaba Cloud DashScope, but it does not explicitly warn users that prompt contents and metadata leave the local environment and are transmitted to a third-party service. In an agent skill context, this can lead to unintentional disclosure of sensitive user content if prompts are constructed from private data.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.