Back to skill

Security audit

精准中文文字商业图片|GPT Image 2 文案合同

Security checks for vulnerabilities and agentic risk

Overview

This skill is a coherent Chinese commercial-poster image workflow that uploads only user-specified images to AI Hive and saves generated results, with a few integration risks users should understand.

Install only if you are comfortable sending the images and approved copy you choose to AI Hive. Use a virtual environment, consider pinning dependencies, provide the API key via environment variable if you do not want it saved locally, and review generated images manually before publishing commercial or regulated content.

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/chinese_copy_image.py:226
Finding

API-Provided Upload and Download URLs Are Not Restricted to Trusted Hosts

Content
View full analysis

Vulnerability Details

File Location: scripts/chinese_copy_image.py:226-246, scripts/chinese_copy_image.py:323-355
Vulnerability Type: Insufficient validation of remote transfer destinations
Risk Level: Medium

Vulnerable Code

python
def upload(api, filename):
    path, content_type = source_file(filename)
    ticket = api.upload_ticket(path, content_type)
    media_id = ticket["mediaId"]
    transfer = ticket["upload"]
    url = transfer["url"]
    if urlparse(url).scheme != "https":
        raise SystemExit("素材上传地址必须使用 HTTPS")
    try:
        with path.open("rb") as handle:
            response = requests.request(
                transfer.get("method", "PUT"), url,
                headers=transfer.get("headers", {}), data=handle, timeout=300,
            )
    except requests.RequestException as exc:
        raise SystemExit("素材上传失败:" + str(exc))
    if not response.ok:
        raise SystemExit(
            "素材上传失败 {}:{}".format(response.status_code, response.text)
        )
    api.complete_upload(media_id)
    print("[source]", path.name, "->", media_id)
    return media_id
python
def safe_download(url, destination):
    if urlparse(url).scheme != "https":
        raise SystemExit("结果下载地址必须使用 HTTPS")
    destination.parent.mkdir(parents=True, exist_ok=True)
    try:
        with requests.get(url, stream=True, timeout=300) as response:
            response.raise_for_status()
            with destination.open("wb") as handle:
                for chunk in response.iter_content(8192):
                    if chunk:
                        handle.write(chunk)
    except requests.RequestException as exc:
        raise SystemExit("结果下载失败:" + str(exc))
    print("[saved]", destination)


def wait_and_download(api, task_id, output_dir, project):
    deadline = time.time() + 1200
    task = None
    while time.time() < deadline:
      
...[truncated 3411 chars]
Remediation
View remediation

Remediation Suggestions

  1. Maintain an explicit allowlist of approved upload and download hostnames and ports.
  2. Resolve destination hostnames and reject loopback, private, link-local, multicast, reserved, and cloud metadata addresses.
  3. Disable automatic redirects with allow_redirects=False, or validate the scheme, hostname, port, and resolved address at every redirect.
  4. Permit only the documented upload methods, such as PUT or POST, rather than accepting an arbitrary API-provided method.
  5. Filter API-provided headers against a narrow allowlist and reject sensitive or unexpected headers.
  6. Validate downloaded Content-Type, enforce a maximum response size, and verify the image's magic bytes before saving it.
  7. Write downloads to a temporary file, validate them, and then atomically rename them to the final destination.
  8. Consider binding transfer tickets cryptographically to the expected media identifier, destination, size, and expiration where supported by the service.

T08 · Insecure Dependencies

Note
Location
SKILL.md:149
Finding

Unpinned Third-Party Dependency Installation

Content
View full analysis

Vulnerability Details

File Location: SKILL.md:149
Vulnerability Type: Unpinned and non-reproducible dependency installation
Risk Level: Low

Vulnerable Code

bash
pip3 install requests

Technical Analysis

The installation instruction retrieves the latest package version selected by the package index at installation time. It does not specify an audited version, use a lockfile, or verify package hashes. Transitive dependencies are likewise unresolved until installation.

The package name is legitimate and there is no evidence of dependency confusion, typosquatting, or a currently malicious release. Nevertheless, the instruction creates a non-reproducible supply-chain boundary: future releases or altered package-index responses can introduce code that was not covered by this audit.

Python packages and their installation machinery can execute code in the user's environment during installation or later when imported. Pinning and integrity verification therefore materially reduce supply-chain exposure.

Attack Path

  1. A user follows the documented pip3 install requests instruction.
  2. pip resolves the package and applicable dependencies at installation time from its configured package index.
  3. A compromised package release, package index, mirror, or dependency version is selected.
  4. Unreviewed code is installed into the active Python environment.
  5. The code may execute during package installation or when chinese_copy_image.py imports requests.

Impact Assessment

Impact depends on the privileges of the Python environment used for installation. A compromised dependency could access files and credentials available to that user, make network requests, or modify the affected Python environment.

The project does not instruct users to install with elevated privileges, so system-wide compromise is not inherently available. In a normal user installation, scope would generally be lim ...[truncated 47 chars]

Remediation
View remediation

Remediation Suggestions

  1. Declare dependencies in a version-controlled requirements or lock file.
  2. Pin requests and all transitive dependencies to reviewed versions.
  3. Use hash verification, such as pip install --require-hashes -r requirements.txt.
  4. Install dependencies in an isolated virtual environment rather than the global Python environment.
  5. Use a trusted package index over TLS and document the expected index configuration.
  6. Periodically review and deliberately update pinned versions after vulnerability and compatibility testing.
Vulnerability Patterns
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • 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
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (3)

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
90% confidence
Finding

The skill invokes local scripts with shell commands, reads and writes files, uses environment variables such as $SKILL_PATH, and makes outbound network requests to a fixed API endpoint, but it declares no explicit tool permissions or scope. This creates an avoidable trust-boundary problem: an agent or runtime may grant broader capabilities than the skill actually needs, increasing the chance of misuse, unintended data access, or command execution in environments with sensitive files or credentials.

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 states the tool performs Chinese commercial copy image work, and the CLI/help text throughout the file is written exclusively in Chinese. Under the policy, language constraints should either offer user opt-in/choice or be explicitly documented as a justified locale-specific tool; that justification is not stated here.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Low
Category
Not specified by scanner
Confidence
86% confidence
Finding

The manifest describes generating commercial poster images with approved copy, offline character comparison, and repair workflows. Saving credentials to ~/.ai-hive/config.json is an auxiliary credential-management capability that is not part of that stated end-user purpose, even though the implementation tries to secure the file permissions.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.