Back to skill

Security audit

ERNIE-Image文生图SKILL

Security checks for vulnerabilities and agentic risk

Overview

This skill is a straightforward Baidu ERNIE image generator, but users should treat prompts and API keys carefully and avoid unsafe output paths.

Install only if you are comfortable sending image prompts to Baidu's API. Use a narrowly scoped Baidu key from an environment variable, avoid pasting secrets into chat or passing them with --api-key, and choose output filenames inside your workspace to avoid overwriting important files. Do not rely on this package for image editing; the shipped script supports text-to-image only.

Vulnerability Patterns
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • 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
Findings (3)

T08 · Insecure Dependencies

Warning
Location
scripts/generate_image.py:3
Finding

Unpinned OpenAI SDK Dependency Creates a Supply-Chain Risk

Content
View full analysis
=3.7" # dependencies = [ # "openai", # ] # /// ``` The installation documentation similarly requests the latest available package without a version or integrity constraint: ```text - Need Install python openai sdk: pip instsall openai ``` ### Technical Analysis The project declares the `openai` package without pinning a reviewed version or verifying package integrity. Consequently, the code executed by the skill depends on whichever compatible package release the package resolver selects at installation or execution time. If the upstream package, package index, dependency resolution path, or a transitive dependency is compromised, malicious code could run when the package is installed or imported. The documented installation command also contains the typo `instsall`, which is a reliability problem and could encourage users to seek untrusted alternative installation instructions. No malicious dependency is currently proven to be present. The vulnerability is the absence of controls ensuring that future installations resolve to a known, reviewed artifact. ### Attack Path 1. An attacker compromises a future `openai` package release, a transitive dependency, or the dependency distribution channel. 2. A user installs the dependency according to `SKILL.md`, or a script runner automatically resolves the inline dependency declaration. 3. Because no exact version or package hash is required, the resolver downloads the attacker-controlled artifact. 4. Malicious package code executes during installation or when `from openai import OpenAI` is imported. 5. The code runs with the same filesystem, environment, network, and credential access as the user or Agent invoking the skill. ### Impact Assessment Successful explo ...[truncated 385 chars]
Remediation
View remediation
", # ] ``` 2. Maintain a lockfile containing hashes for the direct dependency and its transitive dependencies. 3. Install packages only from a trusted, explicitly configured package index. 4. Incorporate dependency vulnerability and integrity scanning into release checks. 5. Review and deliberately update the pinned version instead of accepting updates automatically. 6. Correct the documentation to use a valid, pinned command, such as: ```bash python -m pip install "openai==" ``` 7. Prefer installation inside an isolated virtual environment with only the permissions required by the skill. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/generate_image.py:49
Finding

API Keys Can Be Exposed Through Chat Records and Command-Line Arguments

Content
View full analysis
str | None: """Get API key from argument first, then environment.""" if provided_key: return provided_key # Try multiple env var names for compatibility for key in ["ERNIE-Image_API_KEY", "ERNIE_Image_API_KEY", "BAIDU_API_KEY"]: value = os.environ.get(key) if value: return value return None ``` ### Technical Analysis Secrets supplied in chat may be retained in conversation history, Agent telemetry, command-generation logs, or external service records. Passing the same secret using `--api-key` additionally places it in the process argument vector. Depending on operating-system and process isolation settings, command-line arguments may be visible through process-inspection utilities or monitoring systems. They may also be retained in shell history or execution logs. Although the API request itself uses an HTTPS endpoint, transport encryption does not protect the credential from exposure before the request is sent. Environment variables are safer than command-line arguments in many environments but should still be supplied ...[truncated 1011 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/generate_image.py:69
Finding

User-Controlled Output Path Allows Unrestricted File Overwrite

Content
View full analysis
Remediation
View remediation
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Memory PoisoningPersistent Context Injection, Context Window Stuffing, Memory Manipulation
  • Rogue AgentSelf-Modification, Session Persistence
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
Findings (15)

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

The skill claims to support image editing and --input-image, but the documented behavior does not implement that functionality. This mismatch is dangerous because users or agents may provide sensitive local images expecting controlled edit behavior, while the actual implementation may ignore the input, fail unpredictably, or route data in ways not covered by the description.

Content

No source excerpt is available for this finding.

Missing User Warnings

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

The skill does not clearly warn that prompts and any input images may be transmitted to Baidu's external ERNIE-Image API. This omission is security- and privacy-relevant because users may share confidential text or local images without understanding that the data leaves the local environment.

Content

No source excerpt is available for this finding.

Memory Manipulation

High
Category
Memory Poisoning
Confidence
80% confidence
Finding

Skill manipulates agent memory, state, or stored context. Memory corruption can alter personality, override safety rules, or cause unpredictable behavior.

Content

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

md
- Prompt "A serene Japanese garden" → `2025-11-23-14-23-05-japanese-garden.png`
- Prompt "sunset over mountains" → `2025-11-23-15-30-12-sunset-mountains.png`
- Prompt "create an image of a robot" → `2025-11-23-16-45-33-robot.png`
- Unclear context → `2025-11-23-17-12-48-x9k2.png`

Credential Access

High
Category
Privilege Escalation
Confidence
70% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · DESIGN.md (reported line 143)May include surrounding context.

md
from openai import OpenAI

def get_api_key(provided_key: str | None) -> str | None:
    """Get API key from argument first, then environment."""
    if provided_key:
        return provided_key
    # Try multiple env var names for compatibility

Credential Access

High
Category
Privilege Escalation
Confidence
70% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

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

python
from openai import OpenAI

def get_api_key(provided_key: str | None) -> str | None:
    """Get API key from argument first, then environment."""
    if provided_key:
        return provided_key
    # Try multiple env var names for compatibility

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

At L028 the documentation explicitly states image editing is supported through --input-image. However, the later parameter table at L127-L133 contains no --input-image argument, and the API call described at L181-L187 only sends model, prompt, size, and response_format, which corresponds to text-to-image only. This is an active contradiction in the skill's own documentation about what the code does.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

Documenting silent overwrite behavior without a strong warning can lead to unintended destruction of existing files, especially because output paths are user-controlled and parent directories are auto-created. In an agent setting, this increases the chance of accidental clobbering of important local data when filenames collide.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The example normalizes passing API keys on the command line, which can expose secrets via process listings, shell history, logs, and agent telemetry. In a skill context, this is more dangerous because users may copy-paste examples directly and agents may record invocation details automatically.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
84% confidence
Finding

The skill documents use of an environment variable for an API key and operational script execution, but the manifest declares no explicit tool scope or permissions boundary. This can cause the agent framework to invoke the skill with broader-than-expected capabilities or without clear review of environment access, increasing the chance of unintended secret handling.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
Confidence
60% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

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

md
---
name: ERNIE-Image
description: Generate images with ERNIE-Image. Use for image create requests incl. edits. Supports text-to-image ; - 1024x1024/1376x768/1264x848/ 1200x896/896x1200/848x1264/768x1376; use --input-image.
---

# ERNIE-ImageImage Generation & Editing

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The invocation description is broad enough to match many ordinary image-related requests, which increases the likelihood of accidental activation. In a skill that sends prompts and possibly files to an external API, ambiguous triggering can cause unintended data disclosure or unexpected third-party processing.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
Confidence
60% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

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

md
Examples:
- Prompt "A serene Japanese garden" → `2025-11-23-14-23-05-japanese-garden.png`
- Prompt "sunset over mountains" → `2025-11-23-15-30-12-sunset-mountains.png`
- Prompt "create an image of a robot" → `2025-11-23-16-45-33-robot.png`
- Unclear context → `2025-11-23-17-12-48-x9k2.png`

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
90% confidence
Finding

The version history entry says the initial version supports 文生图、图生图 (text-to-image and image-to-image). But the detailed design sections document only prompt, filename, resolution, and API key handling, with a single /images/generations flow and no input image parameter or edit endpoint. This is a documentation-to-implementation contradiction rather than a mere omission.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
97% confidence
Finding

The script documentation and implementation consistently target Baidu's ERNIE-Image API, but the inline help for --api-key says "Gemini API key." That comment-like user-facing documentation contradicts the actual code path, which passes the key to an OpenAI-compatible client configured for Baidu's ERNIE-Image endpoint.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
82% confidence
Finding

This code creates parent directories and writes binary image data to a user-specified path, but it does not disclose whether an existing file may be overwritten or that filesystem changes will occur beyond a brief success message after the fact. Under the code-file warning criteria, file writes should have some user-facing disclosure before the operation unless clearly documented elsewhere in the skill description.

Content

No source excerpt is available for this finding.