Back to skill

Security audit

Flow Image Gen

Security checks for vulnerabilities and agentic risk

Overview

This image-generation skill is coherent and not deceptive, but its runner has file-write containment and output validation weaknesses users should review.

Install only if you trust the job directory contents and are comfortable sending image prompts to Google's Gemini API with your GEMINI_API_KEY. Prefer running it in a clean, private per-job directory, and avoid preexisting or shared images folders until the runner rejects symlinks and validates each expected PNG output.

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

T09 · Insecure Skill Coding Practices

Error
Location
scripts/gen_images.sh:40
Finding

Symbolic Link Allows Writes Outside the Job Directory

Content
View full analysis
"$DEST" } ``` The destination is constructed elsewhere as follows: ```bash DEST="$JOB/images/$(basename "$FILE")" gen_one "$ID" "$PROMPT" "$DEST" & ``` ### Technical Analysis Using `basename` prevents direct `../` path traversal through the timeline filename, but it does not protect against symbolic links already present in the `images` directory. The script writes directly to `$DEST` using shell redirection without checking whether the destination is a symbolic link. The initial `-s` test only skips an existing target whose resolved file has a nonzero size. It does not reject: - A dangling symbolic link. - A symbolic link to an empty writable file. - A link whose target changes between the check and the write. When redirection opens such a path, the operating system follows the symbolic link. Generated image bytes can consequently be written to a location outside `$JOB/images`. The separate existence check and subsequent write also create a time-of-check-to-time-of-use race. An attacker with concurrent write access to the job directory could replace the destination with a symbolic link after the check. ### Attack Path 1. The attacker obtains the ability to prepare or modify the supplied job directory. 2. The attacker creates `JOB/images/scene.png` as a symbolic link to an empty file writable by the account running the Skill. 3. The attacker places `scene.png` in the corresponding timeline entry in `input.json`. 4. The Skill derives the destination as `JOB/images/scene.png`. 5. Because the symbolic-link targe ...[truncated 847 chars]
Remediation
View remediation
&2 return 1 fi ``` 2. Canonicalize the images directory and destination parent, then verify that the destination remains beneath the canonical images directory. 3. Create a temporary output file inside the images directory with restrictive permissions. 4. Decode and validate the response into that temporary file. 5. Atomically rename the validated temporary file to the final destination. 6. Use an operating-system mechanism that refuses to follow links, such as `openat2` with path-resolution restrictions or `O_NOFOLLOW`, if implemented through a helper language. 7. Do not rely on a check followed by ordinary shell redirection, because that remains vulnerable to a race. 8. Restrict permissions on the job and images directories so untrusted users cannot modify them during generation. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/gen_images.sh:58
Finding

Generated Files Are Accepted Without Verifying PNG Format

Content
View full analysis
/dev/null 2>&1; then jq -r '.candidates[0].content.parts[] | select(.inlineData) | .inlineData.data' "$RESP" | base64 -d > "$DEST" local SZ SZ=$(stat -c%s "$DEST" 2>/dev/null || stat -f%z "$DEST" 2>/dev/null || echo 0) if [ "${SZ:-0}" -ge 10000 ]; then echo "OK $DEST"; rm -f "$REQ" "$RESP"; return 0 fi fi ``` ### Technical Analysis The generated output is considered successful solely when the decoded file is at least 10,000 bytes. The implementation does not verify: - The PNG eight-byte signature. - Whether the complete file can be parsed as a PNG. - Whether the file has valid image dimensions and chunk structure. - Whether the MIME type returned in `inlineData` is an expected image type. - Whether exactly one expected image payload was returned. Consequently, arbitrary base64-decoded content of sufficient size can be saved with a `.png` extension and marked as successful. This differs from the documented behavior in `SKILL.md`, which states that the runner verifies that the output is a valid PNG. Because the content originates at an external API trust boundary, it must be validated before being supplied to downstream image decoders or rendering tools. ### Attack Path 1. The remote response contains an `inlineData.data` value that decodes to at least 10 KB of non-PNG or malformed image data. 2. The response has HTTP status 200 and no top-level `.error` value. 3. `jq` extracts the data and `base64 -d` writes it to a file with a `.png` extension. 4. The size test succeeds even though the file is not a valid PNG. 5. The script reports `OK`, and downstream workflow stages consume the malformed file. This path requires an anomalous or malicious external response, or anot ...[truncated 647 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/gen_images.sh:99
Finding

Unrelated PNG Files Can Mask Failed Image Generation

Content
View full analysis
.png. (.timeline // []) as $tl | [ $tl[] | select(.image) | {key: (.id // .image), image: .image} ] as $byid | .image_prompts as $ip | range(0; ($ip | length)) as $i | $ip[$i] as $p | ( ($byid[] | select(.key == $p.id) | .image) // $tl[$i].image // ($p.id + ".png") ) as $dest | [ $p.id, $p.prompt, $dest ] | @tsv ' "$INPUT") wait # Recompute result: every prompt id must have produced a file. TOTAL=$(jq '.image_prompts | length' "$INPUT") HAVE=$(ls -1 "$JOB/images/"*.png 2>/dev/null | wc -l | tr -d ' ') echo "Generated $HAVE/$TOTAL images." [ "${HAVE:-0}" -lt "${TOTAL:-0}" ] && RC=1 exit $RC ``` ### Technical Analysis The final success decision compares the number of requested prompts with the total number of files matching `JOB/images/*.png`. It does not verify that each expected destination exists, is nonempty, is valid, or corresponds to a requested prompt. Although worker processes can return nonzero, their statuses are not reliably accumulated into `RC`. The script initializes `RC=0`, but the final result is primarily determined by the aggregate PNG count. Therefore, unrelated, stale, or attacker-created PNG files can compensate numerically for missing expected outputs. The script can exit successfully even when one or more requested images were not generated. The same integrity problem applies to preexisting expected outputs: `gen_one` skips any nonempty destination without validating that it is a PNG or that it belongs to the current job. ### Attack Path 1. A job requests two image outputs. 2. The attacker or a prior job le ...[truncated 922 chars]
Remediation
View remediation
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • 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)

Chaining Abuse

High
Category
Tool Misuse
Confidence
75% confidence
Finding

Tool calls are chained to bypass individual safety checks or escalate capabilities beyond what any single tool call would allow.

Content

Scanner excerpt · scripts/gen_images.sh (reported line 66)May include surrounding context.

sh
local SZ
      SZ=$(stat -c%s "$DEST" 2>/dev/null || stat -f%z "$DEST" 2>/dev/null || echo 0)
      if [ "${SZ:-0}" -ge 10000 ]; then
        echo "OK $DEST"; rm -f "$REQ" "$RESP"; return 0
      fi
    fi
    [ "$attempt" = 1 ] && sleep 2

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
93% confidence
Finding

The skill performs shell operations and external network access but does not declare an explicit tool scope such as permissions or allowed-tools. That increases the risk that an orchestrator or agent grants broader execution capability than intended, making misuse or unexpected command execution harder to constrain and audit.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
60% confidence
Finding

Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Content

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

md
6. Build the work list: for each `image_prompts[i]`, the destination filename comes from the matching `timeline[].image` (matched by `id`, else positional, else `<id>.png`).

7. Generate the images — **up to 4 in parallel**, never sequentially one curl at a time (a 14-image job drops from ~4 min to ~1 min of waiting). Per image:

   a. Build the destination path: `$JOB/images/<filename>`.

External Transmission

Medium
Category
Data Exfiltration
Confidence
70% confidence
Finding

Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Content

Scanner excerpt · scripts/gen_images.sh (reported line 57)May include surrounding context.

sh
local attempt
  for attempt in 1 2; do
    CODE=$(curl -sS -X POST "$ENDPOINT" \
      -H "x-goog-api-key: $GEMINI_API_KEY" \
      -H "Content-Type: application/json" \
      -d @"$REQ" -w "%{http_code}" -o "$RESP")