Back to skill

Security audit

illustrations-local-storage

Security checks for vulnerabilities and agentic risk

Overview

The skill does what it claims, but its default downloader can fetch any HTTP(S) image URL found in Markdown, which is risky for untrusted documents or sensitive networks.

Install only if you will process trusted Markdown or can run it in a network-restricted environment. Use --allowed-host for known SoMark/object-storage domains, avoid running it on documents supplied by untrusted parties, and prefer a virtual environment for the Pillow dependency.

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

T09 · Insecure Skill Coding Practices

Error
Location
illustrations_local_storage.py:197
Finding

Unrestricted Outbound Image Requests Enable Server-Side Request Forgery

Content
View full analysis

Vulnerability Details

File Location: illustrations_local_storage.py, lines 197–202, 289–291, and 295–317
Vulnerability Type: Server-Side Request Forgery (SSRF) caused by an optional host allowlist
Risk Level: High

Vulnerable Code

python
parser.add_argument(
    "--allowed-host",
    action="append",
    default=[],
    metavar="HOST",
    help="只下载指定域名,可重复传入;默认不限制域名",
)
python
def _host_is_allowed(url: str, allowed_hosts: set[str]) -> bool:
    if not allowed_hosts:
        return True
    hostname = (urllib.parse.urlsplit(url).hostname or "").lower().rstrip(".")
    return any(hostname == host or hostname.endswith("." + host) for host in allowed_hosts)
python
def _download_once(
    url: str,
    temp_path: Path,
    timeout: float,
    max_bytes: int,
    allowed_hosts: set[str],
) -> DownloadResult:
    if not _host_is_allowed(url, allowed_hosts):
        raise LocalizationError(f"图片域名不在允许列表中:{url}")

    request = urllib.request.Request(
        url,
        headers={
            "Accept": "image/*,*/*;q=0.8",
            "User-Agent": f"illustrations-local-storage/{VERSION}",
        },
    )
    try:
        with urllib.request.urlopen(request, timeout=timeout) as response:
            final_url = response.geturl()
            if not _host_is_allowed(final_url, allowed_hosts):
                raise LocalizationError(f"图片重定向到了未允许的域名:{final_url}")

Technical Analysis

The script extracts attacker-controllable HTTP or HTTPS image URLs from Markdown and passes them to urllib.request.urlopen(). The --allowed-host option defaults to an empty list, and _host_is_allowed() explicitly interprets an empty allowlist as permission to access every hostname.

Consequently, URLs targeting loopback interfaces, private network ranges, link-local addresses, cloud metadata services, or other internal services are not rejected. The final redirect URL is checked, but that check provides no protection under the default con ...[truncated 2529 chars]

Remediation
View remediation

Remediation Suggestions

  1. Require an explicit host allowlist by default. Reject remote downloads when no --allowed-host value is supplied, or provide a narrowly scoped default list of trusted SoMark object-storage domains.

  2. Reject unsafe address ranges. Before connecting, resolve every destination hostname and reject all resolved IPv4 and IPv6 addresses belonging to:

    • Loopback ranges
    • Private ranges
    • Link-local ranges
    • Unspecified ranges
    • Multicast ranges
    • Reserved or documentation ranges
  3. Validate every redirect hop. Use a controlled redirect handler that validates the scheme, hostname, port, and resolved IP address before following each redirect. Checking only the final URL is insufficient because an unsafe redirect request may already have occurred.

  4. Mitigate DNS rebinding. Ensure the address validated is the address used for the connection. Where feasible, pin the validated resolved address for the request while preserving correct TLS hostname verification.

  5. Restrict schemes and ports. Continue allowing only HTTP and HTTPS, and consider limiting destination ports to those required by trusted object-storage services.

  6. Apply network-level egress controls. Run the downloader in an environment that denies access to loopback services, private networks, link-local metadata services, and unrelated external destinations.

  7. Make unrestricted operation an explicit high-risk opt-in. If arbitrary public image hosting must be supported, require a clearly named flag rather than treating unrestricted access as the default.

  8. Add security tests. Cover direct and redirected requests to loopback, RFC 1918, IPv6 private and loopback addresses, link-local metadata addresses, alternative IP representations, and hostnames resolving to prohibited networks.

Vulnerability Patterns
  • 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
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (5)

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding

Most of the implementation matches the declared purpose: it processes one file or a directory batch, downloads remote images, stores them locally in package directories, and rewrites Markdown accordingly. It also appropriately avoids ZIP creation and supports SoMark-style packaging. However, a material behavior is missing from the description: after download, every image is converted to JPEG via Pillow, including alpha compositing onto white for transparent images, and filenames are rewritten to a global numeric .jpg naming scheme. This is more than an implementation detail because it changes the image format/content and may affect fidelity, transparency, animation, and vector properties. Therefore the description does not fully or accurately represent the actual behavior.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
70% confidence
Finding

Without declared permissions the skill's intent is opaque and cannot be validated.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The manifest describes persisting remote image URLs locally and producing rewritten Markdown plus images, which implies preserving the original image assets in local form. Here the implementation unconditionally converts every downloaded image into JPEG files, changing file format and potentially image fidelity/transparency rather than just localizing them.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
96% confidence
Finding

This Python file contains natural-language CLI descriptions, help strings, and error messages entirely in Chinese. Under the stated policy, forcing a specific language without user opt-in is a natural-language policy violation because users are not offered any locale selection or alternative language.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
88% confidence
Finding

The comment says the code matches SoMark ZIP naming by sorting provisional on-disk names and then applying a global numeric sequence. But the actual return value discards the computed candidate filenames entirely and hardcodes every output name as image_###.jpg, which is a materially different behavior from what the comment suggests.

Content

No source excerpt is available for this finding.