Back to skill

Security audit

Image Gen

Security checks for vulnerabilities and agentic risk

Overview

The skill is for legitimate image generation, but it needs review because it sends user prompts to an external API through raw curl examples without clearly requiring safe JSON construction.

Review this skill before installing. Use it only if you are comfortable sending prompts and reference image URLs to Labnana, avoid sensitive prompt content, and ensure any implementation builds request bodies with safe JSON serialization rather than interpolating user text into shell strings. The API call should happen only after explicit confirmation.

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
SKILL.md:240
Finding
Unsafe Shell and JSON Construction with User-Controlled Image Parameters<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 127-135, 150-153, and 240-253 **Vulnerability Type**: Command injection and malformed JSON caused by unsafe handling of user-controlled data **Risk Level**: Medium ### Vulnerable Code ```text If yes, collect URLs (comma-separated, max 14). For each URL, infer mimeType from suffix and build: ```json { "fileData": { "fileUri": "<url>", "mimeType": "<inferred>" } } ``` ``` ```text 1. **Build request**: Construct JSON with provider, model, prompt, imageConfig, and optional referenceImages 2. **Submit**: `POST https://api.labnana.com/openapi/v1/images/generation` with timeout of 600s ``` ```bash RESPONSE=$(curl -sS -X POST "https://api.labnana.com/openapi/v1/images/generation" \ -H "Authorization: Bearer $LISTENHUB_API_KEY" \ -H "Content-Type: application/json" \ --max-time 600 \ -d '{ "provider": "google", "model": "gemini-3-pro-image-preview", "prompt": "cyberpunk city at night", "imageConfig": {"imageSize": "2K", "aspectRatio": "16:9"} }') BASE64_DATA=$(echo "$RESPONSE" | jq -r '.candidates[0].content.parts[0].inlineData.data // .data') ``` ### Technical Analysis The skill directs the agent to place a user-supplied prompt and user-supplied reference-image URLs into a JSON request submitted through a shell command. However, it does not prescribe JSON-safe serialization or shell-safe argument handling. The example passes the JSON body as a single-quoted shell string. If an implementation replaces the fixed example prompt with user-controlled content through textual interpolation, an apostrophe can terminate the shell string. Additional shell syntax could then be interpreted as commands. Quotes, backslashes, control characters, and newlines can also corrupt the JSON even when they do not result in command execution. Reference-image URLs create the same class of risk if they are concatenated directly into the request body. Merely checking a URL suffix to infer a ...[truncated 1865 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Construct the request body using `jq` so every untrusted value is JSON-escaped: ```bash REQUEST_FILE=$(mktemp) trap 'rm -f "$REQUEST_FILE"' EXIT jq -n \ --arg provider "google" \ --arg model "$MODEL" \ --arg prompt "$PROMPT" \ --arg imageSize "$IMAGE_SIZE" \ --arg aspectRatio "$ASPECT_RATIO" \ '{ provider: $provider, model: $model, prompt: $prompt, imageConfig: { imageSize: $imageSize, aspectRatio: $aspectRatio } }' > "$REQUEST_FILE" curl -sS -X POST \ "https://api.labnana.com/openapi/v1/images/generation" \ -H "Authorization: Bearer $LISTENHUB_API_KEY" \ -H "Content-Type: application/json" \ --max-time 600 \ --data-binary "@$REQUEST_FILE" ``` 2. Build reference-image arrays with `jq --arg` or `jq --argjson`; never concatenate URLs into a JSON or shell string. 3. Treat model, resolution, and aspect-ratio selections as allowlisted enumerations rather than arbitrary strings. 4. Validate reference URLs with a proper URL parser. Permit only intended schemes such as `https`, reject embedded credentials, and enforce the maximum count separately. 5. Avoid `eval`, generated shell source, and nested command strings for all user-controlled values. 6. Check `curl` exit status and HTTP status before processing the response. Verify that extracted base64 data exists and is valid before decoding it. ]]>

T09 · Insecure Skill Coding Practices

Note
Location
SKILL.md:166
Finding
Predictable Temporary Image Path Permits Symlink-Based File Overwrite<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 166-168 **Vulnerability Type**: Insecure temporary-file creation **Risk Level**: Low ### Vulnerable Code ```bash JOB_ID=$(date +%s) echo "$BASE64_DATA" | base64 -D > /tmp/image-gen-${JOB_ID}.jpg ``` ### Technical Analysis The temporary output filename is derived solely from the current Unix timestamp. It is therefore predictable within a one-second window. The file is created using ordinary shell redirection in the shared `/tmp` directory, without exclusive creation, ownership verification, a private parent directory, or symlink protection. On a multi-user system, another local user can predict the destination and create it before the skill writes the image. If the attacker creates a symbolic link at that location, shell redirection follows the link and writes the decoded image data to the link target. The overwrite remains constrained by the permissions of the account running the skill. Nevertheless, this can corrupt an arbitrary file writable by that account or cause the agent to read and present an attacker-controlled file instead of the generated output. ### Attack Path 1. A local attacker observes or predicts when image generation will occur. 2. The attacker calculates the timestamp-based filename, such as `/tmp/image-gen-<epoch>.jpg`. 3. Before the skill opens the path, the attacker creates a symbolic link at that location pointing to a file writable by the agent account. 4. The skill executes shell redirection to the predictable path. 5. The operating system follows the symbolic link and overwrites the target with decoded image data. 6. Alternatively, the attacker can pre-create or replace the temporary file to interfere with the image subsequently displayed by the agent. ### Impact Assessment A successful attack could: - Overwrite or corrupt files writable by the agent account. - Substitute or tamper with the image shown to the user. - Cause denial of service in workflows ...[truncated 278 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Create a private temporary directory with an unpredictable name: ```bash TMP_DIR=$(mktemp -d "${TMPDIR:-/tmp}/image-gen.XXXXXXXXXX") || exit 1 chmod 700 "$TMP_DIR" trap 'rm -rf "$TMP_DIR"' EXIT OUTPUT_FILE="$TMP_DIR/output.jpg" printf '%s' "$BASE64_DATA" | base64 --decode > "$OUTPUT_FILE" ``` 2. Do not use timestamp-only values as security-sensitive filenames. 3. Keep restrictive permissions by setting an appropriate umask before creating temporary output: ```bash umask 077 ``` 4. Use platform-appropriate base64 decoding selected through explicit operating-system detection rather than assuming the macOS `-D` option. 5. Verify that the resulting path is a regular file owned by the current user before passing it to another tool. 6. Ensure cleanup occurs on normal completion, errors, and interruption by registering a shell `trap`. ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (8)

Vague Triggers

Medium
Confidence
95% confidence
Finding
The trigger list includes very broad everyday verbs like "draw" and "visualize," which can cause the skill to activate in unrelated contexts. That increases the chance of unintended prompt collection and external API submission when the user did not clearly intend to use image generation.

Vague Triggers

Medium
Confidence
91% confidence
Finding
The usage guidance reinforces vague activation terms such as "draw" without requiring image-specific context. In a conversational agent, that can cause accidental invocation during normal discussion of drawing, diagrams, or abstract visualization, leading to unintended workflow execution.

External Transmission

Medium
Category
Data Exfiltration
Content
- No shell scripts. Construct curl commands from the API reference files listed in Resources
- Always read `shared/authentication.md` for API key and headers
- Follow `shared/common-patterns.md` for error handling
- Image generation uses a **different base URL**: `https://api.labnana.com/openapi/v1`
- Always read config following `shared/config-pattern.md` before any interaction
- Output saved to `.listenhub/image-gen/YYYY-MM-DD-{jobId}/` — never `~/Downloads/`
Confidence
50% confidence
Finding
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

External Transmission

Medium
Category
Data Exfiltration
Content
- No shell scripts. Construct curl commands from the API reference files listed in Resources
- Always read `shared/authentication.md` for API key and headers
- Follow `shared/common-patterns.md` for error handling
- Image generation uses a **different base URL**: `https://api.labnana.com/openapi/v1`
- Always read config following `shared/config-pattern.md` before any interaction
- Output saved to `.listenhub/image-gen/YYYY-MM-DD-{jobId}/` — never `~/Downloads/`
Confidence
50% confidence
Finding
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

External Transmission

Medium
Category
Data Exfiltration
Content
- No shell scripts. Construct curl commands from the API reference files listed in Resources
- Always read `shared/authentication.md` for API key and headers
- Follow `shared/common-patterns.md` for error handling
- Image generation uses a **different base URL**: `https://api.labnana.com/openapi/v1`
- Always read config following `shared/config-pattern.md` before any interaction
- Output saved to `.listenhub/image-gen/YYYY-MM-DD-{jobId}/` — never `~/Downloads/`
Confidence
50% confidence
Finding
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Natural-Language Policy Violations

Medium
Confidence
97% confidence
Finding
The instruction to always use English keywords overrides user language preference and can silently transform user input before external transmission. This is risky because it reduces transparency, may distort meaning, and can cause the agent to send a materially different prompt than the user intended.

External Transmission

Medium
Category
Data Exfiltration
Content
5. No references

```bash
RESPONSE=$(curl -sS -X POST "https://api.labnana.com/openapi/v1/images/generation" \
  -H "Authorization: Bearer $LISTENHUB_API_KEY" \
  -H "Content-Type: application/json" \
  --max-time 600 \
Confidence
60% confidence
Finding
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Natural-Language Policy Violations

Medium
Confidence
96% confidence
Finding
Line L56 states 'Always write prompts in English' and instructs translating Chinese prompts before submission. This is a natural-language locale policy constraint that forces a specific language without presenting it as optional or justified as a region-specific requirement.

Static analysis

No suspicious patterns detected.