Back to skill

Security audit

抖音爆款封面生成与编辑

Security checks for vulnerabilities and agentic risk

Overview

The skill mostly fits a Douyin cover generator, but it handles persistent API credentials and has under-scoped network and file-write behavior that users should review before installing.

Install only if you trust the AI Hive service and this publisher, keep the API key scoped and revocable, avoid custom AI_HIVE_BASE_URL or --base-url values, and run it in a contained environment with a dedicated output directory because downloaded files and API responses influence local writes.

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

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/imagegen.py:91
Finding

Unrestricted API endpoint can disclose the bearer token

Content
View full analysis

Vulnerability Details

File Location: scripts/imagegen.py:91-100, scripts/imagegen.py:130-143, scripts/imagegen.py:776-777, scripts/imagegen.py:813
Vulnerability Type: User-controlled API endpoint with credential forwarding
Risk Level: Medium

Vulnerable Code

python
def _resolve_base_url(self, cli_url):
    if cli_url:
        return cli_url.rstrip("/")
    env_url = os.environ.get("AI_HIVE_BASE_URL")
    if env_url:
        return env_url.rstrip("/")
    file_config = self._read_config_file()
    if file_config.get("base_url"):
        return file_config["base_url"].rstrip("/")
    return DEFAULT_BASE_URL
python
def __init__(self, config):
    self.config = config
    self.base = config.base_url
    self.headers = {
        "Authorization": f"Bearer {config.api_key}",
        "Content-Type": "application/json",
    }

def _url(self, path):
    return f"{self.base}/openapi/v1/{path}"

def _request(self, method, url, **kwargs):
    self.config.log(f"{method} {url}")
    try:
        resp = requests.request(
            method, url, headers=self.headers, timeout=DEFAULT_TIMEOUT, **kwargs
        )
python
parser.add_argument("--base-url", help=f"API Base URL (default {DEFAULT_BASE_URL})")

Technical Analysis

The API base URL can be supplied through a command-line argument, the AI_HIVE_BASE_URL environment variable, or the local configuration file. The implementation does not enforce HTTPS or restrict the destination to an approved hostname.

The same AI Hive API key is subsequently placed in the Authorization header for every request sent to the selected endpoint. Consequently, an attacker who controls the endpoint configuration can cause the client to transmit the bearer credential to an attacker-operated server. Supplying an unencrypted HTTP endpoint would also expose the credential to network interception.

Attack Path

...[truncated 992 chars]

Remediation
View remediation

Remediation Suggestions

  • Restrict normal operation to an explicit allowlist such as https://ai-hive.iclip.cn/api.
  • Parse the URL with urllib.parse.urlparse and require the https scheme, the expected hostname, and an approved path prefix.
  • Reject URLs containing user information, unexpected ports, fragments, or ambiguous hostname representations.
  • Do not send the production bearer token to a custom host. If custom endpoints are required for development, require a separate credential and an explicit high-friction opt-in.
  • Warn or fail securely when the environment or configuration file attempts to override the production endpoint.
  • Add automated tests covering HTTP URLs, lookalike domains, embedded credentials, redirects, and localhost/private-network destinations.

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/imagegen.py:399
Finding

Server-controlled task metadata permits output path traversal

Content
View full analysis

Vulnerability Details

File Location: scripts/imagegen.py:399-414
Vulnerability Type: Path traversal and arbitrary file overwrite
Risk Level: Medium

Vulnerable Code

python
out_dir = Path(output_dir)
out_dir.mkdir(parents=True, exist_ok=True)
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)

Technical Analysis

The local output filename incorporates taskType from the API response and task_id from API or command-line data without sanitizing either value as a filename component. Values containing directory separators or .. path components can cause out_dir / filename to resolve outside the requested output directory.

download_file() subsequently opens the derived path in "wb" mode, which creates or truncates the target file. Therefore, a malicious or compromised API endpoint can combine crafted task metadata with attacker-controlled response content to overwrite files writable by the current user.

Attack Path

  1. The attacker controls or compromises the configured API endpoint.
  2. The user submits or queries a generation task.
  3. The endpoint returns a completed task whose taskType contains traversal components such as ../../target.
  4. poll_task() concatenates the untrusted value into the output filename.
  5. Path resolution escapes output_dir.
  6. download_file() fetches the attacker's resultUrl and opens the escaped path in write mode.
  7. The selecte ...[truncated 551 chars]
Remediation
View remediation

Remediation Suggestions

  • Do not use server-provided task metadata as a local filename. Use a fixed local prefix and a locally generated random identifier.
  • If identifiers must be retained, allow only a strict character set such as [A-Za-z0-9_-] and reject all separators, dot components, control characters, and absolute paths.
  • Resolve both the output directory and candidate path with Path.resolve(), then verify that the candidate remains under the resolved output directory.
  • Create files using exclusive creation where overwriting is unnecessary.
  • Detect and reject symbolic-link targets where applicable.
  • Store each task in a dedicated, randomly named directory with restrictive permissions.
  • Apply the same validation to normal results and last-frame output paths.

T09 · Insecure Skill Coding Practices

Note
Location
scripts/imagegen.py:312
Finding

Generated media downloads trust arbitrary URLs and unbounded response bodies

Content
View full analysis

Vulnerability Details

File Location: scripts/imagegen.py:312-326, scripts/imagegen.py:399-414
Vulnerability Type: Unrestricted outbound request and unbounded file download
Risk Level: Low

Vulnerable Code

python
def download_file(url, out_path, timeout=300):
    """流式下载文件,带进度条显示。"""
    print(f"[download] {out_path.name}")
    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)
                    downloaded += len(chunk)
                    if total > 0:
                        pct = int(downloaded * 100 / total)
                        bar = "█" * (pct // 5) + "░" * (20 - pct // 5)
                        print(f"\r  {bar} {pct}% ({downloaded // 1024}KB)", end="", flush=True)
python
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)

Technical Analysis

resultUrl and lastFrameUrl originate in API responses and are passed directly to requests.get(). The implementation does not validate the URL scheme, hostname, resolved address, redirect destination, response media type, or file signature.

The download loop also has no maximum byte count. Streaming controls memory consumption but does not prevent an attacker from continuously supplying data or returning a response la ...[truncated 1274 chars]

Remediation
View remediation

Remediation Suggestions

  • Require HTTPS for generated-media downloads.
  • Allowlist the object-storage domains expected to host AI Hive results.
  • Resolve hostnames and reject loopback, private, link-local, multicast, and otherwise non-public addresses.
  • Revalidate the destination after every redirect or disable redirects and handle them under the same policy.
  • Enforce a maximum download size using both Content-Length and a running byte counter.
  • Abort and delete partial files when the byte limit, timeout, or validation policy is violated.
  • Validate the returned Content-Type and inspect file signatures before accepting the output.
  • Use separate connect and read timeouts and, where supported, enforce an overall transfer deadline.

T08 · Insecure Dependencies

Note
Location
SKILL.md:88
Finding

Third-party dependency installation is unpinned

Content
View full analysis

Vulnerability Details

File Location: SKILL.md:88-94, scripts/imagegen.py:12-18
Vulnerability Type: Unpinned third-party dependency
Risk Level: Low

Vulnerable Code

bash
pip3 install requests
python3 "$SKILL_PATH/scripts/imagegen.py" init --skill-name douyin-viral-cover-image-generation
python3 "$SKILL_PATH/scripts/imagegen.py" task --task-id <taskId>
python
try:
    import requests
except ImportError:
    print("缺少依赖:requests。请运行 pip3 install requests", file=sys.stderr)
    sys.exit(1)

Technical Analysis

The installation instructions request the latest package available under the requests name from the operator's configured Python package index. No exact version, integrity hash, lock file, or trusted index is specified.

The package name is legitimate and the project does not explicitly direct users to an unsafe package source. Nevertheless, the installation is not reproducible and implicitly trusts both the currently selected package index and whichever package version is latest at installation time.

Attack Path

  1. The user follows the documented pip3 install requests instruction.
  2. The user's package-index configuration has been altered, compromised, or points to an untrusted mirror; alternatively, a future package release is compromised.
  3. Pip resolves and installs the unreviewed package artifact without checking a project-supplied integrity hash.
  4. Package installation or subsequent import executes code with the privileges of the user running pip or the Skill.

Impact Assessment

A compromised dependency could execute arbitrary Python code with the privileges of the installing or invoking user. That code could access files, environment variables, and credentials available to that account, including the AI Hive API key. Exploitation depends on compromise or manipulation of the dependency source; no malicious dependency is present in the audi ...[truncated 19 chars]

Remediation
View remediation

Remediation Suggestions

  • Pin requests and its transitive dependencies to reviewed versions in a lock file.
  • Use hash verification, such as pip's --require-hashes, with approved SHA-256 digests.
  • Document and enforce a trusted Python package index.
  • Install dependencies in an isolated virtual environment rather than the system Python environment.
  • Use automated dependency scanning and a controlled process for reviewing and updating pinned versions.
  • Replace the generic installation message with a command that installs from the project's reviewed lock or requirements file.
Vulnerability Patterns
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
Findings (8)

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

The documented purpose is a narrow Douyin cover generator, but the underlying behavior reportedly includes broader AI operations such as chat, multimodal use, video generation, model discovery, user/account queries, general media upload, and browser-based API-key setup. This mismatch is dangerous because users and orchestrators may grant the skill trust and inputs appropriate for a simple image-cover workflow while the implementation can perform materially broader actions and data flows than advertised.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
91% confidence
Finding

The skill invokes a local Python script with shell, file, environment, and network capabilities but does not declare any tool scope or permissions boundary. That creates unnecessary implicit trust: an agent or reviewer cannot tell from the manifest what resources the skill may access, increasing the chance of over-broad execution and misuse of local files, secrets, or outbound network access.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The manifest description and the body of the skill consistently require Chinese-language cover text, including explicit instructions such as '必须出现中文时' and examples with fixed Chinese titles. This imposes a language constraint across the skill without any user opt-in or documented justification that the skill is limited to Chinese-only use.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The module docstring and nearly all user-facing prompts/messages are written only in Chinese, establishing a fixed language/locale for interaction. For a general-purpose '通用 AI 能力调用工具', this is a natural-language locale constraint without any user choice or explicit justification.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The init flow opens a browser, guides the user through API key retrieval, and writes credentials to ~/.ai-hive/config.json. For a skill whose stated purpose is generating Douyin cover images, credential onboarding and local secret persistence are platform-management capabilities rather than domain-specific cover-generation functionality.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The manifest describes a focused skill for generating and editing Douyin cover images, but the wrapped skill CLI additionally exposes generic task, upload, and init operations, and the underlying module is a general AI Hive client with user-info, model listing, chat, image, and video support. While image generation itself fits the manifest, these broader utility and platform-management behaviors go beyond the claimed end-user purpose of cover creation.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
91% confidence
Finding

The substantive changelog entries are written in Chinese throughout the file, with no indication that the skill is region-specific or that users can choose another language. Under the policy, fixed language behavior without opt-in or justification can be a natural-language policy violation.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

The example API key value contains Chinese-only instructional text ('请替换为你的APIKey'), which imposes a specific language in a user-facing configuration artifact. There is no indication that the skill is region-specific or that users can choose their preferred language, so this appears to violate the language/locale policy criteria.

Content

No source excerpt is available for this finding.