Back to skill

Security audit

sudocode-gpt-image-2-gen

Security checks for vulnerabilities and agentic risk

Overview

The skill does what it claims, but its instructions create a real command-injection risk when user prompts or filenames are placed into shell command templates.

Review this skill before installing. It is purpose-aligned, but only use it in an environment where the agent invokes the helper scripts with structured arguments or fully escapes user-controlled values. Do not paste secrets into command-line flags on shared systems, and understand that prompts and uploaded images are sent to the configured SudoCode-compatible API endpoint.

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

Error
Location
SKILL.md:45
Finding

Shell Command Injection Through Direct Interpolation of User-Controlled Arguments

Content
View full analysis

Vulnerability Details

File Location: SKILL.md:45-61
Vulnerability Type: Shell command injection in Skill instructions
Risk Level: High

The Skill instructs the Agent to place user-controlled prompts, filenames, editing instructions, and input paths directly into shell command templates:

bash
node scripts/generate_image.js -p "{prompt}" -f "{filename}" [-s {size}] [-q {quality}] [-o {output_format}]

node scripts/generate_image.js -p "{edit_instruction}" -i "{input_path}" -f "{output_filename}" [-s {size}] [-q {quality}]

node scripts/generate_image.js -p "融合图1和图2的风格" -i ref1.png ref2.png -f "merged.png" [-s {size}] [-q {quality}]

python scripts/generate_image.py -p "{prompt}" -f "{filename}" [-s {size}] [-q {quality}] [-o {output_format}]

python scripts/generate_image.py -p "{edit_instruction}" -i "{input_path}" -f "{output_filename}" [-s {size}] [-q {quality}]

Technical Analysis

The placeholders in these templates may contain attacker-controlled content. The surrounding double quotes do not provide reliable shell escaping. A value containing a double quote can terminate the intended argument, after which shell separators, command substitutions, redirections, or other metacharacters can be interpreted by the shell.

This issue exists in the Skill execution instructions rather than in the argument parsing inside the JavaScript and Python programs. Both scripts receive arguments through their runtime argument arrays, but that protection is bypassed if the Agent first constructs a command string and sends it to a shell.

The vulnerable values include:

  • The image-generation prompt
  • The image-editing instruction
  • The output filename
  • Input image paths
  • Optional size, quality, and output-format values if interpolated before validation

Because the Skill also directs the Agent to preserve the user's complete original prompt, an attacker-controlled quote or shell expression can reach the do ...[truncated 1935 chars]

Remediation
View remediation

Remediation Suggestions

  1. Do not construct shell command strings by interpolating prompts, filenames, paths, or other user-controlled values.
  2. Invoke the program through an argument-array API with shell interpretation explicitly disabled. For example:
    javascript
    spawn(
      "node",
      [
        "scripts/generate_image.js",
        "-p",
        prompt,
        "-f",
        filename,
        "-s",
        size,
        "-q",
        quality
      ],
      { shell: false }
    );
    
  3. Update SKILL.md to explicitly require structured process invocation and prohibit passing dynamically constructed command strings to a shell.
  4. If the execution environment only provides a shell interface, apply platform-specific shell escaping to every dynamic argument and reject values that cannot be represented safely. Argument-array execution remains the preferred solution.
  5. Validate output filenames and input paths separately:
    • Restrict output files to an approved directory.
    • Resolve and normalize paths before use.
    • Reject unexpected control characters.
    • Enforce allowlists for size, quality, and output format before execution.
  6. Do not accept shell syntax as part of generated command templates. Keep user prompts as opaque argument values from input collection through process invocation.
  7. Add tests containing quotes, command substitutions, separators, newlines, and redirection characters to verify that each value reaches the script as exactly one argument and never executes as shell syntax.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Taint TrackingDirect Taint Flow, Variable-Mediated Taint Flow, Credential Exfiltration Chain
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (16)

Tainted flow: 'headers' from os.environ.get (line 191, credential/environment) → requests.post (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 · scripts/generate_image.py (reported line 246)May include surrounding context.

python
print('image generation in progress...')

        try:
            response = requests.post(url, headers=headers, files=files_list, timeout=DEFAULT_TIMEOUT)
            response.raise_for_status()
            data = response.json()
        except requests.exceptions.Timeout:

Tainted flow: 'headers' from os.environ.get (line 191, credential/environment) → requests.post (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 · scripts/generate_image.py (reported line 293)May include surrounding context.

python
print('image generation in progress...')

        try:
            response = requests.post(url, headers=headers, json=payload, timeout=DEFAULT_TIMEOUT)
            response.raise_for_status()
            data = response.json()
        except requests.exceptions.Timeout:

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
- **优先尝试 Node.js 版本**:如果环境有 Node(`node` 命令可用),优先使用 `scripts/generate_image.js`(零依赖,参数与 Python 保持一致)。

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
- **优先尝试 Node.js 版本**:如果环境有 Node(`node` 命令可用),优先使用 `scripts/generate_image.js`(零依赖,参数与 Python 保持一致)。

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
- **优先尝试 Node.js 版本**:如果环境有 Node(`node` 命令可用),优先使用 `scripts/generate_image.js`(零依赖,参数与 Python 保持一致)。

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
- **优先尝试 Node.js 版本**:如果环境有 Node(`node` 命令可用),优先使用 `scripts/generate_image.js`(零依赖,参数与 Python 保持一致)。

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
- **优先尝试 Node.js 版本**:如果环境有 Node(`node` 命令可用),优先使用 `scripts/generate_image.js`(零依赖,参数与 Python 保持一致)。

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
- **优先尝试 Node.js 版本**:如果环境有 Node(`node` 命令可用),优先使用 `scripts/generate_image.js`(零依赖,参数与 Python 保持一致)。

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
- **优先尝试 Node.js 版本**:如果环境有 Node(`node` 命令可用),优先使用 `scripts/generate_image.js`(零依赖,参数与 Python 保持一致)。

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
- **优先尝试 Node.js 版本**:如果环境有 Node(`node` 命令可用),优先使用 `scripts/generate_image.js`(零依赖,参数与 Python 保持一致)。

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
89% confidence
Finding

The skill instructs the agent to use environment variables, write output files, and make networked API calls, but it declares no explicit tool scope or permissions boundary. In an agent platform, this increases the chance of over-broad execution and makes it harder to constrain or audit what the skill is allowed to access.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The trigger text is very broad and can match many ordinary image-related requests, which may cause the skill to activate unexpectedly. Because the skill then performs external API calls and file writes, accidental invocation can leak user content to a third-party service or incur unintended cost.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The documentation tells users to pass the API key directly on the command line, which can expose the secret through shell history, process listings, logs, or terminal recording tools. This is a well-known credential-handling risk and is especially problematic for shared systems or debugging environments.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
80% confidence
Finding

The script transmits user prompts to an external service and allows the destination host to be overridden by the OPENAI_IMAGE_BASE_URL environment variable. In a skill context, this matters because users may provide sensitive text or images for editing, and a misconfigured or malicious endpoint could receive that data and the bearer token.

Content

Scanner excerpt · scripts/generate_image.py (reported line 293)May include surrounding context.

python
print('image generation in progress...')

        try:
            response = requests.post(url, headers=headers, json=payload, timeout=DEFAULT_TIMEOUT)
            response.raise_for_status()
            data = response.json()
        except requests.exceptions.Timeout:

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
96% confidence
Finding

The file’s help text, comments, errors, and runtime status messages are written in Chinese throughout, and there is no option for users to select another language. For a general-purpose image generation script, this is a natural-language locale policy concern because it imposes a specific language without opt-in.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
92% confidence
Finding

This code file contains user-facing natural-language instructions, argument descriptions, and examples exclusively in Chinese. Under the stated policy, forcing a specific language without user opt-in is a locale/language policy violation unless the constraint is explicitly justified, which is not present here.

Content

No source excerpt is available for this finding.