Back to skill

Security audit

Openai Image Gen 1.0.1

Security checks for vulnerabilities and agentic risk

Overview

The skill does what it says, but it silently allows an environment variable to redirect the OpenAI API key and prompts to another endpoint.

Install only if you are comfortable running a local script that sends prompts and an OpenAI API key over the network. Before use, make sure OPENAI_BASE_URL and OPENAI_API_BASE are unset or trusted, avoid sensitive prompts, and be cautious opening generated galleries made from untrusted prompt text.

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

Error
Location
scripts/gen.py:29
Finding

OpenAI API Credential Can Be Sent to an Arbitrary Environment-Controlled Endpoint

Content
View full analysis
str: base = ( os.environ.get("OPENAI_BASE_URL") or os.environ.get("OPENAI_API_BASE") or "https://api.openai.com" ).rstrip("/") if base.endswith("/v1"): return f"{base}/images/generations" return f"{base}/v1/images/generations" ``` The selected API key is placed in an authorization header without validating the destination: ```python def _post_json(url: str, api_key: str, payload: dict, timeout_s: int) -> dict: body = json.dumps(payload).encode("utf-8") req = urllib.request.Request( url, data=body, headers={ "Authorization": f"Bearer {api_key}", "Content-Type": "application/json", }, method="POST", ) try: with urllib.request.urlopen(req, timeout=timeout_s) as resp: raw = resp.read() ``` The environment-derived URL and API key are then used together: ```python api_key = args.api_key or os.environ.get("OPENAI_API_KEY") if not api_key: print("missing OPENAI_API_KEY (or --api-key)", file=sys.stderr) return 2 # ... url = _api_url() items: list[dict] = [] for i, prompt in enumerate(prompts, 1): payload = { "model": args.model, "prompt": prompt, "size": args.size, "quality": args.quality, "n": 1, "response_format": "b64_json", } data = _post_json(url=url, api_key=api_key, payload=payload, timeout_s=args.timeout) ``` ### Technical Analysis The script accepts `OPENAI_BASE_URL` and `OPENAI_API_BASE` as authoritative network destinations. It does not validate that the resulting URL: - Uses HTTPS. - Resolves to ...[truncated 2097 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/gen.py:135
Finding

Unescaped Prompt Content Enables Script Injection in the Generated HTML Gallery

Content
View full analysis
None: html = [ "", "", "", "openai-image-gen", "", "body{font-family:ui-sans-serif,system-ui;margin:24px;max-width:1060px}", ".card{display:grid;grid-template-columns:220px 1fr;gap:16px;align-items:start;margin:18px 0}", "img{width:220px;height:220px;object-fit:cover;border-radius:14px;box-shadow:0 14px 38px rgba(0,0,0,.14)}", "pre{white-space:pre-wrap;margin:0;background:#111;color:#eee;padding:12px 14px;border-radius:14px;line-height:1.35}", "", "

openai-image-gen

", ] for it in items: html.append("
") html.append(f"") html.append(f"
text
{it['prompt']}
") html.append("
") with open(os.path.join(out_dir, "index.html"), "w", encoding="utf-8") as f: f.write("\n".join(html)) ``` ### Technical Analysis Prompt content accepted through the repeatable `--prompt` option is stored verbatim in each item and interpolated directly into `index.html`. The code does not apply context-appropriate HTML escaping before inserting the prompt between `
text
` tags.

An attacker-controlled prompt can terminate the `
text
` element and inject arbitrary HTML or JavaScript. For example, a value structurally equivalent to the following would introduce executable markup:

```html
text
```

The generated gallery is intended to be opened in a browser according to `SKILL.md`, so the injection reaches an execution s
...[truncated 1719 chars]
Remediation
View remediation
") html_parts.append(f"
text
{safe_prompt}
") ``` 3. Prefer a template engine with automatic escaping enabled rather than constructing HTML through string interpolation. 4. Continue restricting generated filenames to a conservative character set and ensure paths cannot contain directory traversal sequences. 5. Add tests using prompts containing `<`, `>`, `&`, single quotes, double quotes, closing tags, and script elements. 6. Add a restrictive Content Security Policy to the generated document as defense in depth, for example prohibiting scripts and limiting network destinations. Escaping remains mandatory because CSP alone does not safely render attacker-controlled text. ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • System Prompt LeakageDirect Leakage, Indirect Extraction, Tool-Based Exfiltration
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (4)

Direct Prompt Extraction

High
Category
System Prompt Leakage
Confidence
85% confidence
Finding

Skill contains instructions that could directly expose system prompts, internal rules, or hidden instructions to users or external parties.

Content

Scanner excerpt · scripts/gen.py (reported line 94)May include surrounding context.

python
f"Palette: {random.choice(palettes)}. "
            "Crisp, no text, no watermark."
        )
    return prompts


def _post_json(url: str, api_key: str, payload: dict, timeout_s: int) -> dict:

Direct Prompt Extraction

High
Category
System Prompt Leakage
Confidence
85% confidence
Finding

Skill contains instructions that could directly expose system prompts, internal rules, or hidden instructions to users or external parties.

Content

Scanner excerpt · scripts/gen.py (reported line 164)May include surrounding context.

python
p.add_argument("--out-dir", default=None)
    p.add_argument("--api-key", default=None)
    p.add_argument("--prompt", action="append", default=None, help="repeatable; overrides random prompts")
    p.add_argument("--dry-run", action="store_true", help="print prompts + exit (no API calls)")
    args = p.parse_args(argv)

    api_key = args.api_key or os.environ.get("OPENAI_API_KEY")

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
95% confidence
Finding

The skill invokes a Python script that uses an API key from the environment and sends data over the network, but the skill manifest declares no explicit tool scope or permissions. This creates an authorization and transparency gap: users and hosting frameworks cannot easily tell that the skill requires secret access and outbound network capability before running it.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The skill documentation tells users how to generate prompts and images but does not clearly warn that prompts and generated outputs are transmitted to the OpenAI Images API and that results are stored on local disk. In a prompt-generation workflow, users may supply sensitive or proprietary text, so the lack of disclosure increases the risk of unintended data exfiltration to a third party and persistent local storage of potentially sensitive content.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.