Back to skill

Security audit

AI大模型专家|农产品品牌AI图片视频营销

Security checks for vulnerabilities and agentic risk

Overview

The skill is mostly aligned with AI-HIVE marketing generation, but it under-discloses sensitive API-key handling and can send that key to a user-configurable API endpoint.

Review this skill before installing if you plan to use a real AI-HIVE key. Prefer passing the key via environment variable, avoid init unless you accept plaintext storage in ~/.ai-hive/config.json, do not set custom base URLs unless you fully trust the endpoint, and only upload media you are authorized to send to AI-HIVE.

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/imagegen.py:91
Finding

Bearer API Credential Can Be Redirected to an Arbitrary Endpoint

Content
View full analysis

Vulnerability Details

File Location: scripts/imagegen.py:91-100, 128-143; scripts/videogen.py:91-100, 128-143
Vulnerability Type: Unrestricted API endpoint override leading to credential disclosure
Risk Level: Medium

Vulnerable Code

The same implementation appears in both scripts/imagegen.py and scripts/videogen.py:

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
        )

Technical Analysis

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

The HTTP client subsequently adds the user's bearer API key to every request sent to the configured base URL. Consequently, an attacker-controlled endpoint receives the Authorization header. The implementation also accepts unencrypted HTTP URLs, which can expose credentials to network interception.

This is a credential-forwarding vulnerability caused by combining an unrestricted destination override with automatic attachment of sensitive authentication mate ...[truncated 1725 chars]

Remediation
View remediation

Remediation Suggestions

  1. Permit the official https://ai-hive.iclip.cn origin by default and validate the parsed hostname, scheme, and effective port before attaching credentials.
  2. Reject plaintext HTTP endpoints whenever an API key is present.
  3. If custom endpoints are required for development, require an explicit option such as --allow-custom-endpoint, display the destination, and request confirmation before transmitting credentials.
  4. Maintain separate authentication policies for official and custom origins. Do not automatically forward the production API key to nonstandard hosts.
  5. Avoid following redirects that cross origins while retaining the Authorization header.
  6. Validate upload URLs returned by the API against documented object-storage schemes and host policies before uploading media.
  7. Apply the same centralized, hardened HTTP client to both scripts to prevent security fixes from diverging.
  8. Add tests covering malicious base URLs, non-HTTPS URLs, deceptive subdomains, embedded credentials, unusual ports, and cross-origin redirects.

T09 · Insecure Skill Coding Practices

Note
Location
scripts/imagegen.py:646
Finding

Recommended Initialization Persists the API Key in a Plaintext File

Content
View full analysis

Vulnerability Details

File Location: scripts/imagegen.py:646-651; scripts/videogen.py:646-651; conflicting handling claim in SKILL.md:111
Vulnerability Type: Plaintext persistent storage of an API credential
Risk Level: Low

Vulnerable Code

The same initialization logic appears in both generation scripts:

python
config_dir = os.path.dirname(CONFIG_FILE_PATH)
os.makedirs(config_dir, exist_ok=True)
with open(CONFIG_FILE_PATH, "w", encoding="utf-8") as f:
    json.dump({"api_key": api_key, "base_url": DEFAULT_BASE_URL}, f, indent=2)
os.chmod(CONFIG_FILE_PATH, 0o600)

Technical Analysis

The recommended init workflow writes the complete reusable API key to ~/.ai-hive/config.json as plaintext JSON. Setting mode 0600 reduces exposure to other local operating-system accounts, but it does not encrypt the credential or protect it from processes running as the same user, home-directory backups, endpoint collection tools, accidental archival, or later permission and ownership errors.

The file is initially opened using the process umask and is only changed to mode 0600 after the key has been written. This creates a small avoidable interval during which the file can have broader permissions if the user's umask is permissive.

The behavior also conflicts with the acceptance statement in SKILL.md:111, which says that the API key exists only in environment variables and does not enter files. Users following the recommended initialization process therefore receive a weaker storage model than the documentation represents.

Attack Path

  1. The user follows the documented recommendation and runs the init command.
  2. The user pastes a valid AI-HIVE API key.
  3. The script writes the complete key to ~/.ai-hive/config.json in plaintext.
  4. A process executing as the same user, a compromised backup destination, or a tool collecting files from the home directory obtains the configuration fi ...[truncated 964 chars]
Remediation
View remediation

Remediation Suggestions

  1. Prefer an operating-system credential store such as Keychain, Credential Manager, or Secret Service instead of plaintext JSON.
  2. Alternatively, make environment-variable use the recommended default and remove the claim that initialization is preferred unless it uses secure credential storage.
  3. If file storage remains available, obtain explicit user consent and accurately document that the key will persist in plaintext.
  4. Create the file atomically with restrictive permissions from the outset, for example by using os.open with mode 0o600, rather than applying chmod after writing.
  5. Verify that the configuration path is a regular file owned by the current user and reject symbolic links before reading or writing it.
  6. Restrict the containing ~/.ai-hive directory to mode 0700.
  7. Add commands for deleting stored credentials and provide clear key revocation and rotation guidance.
  8. Update SKILL.md so its API-key handling statement matches the implemented behavior.
  9. Apply the remediation consistently to both imagegen.py and videogen.py.
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (20)

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding

The reported gap between the declared industry-specific marketing skill and the underlying general AI/API utility behavior is a trust and access-control problem, not just a product mismatch. If a skill marketed for agricultural brand content also exposes generic chat, multimodal input, or user-info/wallet queries without clear disclosure, it can collect more data and perform broader actions than users or platform reviewers expect.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding

The reported gap between the declared industry-specific marketing skill and the underlying general AI/API utility behavior is a trust and access-control problem, not just a product mismatch. If a skill marketed for agricultural brand content also exposes generic chat, multimodal input, or user-info/wallet queries without clear disclosure, it can collect more data and perform broader actions than users or platform reviewers expect.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

The reported gap between the declared industry-specific marketing skill and the underlying general AI/API utility behavior is a trust and access-control problem, not just a product mismatch. If a skill marketed for agricultural brand content also exposes generic chat, multimodal input, or user-info/wallet queries without clear disclosure, it can collect more data and perform broader actions than users or platform reviewers expect.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

The reported gap between the declared industry-specific marketing skill and the underlying general AI/API utility behavior is a trust and access-control problem, not just a product mismatch. If a skill marketed for agricultural brand content also exposes generic chat, multimodal input, or user-info/wallet queries without clear disclosure, it can collect more data and perform broader actions than users or platform reviewers expect.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
86% confidence
Finding

The skill advertises executable workflows and shell commands that imply access to environment variables, local files, networking, and command execution, but it declares no explicit tool scope or permission boundary. This creates an overly broad and ambiguous trust boundary: a caller or host may permit sensitive operations without a clear least-privilege contract, increasing the risk of secret exposure, unintended file access, or unsafe external requests.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The default prompt hard-codes Chinese output regardless of the user's language preference, which can override user intent and reduce transparency about how the skill behaves. In a marketing workflow, this can cause confusing or unusable outputs for non-Chinese-speaking users and may lead to accidental miscommunication in generated business content.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The entire skill file is written in Chinese and presents its guidance only in that language, with no indication that users may choose another language or locale. Under the stated policy, forcing a specific language without user opt-in is a natural-language policy violation unless the locale constraint is clearly documented and justified.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · scripts/edit_video.py (reported line 20)May include surrounding context.

python
def run(args: list[str]) -> None:
    print(" ".join(args))
    subprocess.run(args, check=True)


def main() -> None:

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The file is presented as a specialized agriculture-brand image/video marketing skill, but the module-level implementation is a generic AI-Hive client exposing broader capabilities such as text chat, user-info, model listing, uploads, and task inspection. This scope mismatch weakens least-privilege boundaries: a caller expecting a narrowly scoped media-generation skill may unknowingly gain access to unrelated account and generic model operations.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The module docstring and all user-facing guidance are written only in Chinese, and the CLI help/messages throughout the file assume Chinese output without any opt-in or locale selection. This is a natural-language policy concern because it imposes a specific language on users rather than offering a choice or documenting a justified locale restriction.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The presence of a user-info endpoint allows retrieval of account-related information, including wallet/balance metadata, which is unrelated to the stated marketing-content purpose. In a skill ecosystem, exposing unnecessary account introspection increases the risk of sensitive data disclosure and capability creep if the script is reused, invoked incorrectly, or later wrapped by another agent.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The embedded generic text-chat pathway lets the skill send arbitrary prompts and optional images to a TEXT model, which materially exceeds the advertised image/video marketing scope. This broadens the skill into a general LLM proxy, creating opportunities for unintended data handling, policy bypass through alternate model routes, and misuse beyond the expected agricultural media workflow.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The file embeds its core skill behavior and output content in Chinese-only string constants for industry, mode, focus, channels, and policy boundary. This creates a language/locale constraint without any user opt-in or alternative, which matches the policy category for forced language behavior.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The file is presented as a specialized agriculture-brand marketing skill, but the implementation embeds a broader generic AI-Hive client with model listing, chat, upload, and general generation primitives. This scope mismatch increases the attack surface and can enable use of capabilities outside the user-approved purpose, undermining least-privilege and making policy bypass or unintended data handling more likely.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The module header explicitly describes a generic AI capability tool, which contradicts the advertised specialized agriculture-brand marketing identity. This kind of misrepresentation is dangerous because reviewers and users may grant trust, permissions, or sensitive inputs under a narrower expectation while the code supports materially broader operations.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This code file contains user-facing natural-language strings and documentation entirely in Chinese, including the module docstring and CLI guidance. Because the skill does not offer language selection or explain that it is intentionally region- or locale-specific, it violates the language/locale policy for natural-language behavior.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The generic text chat capability exceeds the stated image/video marketing workflow and allows arbitrary prompt-based interaction with any text model selected by publicModelId. In a constrained skill context, this creates a channel for unintended model use, policy circumvention, and transmission of user data or uploaded media beyond the declared purpose.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
87% confidence
Finding

The module docstring explicitly says this is a '通用 AI 能力调用工具' and lists broad chat, image, video, model query, upload, and polling abilities. That directly conflicts with the surrounding skill identity and manifest, which present a domain-specific agricultural product brand marketing skill rather than a generic AI platform client.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

The docstring states the script creates a 'deterministic industry marketing brief without network calls,' but the payload includes datetime.now(timezone.utc).isoformat(). That means repeated runs with identical inputs produce different output, which directly contradicts the stated deterministic behavior.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Low
Category
Not specified by scanner
Confidence
85% confidence
Finding

The manifest focuses on generating and managing agriculture-brand marketing image/video workflows, model selection, uploads, pricing snapshots, and task tracking. Querying 'user-info' including wallet balance is an account-management capability that is not necessary to fulfill that stated purpose.

Content

No source excerpt is available for this finding.