Back to skill

Security audit

AI图像创作

Security checks for vulnerabilities and agentic risk

Overview

This skill is a straightforward Juhe image-generation helper, but users should handle the API key carefully and understand it downloads provider-returned image URLs.

Install only if you are comfortable sending prompts and your Juhe API key to Juhe's image API. Prefer a platform secret store or environment variable for JUHE_IMAGE_KEY; avoid the --key command-line option and avoid committing scripts/.env. Use --no-download or a contained output directory if you do not want automatic downloads from provider-returned image links.

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
scripts/image_generate.py:153
Finding

API Key Exposure Through Command-Line Arguments

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/image_generate.py:118
Finding

Unvalidated API-Controlled Image URL Download

Content
View full analysis
str | None: """下载图片到本地,返回保存路径或 None""" output_dir.mkdir(parents=True, exist_ok=True) timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") filename = f"image_{timestamp}.png" save_path = output_dir / filename try: urllib.request.urlretrieve(url, save_path) return str(save_path) except Exception as e: print(f"⚠️ 图片下载失败: {e}") print(f" 请手动访问链接保存图片(24小时内有效)") return None ``` The URL originates from the remote API response: ```python image_url = result.get("result", {}).get("image", "") ``` ### Technical Analysis The script automatically passes the API-provided `image` value to `urllib.request.urlretrieve()` without validating: - The URL scheme - The destination hostname - Resolved IP addresses - Redirect destinations - Response content type or file signature - Response size The URL is therefore controlled by the API response rather than by a trusted local constant. If the service, an upstream component, or the response path is compromised, a malicious URL could direct the client to loopback services, private network systems, link-local cloud metadata endpoints, or a non-HTTP resource supported by the URL handler. The downloaded response is written with a `.png` extension regardless of its actual content. There is also no maximum response-size limit, allowing an unexpectedly large resource to consume local disk space. Automatic image download is part of the declared functionality, but unrestricted destination and protocol access are not necessary; a constrained HTTPS download from approved image-delivery hosts would satisfy least privilege. ### Attack Path 1. An attacker compromises or influences the image-genera ...[truncated 1486 chars]
Remediation
View remediation
Vulnerability Patterns
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (8)

Credential Access

High
Category
Privilege Escalation
Confidence
87% confidence
Finding

The documentation encourages storing the API key in a local .env file under the scripts directory, which is a common path that may be accidentally committed, packaged, or exposed to other tooling. In a skill context that already uses filesystem access, this increases the risk of credential leakage and unauthorized third-party API use.

Content

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

md
# 方式一:环境变量(推荐,一次配置永久生效)
export JUHE_IMAGE_KEY=你的AppKey

# 方式二:.env 文件(在脚本目录创建)
echo "JUHE_IMAGE_KEY=你的AppKey" > scripts/.env

# 方式三:每次命令行传入

Credential Access

High
Category
Privilege Escalation
Confidence
84% confidence
Finding

The skill explicitly tells users to write JUHE_IMAGE_KEY into scripts/.env, a plaintext location adjacent to executable code. This makes accidental disclosure more likely through source control, backups, logs, or other agents/tools that can read the workspace, enabling API key theft and quota abuse.

Content

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

md
export JUHE_IMAGE_KEY=你的AppKey

# 方式二:.env 文件(在脚本目录创建)
echo "JUHE_IMAGE_KEY=你的AppKey" > scripts/.env

# 方式三:每次命令行传入
python scripts/image_generate.py --key 你的AppKey "一只猫咪在草地上玩耍"

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 · scripts/image_generate.py (reported line 15)May include surrounding context.

python
API Key 配置(任选其一,优先级从高到低):
    1. 环境变量: export JUHE_IMAGE_KEY=your_api_key
    2. 脚本同目录的 .env 文件: JUHE_IMAGE_KEY=your_api_key
    3. 直接传参: python image_generate.py --key your_api_key "提示词"

免费申请 API Key: https://www.juhe.cn/docs/api/id/824

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 · scripts/image_generate.py (reported line 230)May include surrounding context.

python
API Key 配置(任选其一,优先级从高到低):
    1. 环境变量: export JUHE_IMAGE_KEY=your_api_key
    2. 脚本同目录的 .env 文件: JUHE_IMAGE_KEY=your_api_key
    3. 直接传参: python image_generate.py --key your_api_key "提示词"

免费申请 API Key: https://www.juhe.cn/docs/api/id/824

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 · scripts/image_generate.py (reported line 52)May include surrounding context.

python
if env_key:
        return env_key

    env_file = Path(__file__).parent / ".env"
    if env_file.exists():
        for line in env_file.read_text(encoding="utf-8").splitlines():
            line = line.strip()

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
88% confidence
Finding

The skill instructs use of environment variables, local file access, and outbound network requests, but does not declare any explicit tool scope or permission boundaries. This can lead to over-broad execution in an agent environment, where the skill may gain more access than users or reviewers expect, increasing the chance of unintended secret exposure or filesystem/network misuse.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
87% confidence
Finding

The entire skill description and usage guidance are written only in Chinese, and examples/instructions assume Chinese-language operation. Under the stated policy, a skill that imposes a specific language without user opt-in can be a natural-language policy violation unless the locale constraint is explicitly justified, which is not documented here.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
93% confidence
Finding

The module docstring and all usage/help text are written in Chinese, and the script presents Chinese-only prompts and status messages throughout execution. This imposes a specific language on users without any opt-in or documented locale constraint, which matches the language/locale policy-violation category.

Content

No source excerpt is available for this finding.