Back to skill

Security audit

小红书 电商图片生成与编辑

Security checks for vulnerabilities and agentic risk

Overview

This image-generation skill is mostly coherent, but it has a real credential-safety concern because an AI Hive API key can be sent to a user-configurable API host.

Review this before installing if you use a real AI Hive API key. Only use the default AI Hive endpoint, avoid setting --base-url or AI_HIVE_BASE_URL unless you fully trust the host, and consider installing requests in an isolated environment with pinned dependencies.

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

Error
Location
scripts/imagegen.py:58
Finding

Bearer API Key Disclosure Through an Unrestricted Custom Base URL

Content
View full analysis

Vulnerability Details

File Location: scripts/imagegen.py:58-69 and scripts/imagegen.py:106-121
Vulnerability Type: Unrestricted credential-bearing endpoint configuration
Risk Level: High

Complete Code Snippet:

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
class AiHiveClient:
    """Encapsulates AI Hive OpenAPI HTTP calls."""

    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
            )

Technical Analysis

The API base URL may be supplied through the --base-url command-line option, the AI_HIVE_BASE_URL environment variable, or the persistent configuration file. The value is accepted without validating its scheme or hostname.

The client subsequently attaches the AI Hive API key as a bearer token to every request sent to the configured endpoint. Consequently, an attacker-controlled base URL receives the user's Authorization header. The implementation does not enforce HTTPS, restrict destinations to trusted AI Hive domains, separate credentials by endpoint, or warn the user before sending credentials to a custom host.

Attack Path

  1. An atta ...[truncated 1129 chars]
Remediation
View remediation

Remediation Suggestions

  • Restrict authenticated API requests to an explicit allowlist of trusted HTTPS hostnames, such as the documented AI Hive API host.
  • Parse the URL using a standard URL parser and reject:
    • Plaintext HTTP endpoints
    • Embedded usernames or passwords
    • Unapproved hostnames
    • Unexpected ports
    • Malformed or ambiguous URLs
  • If custom endpoints are a required feature, do not automatically reuse the production AI Hive key. Require endpoint-specific credentials and explicit user confirmation.
  • Display the validated destination hostname before transmitting credentials to a custom endpoint.
  • Consider removing custom base URL support from normal skill commands when it is not essential.
  • Advise affected users to revoke and rotate any API key that may have been sent to an untrusted endpoint.

T08 · Insecure Dependencies

Note
Location
SKILL.md:71
Finding

Unpinned Runtime Installation of a Third-Party Dependency

Content
View full analysis

Vulnerability Details

File Location: SKILL.md:71-73
Vulnerability Type: Unpinned third-party dependency installation
Risk Level: Low

Complete Code Snippet:

bash
pip3 install requests
python3 "$SKILL_PATH/scripts/imagegen.py" init --skill-name xiaohongshu-ecommerce-image-generation-editing
python3 "$SKILL_PATH/scripts/imagegen.py" task --task-id <taskId>

Technical Analysis

The documented setup command installs requests without a pinned version or package hash. Package resolution therefore depends on the package index state at installation time and may install a version or transitive dependency that differs from the version reviewed during development.

The dependency name is legitimate, and there is no evidence that this project intentionally introduces a malicious package. Nevertheless, mutable dependency resolution weakens reproducibility and supply-chain integrity. A future compromised release, compromised package index response, or incompatible dependency update could affect users who follow the installation instructions.

Attack Path

  1. A user follows the documented pip3 install requests instruction.
  2. Pip resolves the latest permitted requests release and its transitive dependencies at that time.
  3. If a resolved package or distribution channel has been compromised, attacker-controlled package code is installed.
  4. The code may execute during installation or when imagegen.py imports requests.

Impact Assessment

The impact depends on the privileges of the Python environment in which pip and the skill run. Malicious dependency code could access files, environment variables, API keys, and network resources available to that user. If installation is performed with elevated privileges, the scope could be greater. No direct exploit or currently malicious dependency was identified, so the finding is rated Low.

Remediation
View remediation

Remediation Suggestions

  • Provide a reviewed dependency file with exact version pins, for example requests==<reviewed-version>.
  • Use hash verification, such as pip install --require-hashes -r requirements.txt, with hashes for all direct and transitive dependencies.
  • Maintain a lock file generated from a controlled and reviewed dependency resolution process.
  • Recommend installation in a dedicated virtual environment rather than the system Python environment.
  • Regularly scan pinned dependencies for known vulnerabilities and update them through a controlled review process.
  • Configure pip to use trusted package indexes and secure TLS settings.
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
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (9)

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The changelog content from L05 onward is written in Chinese and does not indicate that the skill is region-specific or that users can choose another language. Under the policy, forcing a specific language without user opt-in is a natural-language locale violation.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
90% confidence
Finding

The skill includes executable commands that invoke Python, install packages, access files, and likely make network requests, but it does not declare any explicit tool or permission scope. This creates an unnecessary trust gap: an agent may enable broader capabilities than users expect, increasing the risk of filesystem, shell, or network misuse if the skill is invoked in sensitive contexts.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The description uses broad 'Use this skill for ...' phrasing across many common image-editing and ecommerce scenarios, which can cause overbroad or accidental invocation. If auto-selection is used, the agent may route ordinary image requests into a skill that executes shell commands and networked scripts, expanding the attack surface without clear user intent.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The file advertises itself as a Xiaohongshu ecommerce image-generation skill, but actually exposes a general-purpose AI Hive client with chat, video, model enumeration, upload, and account-related operations. This capability mismatch violates least privilege and increases the attack surface, because a caller or integrator may trust the skill for narrow image tasks while it can perform broader actions than expected.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The module docstring and user-facing CLI text are written in Chinese, and the script's prompts, errors, and help strings consistently assume Chinese-language interaction. There is no indication that the skill is region-specific or that users can opt into another language, which creates a natural-language locale policy concern.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The implementation includes full video-generation support despite the skill being presented as an image-generation/editing tool. This hidden breadth enables unintended use, higher-cost operations, and broader media processing than consumers would reasonably expect from the declared scope.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

Exposing a user-info command that retrieves account and wallet/balance information is outside the stated purpose of ecommerce image generation. Even if read-only, it leaks sensitive account metadata and billing context to users or calling agents that should not need access to it.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
72% confidence
Finding

The file title and operational content are entirely in Chinese and the description embeds Chinese usage terms, but there is no note that users may choose another language or locale. This can amount to a locale/language policy issue when the skill appears to assume Chinese-language interaction by default rather than documenting that requirement or offering opt-in.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
91% confidence
Finding

The top-level documentation explicitly says the file is a general-purpose AI Hive tool covering chat, image, video, model queries, media upload, and task polling. That active characterization conflicts with the specialized image-commerce skill identity conveyed by the manifest and generated skill wrapper below.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.