Back to skill

Security audit

imgforge — Free AI Image Generation

Security checks for vulnerabilities and agentic risk

Overview

This image-generation skill appears purpose-built, but it needs review because it sends prompts and an API token to ModelScope and downloads an API-provided URL without tight destination or size checks.

Install only if you are comfortable sending image prompts to ModelScope/Alibaba and protecting a ModelScope API token. Avoid putting secrets, private business data, or personal data in prompts, keep the API key out of shared logs and repositories, prefer a pinned/trusted installer, and be aware that the current downloader does not restrict where the returned image URL may point.

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

Warning
Location
imgforge.py:42
Finding

Unvalidated API-Provided Image URL Enables Server-Side Request Forgery

Content
View full analysis

Vulnerability Details

File Location: imgforge.py, lines 42–44, 67, and 116–117
Vulnerability Type: Server-side request forgery and unbounded remote response handling
Risk Level: Medium

Vulnerable Code

python
def _fetch_bytes(url: str) -> bytes:
    with urllib.request.urlopen(url, timeout=120) as r:
        return r.read()

The URL originates from the remote task response and is used without validation:

python
if st == "SUCCEED":
    return data["output_images"][0]
python
url = _await_task(token, tid)
_save(_fetch_bytes(url), dest)

Technical Analysis

The application trusts output_images[0] returned by the ModelScope API and passes it directly to urllib.request.urlopen. It does not:

  • Require the https scheme.
  • Restrict downloads to documented ModelScope or image-CDN hostnames.
  • validate redirect destinations.
  • Reject loopback, link-local, private, reserved, or cloud-metadata IP addresses.
  • Validate that the response content type is an image.
  • Limit the number of bytes read into memory.

If the API, an upstream component, or the task response is compromised, an attacker-controlled URL can cause the Agent host to issue requests to otherwise inaccessible local or internal resources. Depending on supported URL handlers and runtime configuration, the URL may also reference an unintended local or non-HTTP resource.

Reading the complete response with r.read() without a size limit additionally creates a denial-of-service risk from an excessively large or non-terminating response. The resulting bytes are then written to a user-selected local path without confirming that they represent an image.

Attack Path

  1. A user invokes the Skill to generate an image.
  2. The Skill authenticates to the declared ModelScope service and creates an asynchronous generation task.
  3. A compromised or malicious upstream response returns an attacker-controlle ...[truncated 1360 chars]
Remediation
View remediation

Remediation Suggestions

  1. Parse the returned URL and accept only the https scheme.
  2. Maintain an explicit allowlist of documented ModelScope image-delivery hostnames. Reject user-information components, unexpected ports, malformed hosts, and all other domains.
  3. Disable automatic redirects or validate every redirect target using the same scheme, hostname, port, and address checks.
  4. Resolve the hostname and reject loopback, private, link-local, multicast, reserved, unspecified, and cloud-metadata destinations for both IPv4 and IPv6. Mitigate DNS rebinding by connecting only to the validated resolved address while preserving correct TLS hostname verification.
  5. Require an expected image media type and validate the downloaded bytes with an image decoder before saving them.
  6. Stream the response in bounded chunks rather than calling unrestricted read(). Enforce a conservative maximum file size and abort when Content-Length or streamed bytes exceed it.
  7. Apply separate connection and read timeouts and limit redirect count.
  8. Prefer a documented API mechanism that returns image bytes directly or signed URLs restricted to a known trusted CDN.
  9. Save downloaded data to a temporary file first and atomically move it to the destination only after all checks succeed.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • System Prompt LeakageDirect Leakage, Indirect Extraction, Tool-Based Exfiltration
  • Rogue AgentSelf-Modification, Session Persistence
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Taint TrackingDirect Taint Flow, Variable-Mediated Taint Flow, Credential Exfiltration Chain
Findings (27)

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

Critical
Category
Data Flow
Confidence
90% confidence
Finding

Credentials or environment variables flow to a network sink. This is a high-confidence indicator of credential exfiltration.

Content

Scanner excerpt · imgforge.py (reported line 44)May include surrounding context.

python
def _fetch_bytes(url: str) -> bytes:
    with urllib.request.urlopen(url, timeout=120) as r:
        return r.read()

Agent Config Directory Access

High
Category
Agent Snooping
Confidence
90% confidence
Finding

Skill reads from agent configuration directories (.claude/, .codex/, .gemini/). These directories may contain API keys, personal settings, and other credentials that the skill has no legitimate need to access.

Content

Scanner excerpt · SKILL.md (reported line 68)May include surrounding context.

md
3. Create a token at https://modelscope.ai/my/access/token
4. Set the environment variable: `export MODELSCOPE_API_KEY="ms-..."`

For Claude Code users, add to `~/.claude/settings.json` under `"env"`.

## Errors

Lp1

High
Category
MCP Least Privilege
Confidence
90% confidence
Finding

This skill makes authenticated outbound requests to a third-party inference service and downloads remote content, yet the network capability is reportedly undeclared. In permissioned agent frameworks, missing network declarations are a real security issue because they hide data egress and expand the runtime attack surface beyond what operators expect.

Content

No source excerpt is available for this finding.

Lp1

High
Category
MCP Least Privilege
Confidence
90% confidence
Finding

This skill makes authenticated outbound requests to a third-party inference service and downloads remote content, yet the network capability is reportedly undeclared. In permissioned agent frameworks, missing network declarations are a real security issue because they hide data egress and expand the runtime attack surface beyond what operators expect.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The README says users can 'Just ask naturally' and gives generic phrases like 'Generate an image of...' and 'Create a minimalist logo...'. Without explicit trigger boundaries, exclusions, or context constraints, these phrases are broad enough to collide with normal assistant requests and could cause unintended invocation.

Content

No source excerpt is available for this finding.

Indirect Prompt Extraction

Medium
Category
System Prompt Leakage
Confidence
75% confidence
Finding

Skill contains patterns that could indirectly extract system prompts through rephrasing, translation, summarization, or side-channel techniques.

Content

Scanner excerpt · README.md (reported line 171)May include surrounding context.

md
| `MODELSCOPE_API_KEY is not set` | See [Setup](#setup) above |
| `401 Unauthorized` | Use **modelscope.ai** (not .cn). Bind Alibaba Cloud in settings. Regenerate token. |
| Timeout | API under load — retry in a minute |
| Content moderation | Rephrase your prompt |

---

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The skill description and usage guidance do not prominently warn that user prompts are transmitted to a third-party external service and that an API key is required. This can lead users to unknowingly send sensitive or proprietary text to an external provider, creating privacy and data-handling risk.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The activation guidance includes generic verbs like "generate, create, draw, or make an image" and broad use cases like visualizing a concept or creating graphics. These phrases are common in ordinary conversation and the file does not provide exclusions or tighter constraints, which could cause unintended invocation.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
Confidence
89% confidence
Finding

The skill instructs users to create third-party accounts, bind services, and generate a persistent API token, which increases session persistence and long-lived credential exposure outside the agent environment. This expands the trust boundary and can lead to ongoing unintended use, billing/account linkage, or credential leakage if the token is stored insecurely.

Content

Scanner excerpt · SKILL.md (reported line 63)May include surrounding context.

md
Requires `MODELSCOPE_API_KEY`. If the user hasn't set it, guide them:

1. Create a free Alibaba Cloud account (phone verification + payment method required, but Z-Image is free) → https://www.alibabacloud.com/campaign/benefits?referral_code=A9242N
2. Sign up at https://modelscope.ai/register?inviteCode=futurizerush&invitorName=futurizerush&login=true&logintype=register and bind the Alibaba Cloud account in settings
3. Create a token at https://modelscope.ai/my/access/token
4. Set the environment variable: `export MODELSCOPE_API_KEY="ms-..."`

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The README tells users to place a ModelScope API token in an environment variable but does not clearly state that the token is a secret credential that must be protected and never committed, logged, or shared. In a developer-assistant skill context, this is more dangerous because users may follow setup instructions verbatim in shells, repos, screenshots, or agent sessions, increasing the chance of credential leakage and unauthorized API use.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The README explains that prompts are sent to the external ModelScope API to generate images, but it does not clearly warn users that their text prompts and possibly related metadata leave the local environment and are processed by a third party. In a skill designed for natural-language interaction, users may unknowingly submit sensitive, proprietary, or regulated information, making the missing privacy notice materially risky.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The README instructs users to place a live API token in an environment variable but does not warn that the token is a sensitive credential, should not be committed to shell profiles, logs, screenshots, or shared transcripts, and may be exposed through agent tooling. In an AI-assistant skill context, users often paste commands into logged environments, increasing the chance of accidental credential disclosure.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The README states that the skill sends image-generation requests to the external ModelScope API but does not clearly warn that user prompts are transmitted to a third party. In an AI assistant context, prompts may contain sensitive business data, personal information, or proprietary material, so lack of disclosure increases the risk of unintended data exposure.

Content

No source excerpt is available for this finding.

Rp1

Medium
Category
MCP Rug Pull
Confidence
70% confidence
Finding

npx commands without a version suffix (e.g. @1.0.0) create a rug-pull risk if the upstream server is compromised and publishes a malicious update.

Content

No source excerpt is available for this finding.

Rp1

Medium
Category
MCP Rug Pull
Confidence
70% confidence
Finding

npx commands without a version suffix (e.g. @1.0.0) create a rug-pull risk if the upstream server is compromised and publishes a malicious update.

Content

No source excerpt is available for this finding.

Rp1

Medium
Category
MCP Rug Pull
Confidence
70% confidence
Finding

npx commands without a version suffix (e.g. @1.0.0) create a rug-pull risk if the upstream server is compromised and publishes a malicious update.

Content

No source excerpt is available for this finding.

Rp1

Medium
Category
MCP Rug Pull
Confidence
91% confidence
Finding

The README instructs users to run npx clawhub@latest install zimage, which fetches and executes remote code without pinning to a specific version. If the upstream package is compromised or a malicious release is published, users could execute attacker-controlled code during installation.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The skill sends user-supplied prompts and an API token to a third-party service but provides no explicit privacy or data-handling warning at the point of use. In this skill context, prompts may contain sensitive user data, and users may not realize their content is transmitted to and processed by an external provider.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
87% confidence
Finding

Este archivo markdown instruye al usuario a establecer MODELSCOPE_API_KEY en varios entornos, pero no incluye ninguna advertencia sobre tratar el token como secreto, evitar compartirlo o no cometerlo en archivos de configuración. Dado que las instrucciones exponen una operación relacionada con credenciales, falta una advertencia básica de seguridad al usuario.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
93% confidence
Finding

This markdown file includes setup steps for storing a ModelScope API key in an environment variable, which is a credential-related action covered by the missing-warning rule for markdown files. The surrounding instructions do not warn users to keep the token secret, avoid committing it to shell history or dotfiles, or rotate it if exposed.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

The example command places the API token directly into a shell environment variable, but the documentation provides no warning about handling secrets safely. For markdown files, omission of privacy or credential-safety warnings around such behavior is in scope for this rule.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
94% confidence
Finding

These installation and usage steps again require users to export a ModelScope API token, yet the README contains no disclosure about the privacy and security implications of credential handling. Because this markdown file describes behavior affecting sensitive user data, a warning is expected.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
81% confidence
Finding

This markdown file tells users to place a ModelScope token into the MODELSCOPE_API_KEY environment variable, but it does not include any caution about handling the token as a secret. Environment variables can be exposed through shell history, process inspection, or shared terminal sessions, so a brief user warning would improve safety transparency.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
92% confidence
Finding

The README instructs users to export MODELSCOPE_API_KEY directly in the shell, which can expose the credential through shell history, process listings in some environments, terminal scrollback, or inherited subprocess environments. While common, this is still a real secret-handling weakness because users are not warned about safer alternatives.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
87% confidence
Finding

The README tells users to create and export MODELSCOPE_API_KEY but does not clearly warn that this token is a sensitive secret sent to an external third-party API. Users may accidentally expose the credential in shell history, logs, screenshots, shared terminals, or commit it into config files, leading to unauthorized API use.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.