Back to skill

Security audit

爆款封面图片生成与编辑

Security checks for vulnerabilities and agentic risk

Overview

The skill mostly matches its image-generation purpose, but a filename handling flaw could let compromised API results write files outside the intended download folder.

Review before installing. The skill sends prompts and any selected reference images to AI Hive and stores an API key locally if you run init. The main issue to require fixing is filename sanitization and output-directory containment for downloaded results; using a dedicated output folder and avoiding sensitive working directories reduces impact but does not fully address the bug.

Vulnerability Patterns
  • 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
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
Findings (2)

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/imagegen.py:350
Finding

Server-Controlled Output Filename Allows Path Traversal

Content
View full analysis

Vulnerability Details

File Location: scripts/imagegen.py:350-364; file-write sink at scripts/imagegen.py:263-283
Vulnerability Type: Path traversal and arbitrary file overwrite
Risk Level: Medium

Vulnerable Code

python
task_type = task.get("taskType", "task")
for i, item in enumerate(succeeded):
    result_url = item.get("resultUrl")
    if not result_url:
        continue
    ext = ".mp4" if "video" in task_type.lower() else ".png"
    filename = f"{task_type}_{task_id}_{i+1}{ext}"
    out_path = out_dir / filename
    download_file(result_url, out_path)

for item in succeeded:
    last_frame = item.get("lastFrameUrl")
    if last_frame:
        out_path = out_dir / f"{task_type}_{task_id}_lastframe.png"
        download_file(last_frame, out_path)

The resulting path is subsequently opened for writing:

python
def download_file(url, out_path, timeout=300):
    try:
        resp = requests.get(url, stream=True, timeout=timeout)
        resp.raise_for_status()
        total = int(resp.headers.get("content-length", 0))
        downloaded = 0
        with open(str(out_path), "wb") as f:
            for chunk in resp.iter_content(chunk_size=8192):
                if chunk:
                    f.write(chunk)

Technical Analysis

The taskType field is obtained from the remote task response and is incorporated directly into a local filename without validation, sanitization, or canonical-path containment checks. The server-issued task_id is also incorporated into the filename.

A crafted value containing path components such as ../ can cause Python's Path joining operation to resolve the output outside the intended out_dir. The resulting path is passed to open(..., "wb"), which creates a new file or truncates an existing file when the current user has sufficient filesystem permissions.

TLS reduces the likelihood of ordinary network interception, but it does not protect against a compromised service, malicious upstr ...[truncated 1555 chars]

Remediation
View remediation

Remediation Suggestions

Do not derive local filenames directly from remote response metadata.

  1. Generate filenames from locally controlled constants and counters, for example:
python
filename = f"image_{i + 1}.png"
  1. If remote identifiers must appear in filenames, restrict each identifier to a conservative allowlist:
python
import re

def safe_component(value, fallback):
    value = str(value)
    if not re.fullmatch(r"[A-Za-z0-9_-]{1,100}", value):
        return fallback
    return value
  1. Resolve and verify the final path before writing:
python
base = Path(output_dir).expanduser().resolve()
candidate = (base / filename).resolve()

if candidate.parent != base:
    raise SystemExit("Refusing to write outside the output directory")

For subdirectories, use candidate.is_relative_to(base) on supported Python versions instead of requiring the direct parent to equal the base.

  1. Reject absolute paths, path separators, . components, and .. components in every remote value used in a filename.

  2. Consider exclusive file creation or explicit overwrite confirmation to prevent silent truncation of existing files.

  3. Apply the same containment validation to normal result downloads and last-frame downloads.

T08 · Insecure Dependencies

Note
Location
SKILL.md:72
Finding

Unpinned Third-Party Dependency Installation

Content
View full analysis

Vulnerability Details

File Location: SKILL.md:72; also referenced by scripts/imagegen.py:7 and scripts/imagegen.py:21
Vulnerability Type: Unpinned dependency and non-reproducible package installation
Risk Level: Low

Vulnerable Code

bash
pip3 install requests

Technical Analysis

The project instructs users to install requests without a version constraint, lockfile, package hash, isolated environment, or explicitly trusted package index. Package resolution therefore depends on the user's current pip configuration and whichever package version is available at installation time.

Although requests is a legitimate and widely used package, this installation process is not reproducible. It inherits risks from compromised or incorrectly configured package indexes, unexpected future releases, dependency-resolution changes, and transitive dependency changes.

Imported Python packages execute code with the privileges of the user running the script. The finding concerns dependency acquisition controls; the audited project does not itself demonstrate that the legitimate requests package is malicious.

Attack Path

  1. A user follows the documented pip3 install requests instruction.
  2. pip resolves the package and its transitive dependencies from the user's configured index or mirror.
  3. A compromised, malicious, or incorrectly configured repository supplies an untrusted artifact, or dependency resolution selects an unreviewed incompatible release.
  4. The package is installed into the selected Python environment.
  5. The skill imports requests, causing installed package code to execute with the user's privileges.

Impact Assessment

If dependency resolution is compromised, arbitrary Python code may execute with the privileges of the account installing or running the package. The potential scope includes access to that user's files, environment variables, API keys, and network permissions.

The practical risk is low wh ...[truncated 178 chars]

Remediation
View remediation

Remediation Suggestions

  1. Add a reviewed, version-pinned dependency file, such as:
text
requests==2.32.5
  1. For stronger integrity protection, include hashes and require them during installation:
bash
python3 -m pip install --require-hashes -r requirements.txt
  1. Generate and commit a lockfile that pins transitive dependencies as well as direct dependencies.

  2. Recommend installation in a dedicated virtual environment:

bash
python3 -m venv .venv
. .venv/bin/activate
python3 -m pip install --require-hashes -r requirements.txt
  1. Document the expected trusted package source and advise users to review custom pip index and mirror configuration.

  2. Establish a dependency-update process that periodically reviews security advisories and deliberately refreshes pinned versions and hashes.

Vulnerability Patterns
  • 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
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
Findings (6)

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
91% confidence
Finding

The skill invokes a Python script that can use shell execution, local files, environment data, and outbound network access, but the manifest does not declare any explicit tool/permission scope. That mismatch weakens least-privilege controls and makes it harder for a host to constrain execution, increasing the risk of unintended file access, secret exposure from environment variables, or unreviewed network egress if the script or its inputs are later changed or abused.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
87% confidence
Finding

The description says to use this skill for a wide range of cover-image tasks, including generic phrases like 'viral cover' and multiple platform cover types, without defining narrower invocation constraints or exclusion conditions. In a manifest-style description, this breadth can cause unintended activation for ordinary image-editing requests that are not specifically about this skill's intended workflow.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The module docstring is entirely in Chinese and presents the tool as a user-facing CLI without any indication that another language is supported. Under the policy, forcing a specific language or locale without user opt-in is a natural-language policy violation unless the constraint is documented and justified, which is not present here.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The script's runtime output, errors, and interactive prompts are consistently hard-coded in Chinese, indicating that users must interact in that language. Because no locale selection or opt-in mechanism is provided, this conflicts with the language/locale policy for natural-language behavior.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
81% confidence
Finding

The description forces a mixed-language presentation in Chinese and English but does not indicate that the user can choose their preferred language or locale. This can violate language/locale policy expectations when a skill imposes a particular language format without opt-in.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Low
Category
Not specified by scanner
Confidence
87% confidence
Finding

The manifest describes a skill for generating and editing viral cover images via AI Hive. The code also implements an interactive credential bootstrap flow that opens a browser, guides the user through account actions, and stores an API key locally, which is ancillary account-management functionality rather than a direct image-generation/editing capability.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.