Back to skill

Security audit

杰哥生图

Security checks for vulnerabilities and agentic risk

Overview

This image-generation skill is mostly coherent, but it sends OpenAI credentials and image content to a third-party gateway by default and follows unvalidated API-returned URLs.

Review before installing. Use only if you trust token.minapp.xin with your API key, prompts, and uploaded reference images, or override the base URL to a trusted provider. Avoid using confidential images or broad API keys, and check output paths carefully because the skill can write into the project and integrate generated assets.

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)

other

Error
Location
scripts/generate_image.py:21
Finding

API Credentials and User Content Are Sent to a Third-Party Gateway by Default

Content
View full analysis

Vulnerability Details

File Location: scripts/generate_image.py:21, scripts/generate_image.py:83-99, scripts/generate_image.py:132-151, and scripts/generate_image.py:228-273; documented in SKILL.md:47-49
Vulnerability Type: Credential and sensitive-data disclosure to a third-party service
Risk Level: High

Vulnerable Code

python
DEFAULT_BASE_URL = "https://token.minapp.xin/v1"
python
def request_json(
    endpoint: str, api_key: str, body: dict[str, Any], timeout: int
) -> Any:
    request = urllib.request.Request(
        endpoint,
        data=json.dumps(body, ensure_ascii=False).encode("utf-8"),
        headers={
            "Authorization": f"Bearer {api_key}",
            "Content-Type": "application/json",
            "Accept": "application/json",
        },
        method="POST",
    )
    return parse_response(request_bytes(request, timeout))
python
def request_multipart(
    endpoint: str,
    api_key: str,
    fields: dict[str, str],
    files: dict[str, Path],
    timeout: int,
) -> Any:
    payload, boundary = encode_multipart(fields, files)
    request = urllib.request.Request(
        endpoint,
        data=payload,
        headers={
            "Authorization": f"Bearer {api_key}",
            "Content-Type": f"multipart/form-data; boundary={boundary}",
            "Accept": "application/json",
        },
        method="POST",
    )
    return parse_response(request_bytes(request, timeout))
python
def request_edit(
    base_url: str,
    api_key: str,
    model: str,
    prompt: str,
    input_image: Path,
    size: str,
    quality: str,
    timeout: int,
) -> bytes:
    result = request_multipart(
        api_url(base_url, "/images/edits"),
        api_key,
        {
            "model": model,
            "prompt": prompt,
            "size": size,
            "qua
...[truncated 2461 chars]
Remediation
View remediation

Remediation Suggestions

  1. Use the official provider endpoint as the default, or require the user to configure a gateway explicitly before the first request.
  2. Display the exact destination hostname and the categories of data being transmitted before sending a prompt or reference image to a non-official service.
  3. Require gateway-specific, narrowly scoped credentials rather than forwarding a general-purpose OpenAI API key.
  4. Maintain an allowlist of approved HTTPS API hosts and reject unapproved destinations unless the user explicitly authorizes them.
  5. Reject plaintext HTTP base URLs to prevent credential interception.
  6. Separate credentials by provider so an OpenAI credential cannot accidentally be sent to a third-party gateway.
  7. Document the gateway operator, retention policy, privacy policy, and whether prompts or uploaded images are used for logging or model training.
  8. Encourage users to remove secrets and unnecessary personal or proprietary information from prompts and images before transmission.

T09 · Insecure Skill Coding Practices

Error
Location
scripts/generate_image.py:187
Finding

API-Controlled Image URL Enables Unrestricted Local and Network Resource Retrieval

Content
View full analysis

Vulnerability Details

File Location: scripts/generate_image.py:187-205
Vulnerability Type: Unrestricted URL fetching and server-side request forgery
Risk Level: High

Vulnerable Code

python
def download_image(image_url: str, timeout: int) -> bytes:
    request = urllib.request.Request(image_url, headers={"Accept": "image/*"})
    return request_bytes(request, timeout)


def extract_image_item(item: Any, timeout: int, source: str) -> bytes | None:
    if not isinstance(item, dict):
        return None
    for key in ("b64_json", "result", "image_base64", "base64"):
        encoded = item.get(key)
        if isinstance(encoded, str) and encoded:
            return decode_base64_image(encoded, source)
    image_url = item.get("url") or item.get("image_url")
    if isinstance(image_url, str) and image_url:
        if image_url.startswith("data:image/") and "," in image_url:
            return decode_base64_image(image_url.split(",", 1)[1], source)
        return download_image(image_url, timeout)
    content = item.get("content")
    if isinstance(content, list):
        for child in content:
            image = extract_image_item(child, timeout, source)
            if image is not None:
                return image
    return None

Technical Analysis

The image URL is taken directly from the remote API response and passed to urllib.request.urlopen without validating its scheme, hostname, port, resolved address, redirect chain, response content type, or response size.

Because the configured gateway controls the response, a malicious or compromised gateway can return a URL targeting loopback services, private network addresses, link-local infrastructure, cloud metadata endpoints, or other resources reachable from the machine running the Skill. Redirects are also followed without revalidating the final destination.

The downloader does not verify that the response is an ...[truncated 1915 chars]

Remediation
View remediation

Remediation Suggestions

  1. Accept only https image URLs.
  2. Maintain an allowlist of trusted image-delivery hostnames associated with the selected API provider.
  3. Resolve the hostname before connecting and reject loopback, private, link-local, multicast, unspecified, and reserved IPv4 and IPv6 addresses.
  4. Defend against DNS rebinding by validating the actual connected address, not only the result of an initial DNS lookup.
  5. Disable automatic redirects or validate the scheme, hostname, port, and resolved address after every redirect.
  6. Reject URLs containing embedded credentials or unexpected ports.
  7. Apply a strict maximum response size while streaming the body instead of using an unbounded response.read().
  8. Validate the HTTP status and require an appropriate image content type.
  9. Decode the downloaded data with a trusted image parser and verify that it is a valid supported image, preferably PNG, before writing it.
  10. Prefer base64 image data returned directly in the authenticated API response when the provider supports it, eliminating the secondary arbitrary URL request.
Vulnerability Patterns
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Taint TrackingDirect Taint Flow, Variable-Mediated Taint Flow, Credential Exfiltration Chain
  • 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 (5)

Tainted flow: 'request' from os.environ.get (line 142, credential/environment) → urllib.request.urlopen (network output)

Critical
Category
Data Flow
Confidence
95% confidence
Finding

This is a real SSRF-style issue: the script accepts a user-/environment-controlled base URL and later dereferences response-provided image URLs with urllib.request.urlopen. In this skill context, the tool is explicitly designed to fetch from a configurable gateway and to download arbitrary returned URLs, so a malicious or compromised gateway could cause network access to internal services or local metadata endpoints, and the Authorization bearer token is also sent to the attacker-controlled base URL if --base-url or OPENAI_BASE_URL is overridden.

Content

Scanner excerpt · scripts/generate_image.py (reported line 61)May include surrounding context.

python
def request_bytes(request: urllib.request.Request, timeout: int) -> bytes:
    try:
        with urllib.request.urlopen(request, timeout=timeout) as response:
            return response.read()
    except urllib.error.HTTPError as exc:
        details = exc.read().decode("utf-8", errors="replace")

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
91% confidence
Finding

The skill directs the agent to use environment variables, read local files, write generated assets into the project tree, and make outbound network requests, but it does not declare any explicit tool scope or permissions boundary. This creates a governance gap: the skill can induce sensitive actions without clear least-privilege constraints, making accidental overreach or misuse harder to detect and enforce.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The trigger description is extremely broad, covering nearly any image-related request, which can cause the skill to activate in situations where the user did not clearly intend networked generation or project file modification. Overbroad activation increases the chance of unexpected external API calls, costs, and writes to repository directories under normal conversational requests.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The instructions explicitly tell the agent to save outputs into project directories and integrate them into pages, but they do not require an explicit warning or confirmation before modifying workspace files. In practice, this can lead to silent repository changes, overwriting assets, or introducing externally generated content into builds without the user's informed consent.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The display name, description, and default prompt are all written in Chinese, which indicates a fixed language/locale experience. The file does not provide any opt-in, alternative locale, or justification that this is a region-specific skill, so it may violate language-choice policy.

Content

No source excerpt is available for this finding.