Back to skill

Security audit

Imagen

Security checks for vulnerabilities and agentic risk

Overview

The skill does the image generation it advertises, but its script exposes an output path option that can write outside the declared workspace.

Review this before installing if workspace containment matters. It is suitable for sending image prompts to OpenRouter with an OpenRouter key, but avoid using or allowing --out-dir unless it is constrained to the workspace, and do not include secrets or regulated personal data in prompts sent to the provider.

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
scripts/gen_openrouter.py:416
Finding

Unrestricted Output Directory Permits Writes Outside the Workspace

Content
View full analysis

Vulnerability Details

File Location: scripts/gen_openrouter.py, lines 416–432, with the argument exposed at lines 462–466 and used at lines 504–505
Vulnerability Type: Unrestricted filesystem output path
Risk Level: Medium

Complete Code Snippet

python
def ensure_output_dir(custom_dir: Optional[str], workspace_dir: Path) -> Path:
    if custom_dir:
        custom_path = Path(custom_dir).expanduser()
        if custom_path.is_absolute():
            out_dir = custom_path.resolve()
        else:
            out_dir = (workspace_dir / custom_path).resolve()
    else:
        out_dir = (workspace_dir / "skills" / "imagen" / "out").resolve()

    out_dir.mkdir(parents=True, exist_ok=True)
    return out_dir

The destination is exposed as a command-line argument and used without a workspace-containment check:

python
p.add_argument(
    "--out-dir",
    default=None,
    help="Directorio de salida. Si es relativo, se resuelve dentro del workspace. "
         "Por defecto: skills/imagen/out",
)
python
out_dir = ensure_output_dir(args.out_dir, workspace_dir)
out_file = save_image(raw, ext, out_dir, args.quality)

Technical Analysis

The --out-dir option accepts arbitrary absolute paths. Relative paths are combined with the workspace and normalized using resolve(), but the normalized destination is never checked to ensure that it remains beneath workspace_dir. A value containing traversal components, such as ../../target, can therefore escape the intended workspace.

The script subsequently creates the selected directory and writes the generated image there using the permissions of the Agent process. This behavior conflicts with the Skill's declared restriction that generated output must remain in the current Agent workspace, normally under skills/imagen/out.

Although the documented invocation does not use --out-dir, the script exposes the option directly. Any caller or prompt-induced invocation capable of inf ...[truncated 1603 chars]

Remediation
View remediation

Remediation Suggestions

  1. Remove the --out-dir option if custom output locations are not required by the declared functionality.
  2. If customization is necessary, reject absolute paths and enforce containment after canonicalization:
python
def ensure_output_dir(custom_dir: Optional[str], workspace_dir: Path) -> Path:
    workspace_dir = workspace_dir.resolve()
    relative_dir = Path(custom_dir) if custom_dir else Path("skills/imagen/out")

    if relative_dir.is_absolute():
        raise ValueError("The output directory must be relative to the workspace.")

    out_dir = (workspace_dir / relative_dir).resolve()

    if not out_dir.is_relative_to(workspace_dir):
        raise ValueError("The output directory must remain inside the workspace.")

    out_dir.mkdir(parents=True, exist_ok=True)
    return out_dir
  1. Consider restricting output to the fixed workspace_dir / "skills" / "imagen" / "out" directory rather than merely any location under the workspace.
  2. Account for symbolic-link races where hostile local users can modify workspace paths. On supported platforms, use directory file descriptors, no-follow semantics, or an equivalent safe file-creation mechanism.
  3. Create files with collision-safe names and restrictive permissions where the runtime environment requires stronger multi-user isolation.
  4. Add automated tests covering absolute paths, .. traversal, symbolic links, and valid in-workspace destinations.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (9)

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
- ejecutar `SKILL.md`

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
- ejecutar `SKILL.md`

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
90% confidence
Finding

The skill clearly directs the agent to invoke a local script that reads configuration, uses an API key, performs network calls to OpenRouter, and writes files into the workspace, yet it declares no explicit tool scope or permission boundaries. That mismatch weakens least-privilege controls and can let a user-invocable skill exercise broader capabilities than reviewers or policy systems expect.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The description states that the skill generates images and saves files into the current workspace, but it does not clearly disclose to the end user that invoking it will create persistent files. In a user-invocable skill, silent file creation can surprise users, clutter workspaces, and cause unintended persistence of sensitive prompts or generated content.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The skill instructs the agent to execute immediately without confirmation even though the action both writes files and sends the prompt to an external service. Removing confirmation and omitting any privacy or side-effect warning increases the chance of unintended data disclosure and unreviewed filesystem changes, especially when natural-language requests are interpreted broadly as image-generation commands.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The script description explicitly says it reads an API key and generates the image through OpenRouter, but it omits any warning that the user's prompt and related parameters are transmitted to a third-party service. In context, this is more dangerous because the skill is user-invocable and encourages direct execution, so users may unknowingly send confidential or regulated content off-platform.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
87% confidence
Finding

El script transmite el prompt del usuario a un servicio externo (OpenRouter) sin una advertencia explícita en el propio flujo del programa ni confirmación de consentimiento. En un entorno de agente, esto puede provocar exfiltración involuntaria de datos sensibles incluidos en el prompt, especialmente porque la skill está diseñada para operar automáticamente con la configuración activa y credenciales ya disponibles.

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 user-facing error text in Spanish, and similar Spanish-only strings appear throughout argument descriptions and runtime messages. Because the skill does not offer a language or locale choice, it may violate a policy requiring no forced language without user opt-in.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
82% confidence
Finding

This function accesses sensitive credentials from OPENROUTER_API_KEY or local auth profile files. The code lacks an in-code warning, comment, or user-facing notice explaining that credentials will be read from these locations.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.