Back to skill

Security audit

Alibabacloud Bailian Image Creator

Security checks for vulnerabilities and agentic risk

Overview

This image-generation skill is mostly purpose-aligned, but it can automatically change local Alibaba CLI tooling and create, save, recycle, or delete cloud API keys.

Review this before installing if you use Alibaba Cloud credentials on the machine. Prefer providing an existing limited DashScope API key, avoid enabling automatic key creation/deletion unless needed, do not grant full Bailian access, and be aware that prompts and image files or URLs are sent to Alibaba Cloud for processing.

Vulnerability Patterns
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • 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
Findings (3)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/api_key.py:187
Finding

Caller-Controlled Description Can Trigger Deletion of Unrelated Cloud API Keys

Content
View full analysis
tuple[str, str]: ``` ```python if not _retry: existing_keys = _list_cloud_api_keys(workspace_id) orphans = [k for k in existing_keys if description in k.get("description", "")] for orphan in orphans: orphan_id = str(orphan.get("apiKeyId", "")) if orphan_id: print(f" Cleaning up orphan key from previous attempt: ID={orphan_id}", file=sys.stderr) _delete_cloud_api_key(orphan_id) ``` The API-key-limit recovery path repeats the same unsafe ownership test: ```python if not _retry and ("Limit" in stderr or "limit" in stderr.lower()): print("Warning: API Key count has reached the limit. Attempting to recycle old keys from this skill...", file=sys.stderr) existing_keys = _list_cloud_api_keys(workspace_id) # Only recycle keys created by this skill (matched by description), never touch other keys recyclable = [k for k in existing_keys if description in k.get("description", "")] if recyclable: old_key_id = str(recyclable[0].get("apiKeyId", "")) old_key_desc = recyclable[0].get("description", "") if old_key_id: print(f" Found recyclable old key: ID={old_key_id}, description='{old_key_desc}'", file=sys.stderr) delete_result = _delete_cloud_api_key(old_key_id) if delete_result["success"]: print(f"Old key recycled (ID: {old_key_id}). Recreating...", file=sys.stderr) return generate_api_key(description, _retry=True) ``` ### Technical Analysis The public `generate_api_key()` function accepts a ...[truncated 2345 chars]
Remediation
View remediation

T08 · Insecure Dependencies

Warning
Location
scripts/api_key.py:63
Finding

Routine Credential Retrieval Automatically Installs an Unpinned Pre-Release CLI Plugin

Content
View full analysis
bool: """Auto-install ModelStudio plugin if missing.""" try: print("Auto-installing ModelStudio plugin...", file=sys.stderr) result = subprocess.run( ["aliyun", "plugin", "install", "--names", "aliyun-cli-modelstudio", "--enable-pre"], capture_output=True, text=True, timeout=60 ) if result.returncode == 0: print("ModelStudio plugin installed successfully", file=sys.stderr) return True print(f"Warning: ModelStudio plugin installation failed: {result.stderr.strip()}", file=sys.stderr) return False except (subprocess.TimeoutExpired, FileNotFoundError): return False ``` The installation is automatically reached by the availability check: ```python def check_aliyun_cli() -> bool: """Check if Alibaba Cloud CLI and ModelStudio plugin are available, auto-install plugin if missing.""" if not _check_aliyun_binary(): return False # Check ModelStudio plugin try: result = subprocess.run( ["aliyun", "modelstudio", "version"], capture_output=True, text=True, timeout=5 ) if result.returncode == 0: return True except (subprocess.TimeoutExpired, FileNotFoundError): pass # Plugin not installed, try auto-install if not _install_modelstudio_plugin(): return False # Verify after installation try: result = subprocess.run( ["aliyun", "modelstudio", "version"], capture_output=True, text=True, timeout=5 ) return result.returncode == 0 except (subprocess.Timeou ...[truncated 2204 chars]
Remediation
View remediation

T05 · Unauthorized Access and Privilege Escalation

Warning
Location
references/ram-policies.md:34
Finding

Documentation Recommends Full Bailian Access Beyond Required Image Functionality

Content
View full analysis
Remediation
View remediation
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Rogue AgentSelf-Modification, Session Persistence
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
Findings (24)

Credential Access

High
Category
Privilege Escalation
Confidence
82% confidence
Finding

Although phrased as a prohibition, this section confirms the skill is designed to interact with sensitive credentials obtained from config files, environment variables, and CLI output. Combined with automatic key management, this materially increases the credential exposure surface: a compromised or overly permissive script could read, create, persist, or leak API keys despite the markdown saying not to.

Content

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

md
1. **Key retrieval is automated**: Scripts internally call `api_key.py` to automatically obtain keys from config files/environment variables, or auto-create via CLI. The Agent only needs to run the script command
2. **Never hardcode any form of key**: Including `api_key = "sk-..."`, `export DASHSCOPE_API_KEY="sk-..."`, and assigning keys in shell scripts
3. **Never extract keys from CLI output**: The key value returned by `aliyun modelstudio create-api-key` is automatically saved by `api_key.py`. The Agent must not write this value into any script, variable, or file
4. **Never expose keys in any output**: Including generated scripts, shell commands, log files (summary.md, task_summary.md, execution_log.md, etc.), and terminal output containing strings starting with `sk-`
5. **Never read or print keys from config files**: Do not use `cat ~/.aliyun/config.json`, `jq`, `python -c`, or other commands to read and output API Key values from config files
6. **Never directly call CLI key commands**: Do not directly run `aliyun modelstudio create-api-key` or `aliyun modelstudio list-api-keys`. These commands are only called internally by `api_key.py`

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The skill description is broad enough to auto-trigger on generic image generation, editing, and analysis requests, which increases the chance of unsolicited execution. In this skill, that is more dangerous because first-run behavior can install plugins and manage cloud API keys, causing account or system side effects for ordinary user prompts.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The skill advertises automatic API key lifecycle actions and CLI/plugin installation but does not present a clear upfront warning that it may modify the user's cloud account and local environment. This can lead to silent credential creation, plugin changes, billing exposure, and persistent system changes when the skill is invoked for a simple image task.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
Confidence
89% confidence
Finding

The skill states that scripts may obtain keys from environment/config or auto-create them via CLI, which can leave usable credentials available across the session or beyond it. This persistence is more risky here because the same skill can perform networked actions and may modify local/cloud state without a tightly bounded credential lifetime visible to the user.

Content

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

md
**Scripts automatically handle key retrieval via `api_key.py`. The Agent does not need to and should not manually extract, set, or pass API Key values.**

1. **Key retrieval is automated**: Scripts internally call `api_key.py` to automatically obtain keys from config files/environment variables, or auto-create via CLI. The Agent only needs to run the script command
2. **Never hardcode any form of key**: Including `api_key = "sk-..."`, `export DASHSCOPE_API_KEY="sk-..."`, and assigning keys in shell scripts
3. **Never extract keys from CLI output**: The key value returned by `aliyun modelstudio create-api-key` is automatically saved by `api_key.py`. The Agent must not write this value into any script, variable, or file
4. **Never expose keys in any output**: Including generated scripts, shell commands, log files (summary.md, task_summary.md, execution_log.md, etc.), and terminal output containing strings starting with `sk-`

Session Persistence

Medium
Category
Rogue Agent
Confidence
90% confidence
Finding

Documenting retrieval priority from ~/.aliyun/config.json, environment variables, and auto-creation via CLI indicates the skill can rely on persistent credentials stored outside the immediate task boundary. That creates a session-persistence risk because future executions or other processes may continue to use the same credentials, increasing blast radius if the environment is compromised.

Content

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

md
This skill manages DashScope API Keys through `scripts/api_key.py`, which automatically validates key format (detects invalid keys like `sk-sp-`).

**Retrieval Priority**: `~/.aliyun/config.json` > Environment variable `DASHSCOPE_API_KEY` > Auto-create via Alibaba Cloud CLI

**Method 1: Alibaba Cloud CLI Config File (Recommended)**

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

This markdown file documents multimodal API calls and explicitly shows passing an image via a local file path (file://) to a remote API. The documentation does not include any warning that local image contents or referenced URLs may be transmitted to an external service, which is a user-facing omission relevant to privacy and data handling.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The module documentation claims local API key management, but the implementation also installs plugins and creates or deletes cloud API keys remotely. This mismatch can mislead users, reviewers, and calling code into granting trust to functionality that performs privileged, networked, and destructive actions beyond the stated scope.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · scripts/api_key.py (reported line 52)May include surrounding context.

python
def _check_aliyun_binary() -> bool:
    """Check if Alibaba Cloud CLI binary is installed."""
    try:
        result = subprocess.run(
            ["aliyun", "version"],
            capture_output=True,
            text=True,

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
92% confidence
Finding

This code automatically installs a CLI plugin by executing the external 'aliyun' binary and enabling a pre-release plugin channel. In a skill context, silently modifying the host environment and pulling executable code from a remote source expands trust boundaries and can lead to supply-chain compromise or unintended code execution if the binary or plugin source is malicious or spoofed.

Content

Scanner excerpt · scripts/api_key.py (reported line 67)May include surrounding context.

python
"""Auto-install ModelStudio plugin if missing."""
    try:
        print("Auto-installing ModelStudio plugin...", file=sys.stderr)
        result = subprocess.run(
            ["aliyun", "plugin", "install",
             "--names", "aliyun-cli-modelstudio", "--enable-pre"],
            capture_output=True,

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · scripts/api_key.py (reported line 89)May include surrounding context.

python
return False
    # Check ModelStudio plugin
    try:
        result = subprocess.run(
            ["aliyun", "modelstudio", "version"],
            capture_output=True,
            text=True,

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · scripts/api_key.py (reported line 104)May include surrounding context.

python
return False
    # Check ModelStudio plugin
    try:
        result = subprocess.run(
            ["aliyun", "modelstudio", "version"],
            capture_output=True,
            text=True,

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · scripts/api_key.py (reported line 126)May include surrounding context.

python
RuntimeError: When unable to retrieve the workspace ID
    """
    try:
        result = subprocess.run(
            ["aliyun", "modelstudio", "list-workspaces",
             "--region", "cn-beijing",
             "--user-agent", "AlibabaCloud-Agent-Skills/alibabacloud-bailian-image-creator"],

Session Persistence

Medium
Category
Rogue Agent
Confidence
60% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · scripts/api_key.py (reported line 145)May include surrounding context.

python
workspaces = data.get("workspaces", [])
        if not workspaces:
            raise RuntimeError(
                "No Bailian Workspace found. Please create one in the console first:\n"
                "  https://bailian.console.aliyun.com/"
            )
        return workspaces[0]["workspaceId"]

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · scripts/api_key.py (reported line 164)May include surrounding context.

python
list: API Key list (each item contains apiKeyId, description, etc.)
    """
    try:
        result = subprocess.run(
            ["aliyun", "modelstudio", "list-api-keys",
             "--region", "cn-beijing",
             "--workspace-id", workspace_id,

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
85% confidence
Finding

This code remotely creates cloud API keys and can be triggered from a retrieval-oriented function path, causing credential provisioning as a side effect. In an agent skill, generating persistent credentials automatically without explicit confirmation increases the blast radius of misuse, can create unmanaged secrets, and may violate least-privilege expectations.

Content

Scanner excerpt · scripts/api_key.py (reported line 236)May include surrounding context.

python
_delete_cloud_api_key(orphan_id)

    try:
        result = subprocess.run(
            ["aliyun", "modelstudio", "create-api-key",
             "--region", "cn-beijing",
             "--workspace-id", workspace_id,

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The get_api_key function is documented as retrieval logic, but it can automatically create a new cloud API key and persist it locally. Hidden credential creation is dangerous because callers may invoke a seemingly read-only function in environments where creating long-lived secrets is unauthorized or unexpected.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
80% confidence
Finding

This subprocess call deletes cloud API keys remotely based on locally stored state and weak ownership checks derived from key descriptions. In a skill context, remote destructive actions against credentials are sensitive, and description-based verification can be bypassed or produce accidental deletion of keys that merely contain the same identifier string.

Content

Scanner excerpt · scripts/api_key.py (reported line 446)May include surrounding context.

python
}

    try:
        result = subprocess.run(
            ["aliyun", "modelstudio", "delete-api-key",
             "--region", "cn-beijing",
             "--api-key-id", api_key_id,

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The script sends base64-encoded local image contents and free-form instructions to a third-party remote API, but it does not provide an explicit privacy warning, confirmation step, or consent mechanism before transmission. This creates a real data disclosure risk because users may process sensitive local images under the assumption they remain local, while the skill silently uploads them off-host.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The script sends user-supplied image data or image references to a third-party remote API for processing, but the function docs and CLI output do not clearly warn users that image content may leave the local environment. This creates a real privacy and data-governance risk, especially if users pass sensitive local files or confidential image URLs under the assumption that analysis is local.

Content

No source excerpt is available for this finding.

Autonomous Decision Making

Medium
Category
Excessive Agency
Confidence
88% confidence
Finding

The script explicitly bypasses the user confirmation step when running in a non-interactive environment, yet still performs a billable external API call. In automation, CI, or agent-driven contexts, this can cause unintended spending and autonomous use of an external service without an explicit approval gate at execution time.

Content

Scanner excerpt · scripts/text_to_image.py (reported line 53)May include surrounding context.

python
print(f"Estimated cost: {estimated_cost:.2f}")
    print("=" * 60)

    # Skip confirmation in non-interactive environments
    if sys.stdin.isatty():
        confirm = input("\nProceed with generation? (y/n): ").strip().lower()
        if confirm not in ['y', 'yes']:

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

This code sends the user prompt and any provided reference image URLs to an external DashScope service via ImageGeneration.call. While the script logs that generation is happening, it does not clearly warn users that their text and image references will be transmitted off-box to a third-party API, which is a privacy-relevant operation.

Content

No source excerpt is available for this finding.

Scope Creep

Low
Category
Excessive Agency
Confidence
70% confidence
Finding

Skill's behavior or capabilities extend beyond its stated purpose. Scope creep allows an agent to perform actions unrelated to its documented functionality, increasing the attack surface.

Content

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

md
- **Do NOT write your own API call code** -- Do not create new Python scripts to call DashScope API. You must use the scripts specified in the "Task-to-Script Mapping" table below
- **Do NOT use PIL/Pillow or other local libraries** for image generation or editing (only allowed for auxiliary operations such as size validation)
- **Do NOT use third-party APIs** -- Including but not limited to Pollinations.ai, Stability.ai, DALL-E, Midjourney
- **Do NOT create mock/simulated scripts** -- Do not bypass real API calls in any way
- **Do NOT use deprecated models** -- `wanx-v1`, `wanx-v2`, `wan2.6-image` and other legacy models are discontinued
- **Do NOT mix APIs** -- Qwen models (qwen-*) can only use `MultiModalConversation.call()`, Wanx models (wan2.7-*) can only use `ImageGeneration.call()`

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
81% confidence
Finding

The natural-language comment and configuration explicitly set the API endpoint to the Beijing region. This imposes a locale/region choice in the skill without user opt-in or an explanation that the tool is intentionally region-specific.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
76% confidence
Finding

The code retrieves an API key and uses it for a remote service call, but the script provides no user-facing notice about credential usage or where the key is sourced from. Under the rule, access to sensitive credentials should have some visible disclosure unless already documented elsewhere in the skill description.

Content

No source excerpt is available for this finding.