Back to skill

Security audit

Image Gen

Security checks for vulnerabilities and agentic risk

Overview

This image-generation skill is mostly purpose-aligned, but it needs Review because its shell script can execute commands from a local .env file and trusts unvalidated external image URLs.

Install only if you trust the publisher and the configured image API. Do not use it with private, regulated, or sensitive images unless you are comfortable sending them to the API provider. Keep the API key out of shared workspaces where possible, restrict .env permissions, inspect .env contents before running, and prefer patching the script to parse config safely, validate HTTPS endpoints, constrain output to the image directory, and verify downloaded files as images.

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 (2)

T09 · Insecure Skill Coding Practices

Warning
Location
image-gen.sh:23
Finding

Arbitrary Shell Execution Through Executable .env Configuration

Content
View full analysis

Vulnerability Details

File Location: image-gen.sh:23-32
Vulnerability Type: Unsafe execution of configuration file contents
Risk Level: Medium

bash
# 检查 .env 文件
if [[ ! -f "$ENV_FILE" ]]; then
    log_error "未找到 .env 文件"
    echo "请在 $SCRIPT_DIR 目录下创建 .env 文件"
    echo "参考 .env.example 文件格式"
    exit 1
fi

# 加载环境变量
source "$ENV_FILE"

Technical Analysis

The script loads its configuration with the Bash source builtin. This treats every line in .env as executable shell code rather than parsing it as inert key-value data.

The Skill only needs to read a small set of configuration values, including IMAGE_API_BASE_URL, IMAGE_API_KEY, IMAGE_MODEL, IMAGE_SIZE, and IMAGE_ASPECT_RATIO. Granting the configuration file the ability to execute arbitrary commands exceeds the minimum privileges necessary for image generation.

Exploitation requires an attacker to create or modify the Skill-local .env file. This could occur through a compromised installation process, another vulnerable component with write access, an untrusted shared workspace, or social engineering that causes a user to install a malicious configuration file.

Attack Path

  1. An attacker obtains the ability to write to the .env file beside image-gen.sh.
  2. The attacker adds a shell command to the file while retaining plausible API configuration entries, for example:
    bash
    IMAGE_API_BASE_URL=https://api.example.invalid
    IMAGE_API_KEY=example
    malicious_command_here
    
  3. A user or agent invokes image-gen.sh for its legitimate image-generation purpose.
  4. Bash reaches source "$ENV_FILE" and executes the attacker-controlled command.
  5. The command runs with the same operating-system identity and permissions as the invoking user or agent.

Impact Assessment

Successful exploitation provides arbitrary command execution with the invoking user's privileges. The attacker could rea ...[truncated 379 chars]

Remediation
View remediation

Remediation Suggestions

  • Do not load .env through source, ., eval, or another shell-execution mechanism.
  • Parse only an explicit allowlist of supported keys and treat all values as data.
  • Reject malformed lines, duplicate security-sensitive keys, command substitutions, shell operators, and unsupported variable names.
  • Validate IMAGE_API_BASE_URL as an HTTPS URL and validate model, size, and aspect-ratio values against expected formats or allowlists.
  • Require the configuration file to be owned by the expected user and not writable by group or other users. Recommended permissions are 0600.
  • Resolve the documentation mismatch: README.md directs users to ~/.openclaw/workspace/.env, while the implementation loads .env from the Skill directory.
  • Prefer receiving the API key from a dedicated secret manager or inherited process environment rather than storing it in the Skill package directory.

T09 · Insecure Skill Coding Practices

Warning
Location
image-gen.sh:116
Finding

Unvalidated Server-Controlled Image Download URL

Content
View full analysis

Vulnerability Details

File Location: image-gen.sh:116-130
Vulnerability Type: Server-side request forgery and unsafe file download
Risk Level: Medium

bash
# 尝试解析图像 URL
# 支持多种响应格式
IMAGE_URL=$(echo "$RESPONSE" | jq -r '.data[0].url // .url // .image_url // empty' 2>/dev/null)

if [[ -z "$IMAGE_URL" || "$IMAGE_URL" == "null" ]]; then
    log_error "未能获取图像 URL"
    echo "响应: $RESPONSE"
    exit 1
fi

# 下载图像
log_info "下载图像到 $OUTPUT..."
curl -s -o "$OUTPUT" "$IMAGE_URL"

if [[ -f "$OUTPUT" ]]; then

Technical Analysis

The image URL is obtained directly from the external API response and passed to curl without validating its scheme, hostname, resolved address, port, or expected content type.

A compromised, malicious, or incorrectly configured image API can therefore direct the client to retrieve a local file or an internal network resource instead of an image. No HTTPS-only restriction, destination allowlist, private-address rejection, response-status check, size limit, or image signature validation is applied.

The script also accepts a caller-selected output path. Consequently, downloaded content can be written to any path writable by the invoking account. The existing file check only verifies that a path exists after curl; it does not prove that the request succeeded or that the result is an image.

Attack Path

  1. A user configures a malicious API base URL, or the configured image API is compromised.
  2. The user invokes the Skill and the script submits an otherwise legitimate image-generation request.
  3. The API returns a response containing an attacker-selected value in data[0].url, url, or image_url.
  4. The attacker supplies a URL targeting a local file, loopback service, private-network host, link-local endpoint, or another unintended destination supported by curl.
  5. The script executes curl -s -o "$OUTPUT" "$IMAGE_URL" without destination validation.
  6. The ...[truncated 1301 chars]
Remediation
View remediation

Remediation Suggestions

  • Accept only https:// image URLs and invoke curl with --proto '=https'.
  • Allowlist trusted image-delivery hostnames rather than trusting arbitrary hosts returned by the API.
  • Resolve the destination and reject loopback, private, link-local, multicast, unspecified, and reserved IP ranges for both IPv4 and IPv6.
  • Account for DNS rebinding by validating the address actually used for the connection, not only an earlier lookup.
  • Use curl --fail --show-error and configure connection, total-time, and maximum-file-size limits.
  • Avoid redirects or validate every redirect destination before following it.
  • Download to a newly created file in a dedicated image directory rather than accepting an arbitrary output path.
  • Verify the response Content-Type, then inspect the file signature and decode it with a trusted image library before accepting it.
  • Refuse to overwrite existing files and use restrictive permissions for newly created outputs.
  • Delete partial or invalid downloads when validation fails.
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
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
Findings (21)

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

声明描述的是一个以 AI 图像生成/编辑为核心的技能,压缩图片只是其辅助能力之一。但实际代码块完全聚焦于图片压缩:读取本地文件、根据大小阈值降低质量或缩放尺寸、保存输出并打印压缩结果。它不包含任何模型调用、文本提示处理、参考图生成、编辑流水线、飞书集成或固定目录管理。因此该代码与声明的主要目的存在明显且实质性的偏差,应判定为描述与行为不匹配。

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
91% confidence
Finding

The core declared purpose of text-to-image and image-to-image generation is represented by the code: it accepts a prompt, optionally encodes a reference image, calls an image generation API, and downloads the output. However, several material details in the description are not implemented in this code chunk. There is no logic for compressing large images, no enforced saving to a workspace/img directory (it saves to the provided output path or a generated filename in the current context), and no code for directly displaying the image in Feishu. These are behavior-description mismatches significant enough to flag, even though the primary image-generation purpose is broadly accurate.

Content

No source excerpt is available for this finding.

Credential Access

High
Category
Privilege Escalation
Confidence
83% confidence
Finding

The skill instructs users to place an API key in a .env file under the workspace, which may be accessible to other skills, tools, or accidental file operations in the same environment. Storing credentials in a broadly accessible workspace increases the risk of credential disclosure and reuse by unrelated components.

Content

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

在workspace目录下创建 .env 文件:

bash
# .env
IMAGE_API_BASE_URL=https://api.imyaigc.top
IMAGE_API_KEY=your-api-key-here
IMAGE_MODEL=gemini-3.1-flash-image-preview

Missing User Warnings

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

The skill explicitly describes downloading reference images, converting them to base64, and sending them to a third-party image API, but it does not clearly warn users that their images and prompts leave the local environment. This creates a significant privacy and compliance risk, especially when reference images may contain personal, confidential, or copyrighted material.

Content

No source excerpt is available for this finding.

Credential Access

High
Category
Privilege Escalation
Confidence
81% confidence
Finding

Documenting .env as part of the skill directory structure reinforces the expectation that credentials reside alongside skill files in a potentially inspectable location. In multi-skill or shared-workspace environments, this increases the chance of accidental inclusion, disclosure, or exfiltration of API secrets.

Content

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

├── SKILL.md # 本说明文件 ├── image-gen.sh # 生成脚本 ├── compress_image.py # 压缩工具 ├── .env # API 配置 └── .env.example # 配置示例

text

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · image-gen.sh (reported line 11)May include surrounding context.

sh
# 获取脚本所在目录
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ENV_FILE="$SCRIPT_DIR/.env"

# 颜色输出
GREEN='\033[0;32m'

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · README.md (reported line 32)May include surrounding context.

md
log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
log_error() { echo -e "${RED}[ERROR]${NC} $1"; }

# 检查 .env 文件
if [[ ! -f "$ENV_FILE" ]]; then
    log_error "未找到 .env 文件"
    echo "请在 $SCRIPT_DIR 目录下创建 .env 文件"

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · image-gen.sh (reported line 23)May include surrounding context.

sh
log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
log_error() { echo -e "${RED}[ERROR]${NC} $1"; }

# 检查 .env 文件
if [[ ! -f "$ENV_FILE" ]]; then
    log_error "未找到 .env 文件"
    echo "请在 $SCRIPT_DIR 目录下创建 .env 文件"

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · image-gen.sh (reported line 25)May include surrounding context.

sh
log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
log_error() { echo -e "${RED}[ERROR]${NC} $1"; }

# 检查 .env 文件
if [[ ! -f "$ENV_FILE" ]]; then
    log_error "未找到 .env 文件"
    echo "请在 $SCRIPT_DIR 目录下创建 .env 文件"

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · image-gen.sh (reported line 26)May include surrounding context.

sh
log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
log_error() { echo -e "${RED}[ERROR]${NC} $1"; }

# 检查 .env 文件
if [[ ! -f "$ENV_FILE" ]]; then
    log_error "未找到 .env 文件"
    echo "请在 $SCRIPT_DIR 目录下创建 .env 文件"

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · image-gen.sh (reported line 36)May include surrounding context.

sh
log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
log_error() { echo -e "${RED}[ERROR]${NC} $1"; }

# 检查 .env 文件
if [[ ! -f "$ENV_FILE" ]]; then
    log_error "未找到 .env 文件"
    echo "请在 $SCRIPT_DIR 目录下创建 .env 文件"

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The README states that user-provided reference images are downloaded and then sent to an external image-generation API, but it does not clearly warn users that their uploaded content will leave the local environment. This creates a real privacy and data-handling risk, especially if users provide sensitive, proprietary, or personal images under the assumption processing is local.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
92% confidence
Finding

The skill documentation instructs use of shell commands and file writes, but it does not declare any explicit tool scope or permissions boundary. In an agent environment, missing scope declarations can allow the skill to be invoked with broader-than-expected capabilities, increasing the risk of unintended file modification or command execution.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The trigger conditions are broad enough to match normal conversation about drawing or modifying images, which can cause unintended activation of a skill that sends prompts and possibly user-supplied images to an external service. In a chat agent, accidental invocation can become a privacy and data-handling issue even if the underlying function is legitimate.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
89% confidence
Finding

The skill sends user prompts and potentially embedded reference image data to an external network endpoint via curl. External transmission is expected for an image-generation skill, but without strong notice, consent, and endpoint validation, it creates exposure of user content and increases the attack surface for data leakage.

Content

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

  1. 调用 API
    bash
    curl -X POST "${IMAGE_API_BASE_URL}/v1/images/generations" \
        -H "Authorization: Bearer ${IMAGE_API_KEY}" \
        -H "Content-Type: application/json" \
        -d '{
    

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
98% confidence
Finding

Mandating automatic translation of user prompts into English without opt-in can change the semantic content of user instructions and cause unintended disclosure to translation or model-processing components. It also removes user control over how potentially sensitive text is transformed before being sent to an external API.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

This file contains natural-language descriptions and usage text exclusively in Chinese, including the module docstring and command-line help/error messages. Under the stated policy, forcing a specific language without opt-in or a documented locale-specific justification is a natural-language policy violation.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
96% confidence
Finding

The script transmits user prompts, and in image-to-image mode the full reference image as base64, to a URL taken from .env without validation or allowlisting. If that endpoint is malicious or misconfigured, sensitive user content and API credentials can be sent to an untrusted external service, which is more dangerous here because the skill explicitly handles potentially private images.

Content

Scanner excerpt · image-gen.sh (reported line 110)May include surrounding context.

sh
fi

# 调用 API
RESPONSE=$(curl -s -X POST "${IMAGE_API_BASE_URL}/v1/images/generations" \
    -H "Authorization: Bearer ${IMAGE_API_KEY}" \
    -H "Content-Type: application/json" \
    -d "$JSON_PAYLOAD")

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

Automatically translating prompts to English without clearly disclosing it or offering user choice can expose sensitive or regulated text to additional processing and alter user intent. While lower severity than direct credential or code-execution issues, it is still a meaningful transparency and privacy concern because user inputs may be transformed and potentially sent externally in a different form than expected.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

The file’s natural-language comments and usage instructions are presented only in Chinese, and the script’s user-facing messages are likewise fixed to that locale. This can violate a language/locale policy when no user opt-in or documented region-specific justification is provided.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Low
Category
Not specified by scanner
Confidence
79% confidence
Finding

The script requires and sources a local .env file, then reads IMAGE_API_BASE_URL and IMAGE_API_KEY before contacting the image API. While external API use is expected for an image-generation skill, direct credential loading from local environment/config files is an extra capability not reflected in the manifest's user-facing description.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.